Server-side exports
isInOrg
Does exactly the same thing as the client sided export, returns true if player is in an organization, false if else, the only difference is you can pass a player server id
exports['cs_crime']:isInOrg(source)
getOrgData
Returns all data of a specified organization, searches by organization ID
exports['cs_crime']:getOrgData(OrgId)
Example data returned from this export
{
success = true,
data = {
id = 1,
name = "Los Santos Familia",
announcements = {
{
id = 1,
content = "Meeting tonight at 20:00",
author = "char1:123456",
authorName = "John Doe",
timestamp = 1703425200,
pinned = false
}
},
members = {
["char1:123456"] = {
grade = 5,
gradeName = "Leader",
name = "John Doe",
last_seen = "2023-12-24 20:00:00"
},
["char1:654321"] = {
grade = 3,
gradeName = "Officer",
name = "Jane Smith",
last_seen = "2023-12-24 19:30:00"
}
},
grades = {
["0"] = { name = "Recruit", permissions = {} },
["1"] = { name = "Member", permissions = {"groupStash"} },
["3"] = { name = "Officer", permissions = {"groupStash", "addMember"} },
["5"] = { name = "Leader", permissions = {"*"} }
},
account_number = "123456789",
balance = 50000,
upgrades = {
organization = {
["1"] = 2,
["2"] = 1
},
base = {
["1"] = 1
}
},
market_access = true,
market_slots = 5,
hideout = {
id = 1,
coords = vector3(100.0, 200.0, 30.0),
streetName = "Grove Street",
purchasedAt = "2023-12-01 12:00:00",
furniture = {
completed = true,
items = {
stash = {
coords = vector3(101.0, 201.0, 30.0),
heading = 90.0,
type = "member_stash"
}
}
}
},
active_missions = {
{
id = 1,
name = "Bank Heist",
started_at = "2023-12-24 18:00:00",
duration = 3600,
reward = 100000
}
},
completed_missions = {
{
id = 2,
name = "Store Robbery",
completed_at = "2023-12-23 15:00:00",
reward = 25000
}
},
transactions = {
{
id = "tx_123",
amount = 25000,
type = "deposit",
description = "Mission reward",
timestamp = "2023-12-23 15:00:00",
metadata = {
source = "mission_complete",
reference = "mission_2"
}
}
},
activeMembers = {
{
name = "John Doe",
grade = 5,
gradeName = "Leader"
}
}
}
}
getOrgDataFromIdentifier
Works the same way getOrgData does, with a minor difference, returns organization data based on a players identifier, additionally returns a "self" json object which contains player data from the specified identifier
exports['cs_crime']:getOrgDataFromIdentifier(identifier)
-- Additionally returns this in the json
self = {
name = "Mike Wazowski",
gradeName = "Leader",
grade = 5,
identifier = "char1:1234123123",
permissions = {"groupStash", "addMember"}
}
getOrgOnlineMembers
Returns all online members of a specified organization by organization id, if nothing passed returns every online organization player and passes additional data such as org_name and org_id, if a string is passed it searches the database for a organization with an exact match in name column and returns online members from that organization.
exports['cs_crime']:getOrgOnlineMembers(orgId)
Example returned data from this export
{
{
identifier = "char1:123456",
name = "John Doe",
grade = 5,
gradeName = "Leader",
permissions = {
groupStash = true,
bossStash = true,
startMission = true,
addMember = true,
removeMember = true,
manageMember = true,
manageGrades = true,
checkBalance = true,
withdrawBalance = true,
depositBalance = true,
viewMembers = true,
purchaseMarket = true,
sellMarket = true,
manageMarket = true,
purchaseUpgrade = true,
purchaseHideout = true,
manageAnnouncements = true
}
},
{
identifier = "char1:654321",
name = "Jane Smith",
grade = 2,
gradeName = "Officer",
permissions = {
groupStash = true,
bossStash = false,
startMission = true,
addMember = true,
removeMember = true,
manageMember = true,
manageGrades = false
}
}
}
getOrgMembers
Returns all organization members, by organization id, if nothing passed returns every organization player and passes additional data such as org_name and org_id, if a string is passed it searches the database for a organization with an exact match in name column and returns members from that organization.
exports['cs_crime']:getOrgMembers(orgId)
Example returned data from this export
{
{
identifier = "char1:123456",
name = "John Doe",
grade = 5,
gradeName = "Leader",
last_seen = "2023-12-24 20:00:00",
permissions = {
groupStash = true,
bossStash = true,
startMission = true,
addMember = true,
removeMember = true,
manageMember = true,
manageGrades = true,
checkBalance = true,
withdrawBalance = true,
depositBalance = true,
viewMembers = true,
purchaseMarket = true,
sellMarket = true,
manageMarket = true,
purchaseUpgrade = true,
purchaseHideout = true,
manageAnnouncements = true
},
isOnline = true
},
{
identifier = "char1:654321",
name = "Jane Smith",
grade = 3,
gradeName = "Officer",
last_seen = "2023-12-24 19:30:00",
permissions = {
groupStash = true,
startMission = true,
addMember = true
},
isOnline = false
}
}
addBalance
Adds balance to an organizations account, please don't use it in unprotected server events - it will be exploited by cheaters, it's up to you to add security precautions when triggering it
exports['cs_crime']:addBalance(orgId, {
amount = 5000,
description = "Fleeca Heist Reward",
metadata = {
source = "manual",
reference = "",
category = "operational",
sender_account = "000000000"
},
description = "No description",
executor = "SYSTEM",
})
removeBalance
Deducts balance from an organizations account - again, please don't use it in unprotected server events - it will be exploited by cheaters, it's up to you to add security precautions when triggering it
exports['cs_crime']:addBalance(orgId, {
amount = 5000,
description = "Weapon Purchase",
metadata = {
source = "manual",
reference = "",
category = "operational",
sender_account = "000000000"
},
description = "No description",
executor = "SYSTEM",
})
addNewMission
Adds a new active mission to an organization
-- Basic mission
local result = exports['cs_crime']:addNewMission(orgId, source, {
name = "Bank Heist", -- Mission name
duration = 3600, -- Duration in seconds (1 hour)
reward = 50000 -- Mission reward
})
-- Advanced mission with custom participants
local result = exports['cs_crime']:addNewMission(orgId, source, {
name = "Complex Heist",
duration = 7200,
reward = 100000,
participants = { -- Optional: specify participants, if not specified will take all nearby organization members as participants of the mission, the player that started the mission will be set as a leader of the mission
{
name = "John Doe",
identifier = "char1:123456",
role = "leader"
},
{
name = "Jane Smith",
identifier = "char1:654321",
role = "member"
}
}
})
if result.success then
print(('Mission added with ID: %s'):format(result.missionId))
-- Success response structure:
-- {
-- success = true,
-- missionId = 1
-- }
else
print(('Failed to add mission: %s'):format(result.error))
-- Error response structure:
-- {
-- success = false,
-- error = "Error message"
-- }
end
cancelMission
Cancels a specified mission by mission id
local result = exports['cs_crime']:cancelMission(orgId, missionId)
if result.success then
print('Mission cancelled successfully')
else
print(result.error)
end
completeMission
Sets the mission as completed, selected by mission id, runs the function from /server/editable.lua called onMissionComplete, feel free to change the logic if you need to. On completion it moves an active mission to completed missions and adds balance to the organizations account (adds the mission.reward amount)
local result = exports['cs_crime']:completeMission(orgId, missionId)
if result.success then
print('Mission completed successfully')
else
print(('Failed to complete mission: %s'):format(result.error))
end
getActiveMissions
Lists all active missions of an organization by organization id
local result = exports['cs_crime']:getActiveMissions(orgId)
if result.success then
-- result.data =
-- {
-- success = true,
-- data = {
-- {
-- id = 1,
-- name = "Bank Heist",
-- duration = 3600,
-- endTime = 1703425200,
-- timeLeft = 1800,
-- status = "incomplete",
-- reward = 50000,
-- participants = {
-- {
-- name = "John Doe",
-- gradeName = "Leader",
-- role = "leader"
-- }
-- }
-- }
-- }
-- }
for _, mission in ipairs(result.data) do
print(('Active mission: %s (Time left: %d seconds)'):format(
mission.name,
mission.timeLeft
))
end
else
print(('Error: %s'):format(result.error))
end
notify
Returns notification logic defined in /server/editable.lua
notify = function(source, data)
-- You can implement your own notification system here
-- Default implementation using ox_lib
TriggerClientEvent('ox_lib:notify', source, {
title = data.title,
description = data.description,
type = data.type or 'info',
duration = data.duration or 5000,
position = data.position or 'top',
style = data.style or {}
})
end
exports['cs_crime']:notify(source, {
title = "test",
description = "test",
type = "success",
duration = 5000,
position = "top",
style = {}
})
Suggested security precautions
When triggering addBalance/removeBalance add comprehensive serverside checks, if you have problems with securing your events open a ticket and explain your implementation, we will help with securing your missions from cheaters
Last updated