mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-31 23:01:36 +00:00
chore(coding-style): correct indentation
This commit is contained in:
+286
-286
@@ -3,7 +3,7 @@ ESX = nil
|
||||
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
|
||||
|
||||
if Config.MaxInService ~= -1 then
|
||||
TriggerEvent('esx_service:activateService', 'police', Config.MaxInService)
|
||||
TriggerEvent('esx_service:activateService', 'police', Config.MaxInService)
|
||||
end
|
||||
|
||||
TriggerEvent('esx_phone:registerNumber', 'police', _U('alert_police'), true, true)
|
||||
@@ -11,64 +11,64 @@ TriggerEvent('esx_society:registerSociety', 'police', 'Police', 'society_police'
|
||||
|
||||
RegisterServerEvent('esx_policejob:giveWeapon')
|
||||
AddEventHandler('esx_policejob:giveWeapon', function(weapon, ammo)
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
xPlayer.addWeapon(weapon, ammo)
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
xPlayer.addWeapon(weapon, ammo)
|
||||
end)
|
||||
|
||||
RegisterServerEvent('esx_policejob:confiscatePlayerItem')
|
||||
AddEventHandler('esx_policejob:confiscatePlayerItem', function(target, itemType, itemName, amount)
|
||||
|
||||
local sourceXPlayer = ESX.GetPlayerFromId(source)
|
||||
local targetXPlayer = ESX.GetPlayerFromId(target)
|
||||
|
||||
if itemType == 'item_standard' then
|
||||
local sourceXPlayer = ESX.GetPlayerFromId(source)
|
||||
local targetXPlayer = ESX.GetPlayerFromId(target)
|
||||
|
||||
local label = sourceXPlayer.getInventoryItem(itemName).label
|
||||
if itemType == 'item_standard' then
|
||||
|
||||
targetXPlayer.removeInventoryItem(itemName, amount)
|
||||
sourceXPlayer.addInventoryItem(itemName, amount)
|
||||
local label = sourceXPlayer.getInventoryItem(itemName).label
|
||||
|
||||
TriggerClientEvent('esx:showNotification', sourceXPlayer.source, _U('you_have_confinv') .. amount .. ' ' .. label .. _U('from') .. targetXPlayer.name)
|
||||
TriggerClientEvent('esx:showNotification', targetXPlayer.source, '~b~' .. targetXPlayer.name .. _U('confinv') .. amount .. ' ' .. label )
|
||||
targetXPlayer.removeInventoryItem(itemName, amount)
|
||||
sourceXPlayer.addInventoryItem(itemName, amount)
|
||||
|
||||
end
|
||||
TriggerClientEvent('esx:showNotification', sourceXPlayer.source, _U('you_have_confinv') .. amount .. ' ' .. label .. _U('from') .. targetXPlayer.name)
|
||||
TriggerClientEvent('esx:showNotification', targetXPlayer.source, '~b~' .. targetXPlayer.name .. _U('confinv') .. amount .. ' ' .. label )
|
||||
|
||||
if itemType == 'item_account' then
|
||||
end
|
||||
|
||||
targetXPlayer.removeAccountMoney(itemName, amount)
|
||||
sourceXPlayer.addAccountMoney(itemName, amount)
|
||||
if itemType == 'item_account' then
|
||||
|
||||
TriggerClientEvent('esx:showNotification', sourceXPlayer.source, _U('you_have_confdm') .. amount .. _U('from') .. targetXPlayer.name)
|
||||
TriggerClientEvent('esx:showNotification', targetXPlayer.source, '~b~' .. targetXPlayer.name .. _U('confdm') .. amount)
|
||||
targetXPlayer.removeAccountMoney(itemName, amount)
|
||||
sourceXPlayer.addAccountMoney(itemName, amount)
|
||||
|
||||
end
|
||||
TriggerClientEvent('esx:showNotification', sourceXPlayer.source, _U('you_have_confdm') .. amount .. _U('from') .. targetXPlayer.name)
|
||||
TriggerClientEvent('esx:showNotification', targetXPlayer.source, '~b~' .. targetXPlayer.name .. _U('confdm') .. amount)
|
||||
|
||||
if itemType == 'item_weapon' then
|
||||
end
|
||||
|
||||
targetXPlayer.removeWeapon(itemName)
|
||||
sourceXPlayer.addWeapon(itemName, amount)
|
||||
if itemType == 'item_weapon' then
|
||||
|
||||
TriggerClientEvent('esx:showNotification', sourceXPlayer.source, _U('you_have_confweapon') .. ESX.GetWeaponLabel(itemName) .. _U('from') .. targetXPlayer.name)
|
||||
TriggerClientEvent('esx:showNotification', targetXPlayer.source, '~b~' .. targetXPlayer.name .. _U('confweapon') .. ESX.GetWeaponLabel(itemName))
|
||||
targetXPlayer.removeWeapon(itemName)
|
||||
sourceXPlayer.addWeapon(itemName, amount)
|
||||
|
||||
end
|
||||
TriggerClientEvent('esx:showNotification', sourceXPlayer.source, _U('you_have_confweapon') .. ESX.GetWeaponLabel(itemName) .. _U('from') .. targetXPlayer.name)
|
||||
TriggerClientEvent('esx:showNotification', targetXPlayer.source, '~b~' .. targetXPlayer.name .. _U('confweapon') .. ESX.GetWeaponLabel(itemName))
|
||||
|
||||
end
|
||||
|
||||
end)
|
||||
|
||||
RegisterServerEvent('esx_policejob:handcuff')
|
||||
AddEventHandler('esx_policejob:handcuff', function(target)
|
||||
TriggerClientEvent('esx_policejob:handcuff', target)
|
||||
TriggerClientEvent('esx_policejob:handcuff', target)
|
||||
end)
|
||||
|
||||
RegisterServerEvent('esx_policejob:drag')
|
||||
AddEventHandler('esx_policejob:drag', function(target)
|
||||
local _source = source
|
||||
TriggerClientEvent('esx_policejob:drag', target, _source)
|
||||
local _source = source
|
||||
TriggerClientEvent('esx_policejob:drag', target, _source)
|
||||
end)
|
||||
|
||||
RegisterServerEvent('esx_policejob:putInVehicle')
|
||||
AddEventHandler('esx_policejob:putInVehicle', function(target)
|
||||
TriggerClientEvent('esx_policejob:putInVehicle', target)
|
||||
TriggerClientEvent('esx_policejob:putInVehicle', target)
|
||||
end)
|
||||
|
||||
RegisterServerEvent('esx_policejob:OutVehicle')
|
||||
@@ -79,380 +79,380 @@ end)
|
||||
RegisterServerEvent('esx_policejob:getStockItem')
|
||||
AddEventHandler('esx_policejob:getStockItem', function(itemName, count)
|
||||
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
|
||||
TriggerEvent('esx_addoninventory:getSharedInventory', 'society_police', function(inventory)
|
||||
TriggerEvent('esx_addoninventory:getSharedInventory', 'society_police', function(inventory)
|
||||
|
||||
local item = inventory.getItem(itemName)
|
||||
local item = inventory.getItem(itemName)
|
||||
|
||||
if item.count >= count then
|
||||
inventory.removeItem(itemName, count)
|
||||
xPlayer.addInventoryItem(itemName, count)
|
||||
else
|
||||
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('quantity_invalid'))
|
||||
end
|
||||
if item.count >= count then
|
||||
inventory.removeItem(itemName, count)
|
||||
xPlayer.addInventoryItem(itemName, count)
|
||||
else
|
||||
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('quantity_invalid'))
|
||||
end
|
||||
|
||||
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('have_withdrawn') .. count .. ' ' .. item.label)
|
||||
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('have_withdrawn') .. count .. ' ' .. item.label)
|
||||
|
||||
end)
|
||||
end)
|
||||
|
||||
end)
|
||||
|
||||
RegisterServerEvent('esx_policejob:putStockItems')
|
||||
AddEventHandler('esx_policejob:putStockItems', function(itemName, count)
|
||||
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
|
||||
TriggerEvent('esx_addoninventory:getSharedInventory', 'society_police', function(inventory)
|
||||
TriggerEvent('esx_addoninventory:getSharedInventory', 'society_police', function(inventory)
|
||||
|
||||
local item = inventory.getItem(itemName)
|
||||
local item = inventory.getItem(itemName)
|
||||
|
||||
if item.count >= 0 then
|
||||
xPlayer.removeInventoryItem(itemName, count)
|
||||
inventory.addItem(itemName, count)
|
||||
else
|
||||
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('quantity_invalid'))
|
||||
end
|
||||
if item.count >= 0 then
|
||||
xPlayer.removeInventoryItem(itemName, count)
|
||||
inventory.addItem(itemName, count)
|
||||
else
|
||||
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('quantity_invalid'))
|
||||
end
|
||||
|
||||
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('added') .. count .. ' ' .. item.label)
|
||||
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('added') .. count .. ' ' .. item.label)
|
||||
|
||||
end)
|
||||
end)
|
||||
|
||||
end)
|
||||
|
||||
ESX.RegisterServerCallback('esx_policejob:getOtherPlayerData', function(source, cb, target)
|
||||
|
||||
if Config.EnableESXIdentity then
|
||||
|
||||
local xPlayer = ESX.GetPlayerFromId(target)
|
||||
|
||||
local identifier = GetPlayerIdentifiers(target)[1]
|
||||
|
||||
local result = MySQL.Sync.fetchAll("SELECT * FROM characters WHERE identifier = @identifier", {
|
||||
['@identifier'] = identifier
|
||||
})
|
||||
|
||||
local user = result[1]
|
||||
local firstname = user['firstname']
|
||||
local lastname = user['lastname']
|
||||
local sex = user['sex']
|
||||
local dob = user['dateofbirth']
|
||||
local heightInit = user['height']
|
||||
local heightFeet = tonumber(string.format("%.0f",heightInit / 12, 0))
|
||||
local heightInches = tonumber(string.format("%.0f",heightInit % 12, 0))
|
||||
local height = heightFeet .. "\' " .. heightInches .. "\""
|
||||
|
||||
local data = {
|
||||
name = GetPlayerName(target),
|
||||
job = xPlayer.job,
|
||||
inventory = xPlayer.inventory,
|
||||
accounts = xPlayer.accounts,
|
||||
weapons = xPlayer.loadout,
|
||||
firstname = firstname,
|
||||
lastname = lastname,
|
||||
sex = sex,
|
||||
dob = dob,
|
||||
height = height
|
||||
}
|
||||
|
||||
TriggerEvent('esx_status:getStatus', source, 'drunk', function(status)
|
||||
if Config.EnableESXIdentity then
|
||||
|
||||
if status ~= nil then
|
||||
data.drunk = math.floor(status.percent)
|
||||
end
|
||||
|
||||
end)
|
||||
local xPlayer = ESX.GetPlayerFromId(target)
|
||||
|
||||
if Config.EnableLicenses then
|
||||
local identifier = GetPlayerIdentifiers(target)[1]
|
||||
|
||||
TriggerEvent('esx_license:getLicenses', source, function(licenses)
|
||||
data.licenses = licenses
|
||||
cb(data)
|
||||
end)
|
||||
local result = MySQL.Sync.fetchAll("SELECT * FROM characters WHERE identifier = @identifier", {
|
||||
['@identifier'] = identifier
|
||||
})
|
||||
|
||||
else
|
||||
cb(data)
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
local xPlayer = ESX.GetPlayerFromId(target)
|
||||
local user = result[1]
|
||||
local firstname = user['firstname']
|
||||
local lastname = user['lastname']
|
||||
local sex = user['sex']
|
||||
local dob = user['dateofbirth']
|
||||
local heightInit = user['height']
|
||||
local heightFeet = tonumber(string.format("%.0f",heightInit / 12, 0))
|
||||
local heightInches = tonumber(string.format("%.0f",heightInit % 12, 0))
|
||||
local height = heightFeet .. "\' " .. heightInches .. "\""
|
||||
|
||||
local data = {
|
||||
name = GetPlayerName(target),
|
||||
job = xPlayer.job,
|
||||
inventory = xPlayer.inventory,
|
||||
accounts = xPlayer.accounts,
|
||||
weapons = xPlayer.loadout
|
||||
}
|
||||
|
||||
TriggerEvent('esx_status:getStatus', _source, 'drunk', function(status)
|
||||
local data = {
|
||||
name = GetPlayerName(target),
|
||||
job = xPlayer.job,
|
||||
inventory = xPlayer.inventory,
|
||||
accounts = xPlayer.accounts,
|
||||
weapons = xPlayer.loadout,
|
||||
firstname = firstname,
|
||||
lastname = lastname,
|
||||
sex = sex,
|
||||
dob = dob,
|
||||
height = height
|
||||
}
|
||||
|
||||
if status ~= nil then
|
||||
data.drunk = status.getPercent()
|
||||
end
|
||||
|
||||
end)
|
||||
TriggerEvent('esx_status:getStatus', source, 'drunk', function(status)
|
||||
|
||||
TriggerEvent('esx_license:getLicenses', _source, function(licenses)
|
||||
data.licenses = licenses
|
||||
end)
|
||||
if status ~= nil then
|
||||
data.drunk = math.floor(status.percent)
|
||||
end
|
||||
|
||||
cb(data)
|
||||
|
||||
end
|
||||
end)
|
||||
|
||||
if Config.EnableLicenses then
|
||||
|
||||
TriggerEvent('esx_license:getLicenses', source, function(licenses)
|
||||
data.licenses = licenses
|
||||
cb(data)
|
||||
end)
|
||||
|
||||
else
|
||||
cb(data)
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
local xPlayer = ESX.GetPlayerFromId(target)
|
||||
|
||||
local data = {
|
||||
name = GetPlayerName(target),
|
||||
job = xPlayer.job,
|
||||
inventory = xPlayer.inventory,
|
||||
accounts = xPlayer.accounts,
|
||||
weapons = xPlayer.loadout
|
||||
}
|
||||
|
||||
TriggerEvent('esx_status:getStatus', _source, 'drunk', function(status)
|
||||
|
||||
if status ~= nil then
|
||||
data.drunk = status.getPercent()
|
||||
end
|
||||
|
||||
end)
|
||||
|
||||
TriggerEvent('esx_license:getLicenses', _source, function(licenses)
|
||||
data.licenses = licenses
|
||||
end)
|
||||
|
||||
cb(data)
|
||||
|
||||
end
|
||||
|
||||
end)
|
||||
|
||||
ESX.RegisterServerCallback('esx_policejob:getFineList', function(source, cb, category)
|
||||
|
||||
MySQL.Async.fetchAll(
|
||||
'SELECT * FROM fine_types WHERE category = @category',
|
||||
{
|
||||
['@category'] = category
|
||||
},
|
||||
function(fines)
|
||||
cb(fines)
|
||||
end
|
||||
)
|
||||
MySQL.Async.fetchAll(
|
||||
'SELECT * FROM fine_types WHERE category = @category',
|
||||
{
|
||||
['@category'] = category
|
||||
},
|
||||
function(fines)
|
||||
cb(fines)
|
||||
end
|
||||
)
|
||||
|
||||
end)
|
||||
|
||||
ESX.RegisterServerCallback('esx_policejob:getVehicleInfos', function(source, cb, plate)
|
||||
|
||||
if Config.EnableESXIdentity then
|
||||
|
||||
MySQL.Async.fetchAll(
|
||||
'SELECT * FROM owned_vehicles',
|
||||
{},
|
||||
function(result)
|
||||
|
||||
local foundIdentifier = nil
|
||||
if Config.EnableESXIdentity then
|
||||
|
||||
for i=1, #result, 1 do
|
||||
|
||||
local vehicleData = json.decode(result[i].vehicle)
|
||||
MySQL.Async.fetchAll(
|
||||
'SELECT * FROM owned_vehicles',
|
||||
{},
|
||||
function(result)
|
||||
|
||||
if vehicleData.plate == plate then
|
||||
foundIdentifier = result[i].owner
|
||||
break
|
||||
end
|
||||
local foundIdentifier = nil
|
||||
|
||||
end
|
||||
for i=1, #result, 1 do
|
||||
|
||||
if foundIdentifier ~= nil then
|
||||
local vehicleData = json.decode(result[i].vehicle)
|
||||
|
||||
MySQL.Async.fetchAll(
|
||||
'SELECT * FROM characters WHERE identifier = @identifier',
|
||||
{
|
||||
['@identifier'] = foundIdentifier
|
||||
},
|
||||
function(result)
|
||||
|
||||
local ownerName = result[1].firstname .. " " .. result[1].lastname
|
||||
if vehicleData.plate == plate then
|
||||
foundIdentifier = result[i].owner
|
||||
break
|
||||
end
|
||||
|
||||
local infos = {
|
||||
plate = plate,
|
||||
owner = ownerName
|
||||
}
|
||||
end
|
||||
|
||||
cb(infos)
|
||||
if foundIdentifier ~= nil then
|
||||
|
||||
end
|
||||
)
|
||||
|
||||
else
|
||||
MySQL.Async.fetchAll(
|
||||
'SELECT * FROM characters WHERE identifier = @identifier',
|
||||
{
|
||||
['@identifier'] = foundIdentifier
|
||||
},
|
||||
function(result)
|
||||
|
||||
local infos = {
|
||||
plate = plate
|
||||
}
|
||||
local ownerName = result[1].firstname .. " " .. result[1].lastname
|
||||
|
||||
cb(infos)
|
||||
local infos = {
|
||||
plate = plate,
|
||||
owner = ownerName
|
||||
}
|
||||
|
||||
end
|
||||
cb(infos)
|
||||
|
||||
end
|
||||
)
|
||||
|
||||
else
|
||||
|
||||
MySQL.Async.fetchAll(
|
||||
'SELECT * FROM owned_vehicles',
|
||||
{},
|
||||
function(result)
|
||||
|
||||
local foundIdentifier = nil
|
||||
end
|
||||
)
|
||||
|
||||
for i=1, #result, 1 do
|
||||
|
||||
local vehicleData = json.decode(result[i].vehicle)
|
||||
else
|
||||
|
||||
if vehicleData.plate == plate then
|
||||
foundIdentifier = result[i].owner
|
||||
break
|
||||
end
|
||||
local infos = {
|
||||
plate = plate
|
||||
}
|
||||
|
||||
end
|
||||
cb(infos)
|
||||
|
||||
if foundIdentifier ~= nil then
|
||||
end
|
||||
|
||||
MySQL.Async.fetchAll(
|
||||
'SELECT * FROM users WHERE identifier = @identifier',
|
||||
{
|
||||
['@identifier'] = foundIdentifier
|
||||
},
|
||||
function(result)
|
||||
end
|
||||
)
|
||||
|
||||
local infos = {
|
||||
plate = plate,
|
||||
owner = result[1].name
|
||||
}
|
||||
else
|
||||
|
||||
cb(infos)
|
||||
MySQL.Async.fetchAll(
|
||||
'SELECT * FROM owned_vehicles',
|
||||
{},
|
||||
function(result)
|
||||
|
||||
end
|
||||
)
|
||||
|
||||
else
|
||||
local foundIdentifier = nil
|
||||
|
||||
local infos = {
|
||||
plate = plate
|
||||
}
|
||||
for i=1, #result, 1 do
|
||||
|
||||
cb(infos)
|
||||
local vehicleData = json.decode(result[i].vehicle)
|
||||
|
||||
end
|
||||
if vehicleData.plate == plate then
|
||||
foundIdentifier = result[i].owner
|
||||
break
|
||||
end
|
||||
|
||||
end
|
||||
)
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
if foundIdentifier ~= nil then
|
||||
|
||||
MySQL.Async.fetchAll(
|
||||
'SELECT * FROM users WHERE identifier = @identifier',
|
||||
{
|
||||
['@identifier'] = foundIdentifier
|
||||
},
|
||||
function(result)
|
||||
|
||||
local infos = {
|
||||
plate = plate,
|
||||
owner = result[1].name
|
||||
}
|
||||
|
||||
cb(infos)
|
||||
|
||||
end
|
||||
)
|
||||
|
||||
else
|
||||
|
||||
local infos = {
|
||||
plate = plate
|
||||
}
|
||||
|
||||
cb(infos)
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
)
|
||||
|
||||
end
|
||||
|
||||
end)
|
||||
|
||||
ESX.RegisterServerCallback('esx_policejob:getArmoryWeapons', function(source, cb)
|
||||
|
||||
TriggerEvent('esx_datastore:getSharedDataStore', 'society_police', function(store)
|
||||
TriggerEvent('esx_datastore:getSharedDataStore', 'society_police', function(store)
|
||||
|
||||
local weapons = store.get('weapons')
|
||||
local weapons = store.get('weapons')
|
||||
|
||||
if weapons == nil then
|
||||
weapons = {}
|
||||
end
|
||||
if weapons == nil then
|
||||
weapons = {}
|
||||
end
|
||||
|
||||
cb(weapons)
|
||||
cb(weapons)
|
||||
|
||||
end)
|
||||
end)
|
||||
|
||||
end)
|
||||
|
||||
ESX.RegisterServerCallback('esx_policejob:addArmoryWeapon', function(source, cb, weaponName)
|
||||
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
|
||||
xPlayer.removeWeapon(weaponName)
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
|
||||
TriggerEvent('esx_datastore:getSharedDataStore', 'society_police', function(store)
|
||||
xPlayer.removeWeapon(weaponName)
|
||||
|
||||
local weapons = store.get('weapons')
|
||||
TriggerEvent('esx_datastore:getSharedDataStore', 'society_police', function(store)
|
||||
|
||||
if weapons == nil then
|
||||
weapons = {}
|
||||
end
|
||||
local weapons = store.get('weapons')
|
||||
|
||||
local foundWeapon = false
|
||||
if weapons == nil then
|
||||
weapons = {}
|
||||
end
|
||||
|
||||
for i=1, #weapons, 1 do
|
||||
if weapons[i].name == weaponName then
|
||||
weapons[i].count = weapons[i].count + 1
|
||||
foundWeapon = true
|
||||
end
|
||||
end
|
||||
local foundWeapon = false
|
||||
|
||||
if not foundWeapon then
|
||||
table.insert(weapons, {
|
||||
name = weaponName,
|
||||
count = 1
|
||||
})
|
||||
end
|
||||
for i=1, #weapons, 1 do
|
||||
if weapons[i].name == weaponName then
|
||||
weapons[i].count = weapons[i].count + 1
|
||||
foundWeapon = true
|
||||
end
|
||||
end
|
||||
|
||||
store.set('weapons', weapons)
|
||||
if not foundWeapon then
|
||||
table.insert(weapons, {
|
||||
name = weaponName,
|
||||
count = 1
|
||||
})
|
||||
end
|
||||
|
||||
cb()
|
||||
store.set('weapons', weapons)
|
||||
|
||||
end)
|
||||
cb()
|
||||
|
||||
end)
|
||||
|
||||
end)
|
||||
|
||||
ESX.RegisterServerCallback('esx_policejob:removeArmoryWeapon', function(source, cb, weaponName)
|
||||
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
|
||||
xPlayer.addWeapon(weaponName, 1000)
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
|
||||
TriggerEvent('esx_datastore:getSharedDataStore', 'society_police', function(store)
|
||||
xPlayer.addWeapon(weaponName, 1000)
|
||||
|
||||
local weapons = store.get('weapons')
|
||||
TriggerEvent('esx_datastore:getSharedDataStore', 'society_police', function(store)
|
||||
|
||||
if weapons == nil then
|
||||
weapons = {}
|
||||
end
|
||||
local weapons = store.get('weapons')
|
||||
|
||||
local foundWeapon = false
|
||||
if weapons == nil then
|
||||
weapons = {}
|
||||
end
|
||||
|
||||
for i=1, #weapons, 1 do
|
||||
if weapons[i].name == weaponName then
|
||||
weapons[i].count = (weapons[i].count > 0 and weapons[i].count - 1 or 0)
|
||||
foundWeapon = true
|
||||
end
|
||||
end
|
||||
local foundWeapon = false
|
||||
|
||||
if not foundWeapon then
|
||||
table.insert(weapons, {
|
||||
name = weaponName,
|
||||
count = 0
|
||||
})
|
||||
end
|
||||
for i=1, #weapons, 1 do
|
||||
if weapons[i].name == weaponName then
|
||||
weapons[i].count = (weapons[i].count > 0 and weapons[i].count - 1 or 0)
|
||||
foundWeapon = true
|
||||
end
|
||||
end
|
||||
|
||||
store.set('weapons', weapons)
|
||||
if not foundWeapon then
|
||||
table.insert(weapons, {
|
||||
name = weaponName,
|
||||
count = 0
|
||||
})
|
||||
end
|
||||
|
||||
cb()
|
||||
store.set('weapons', weapons)
|
||||
|
||||
end)
|
||||
cb()
|
||||
|
||||
end)
|
||||
|
||||
end)
|
||||
|
||||
|
||||
ESX.RegisterServerCallback('esx_policejob:buy', function(source, cb, amount)
|
||||
|
||||
TriggerEvent('esx_addonaccount:getSharedAccount', 'society_police', function(account)
|
||||
|
||||
if account.money >= amount then
|
||||
account.removeMoney(amount)
|
||||
cb(true)
|
||||
else
|
||||
cb(false)
|
||||
end
|
||||
TriggerEvent('esx_addonaccount:getSharedAccount', 'society_police', function(account)
|
||||
|
||||
end)
|
||||
if account.money >= amount then
|
||||
account.removeMoney(amount)
|
||||
cb(true)
|
||||
else
|
||||
cb(false)
|
||||
end
|
||||
|
||||
end)
|
||||
|
||||
end)
|
||||
|
||||
ESX.RegisterServerCallback('esx_policejob:getStockItems', function(source, cb)
|
||||
|
||||
TriggerEvent('esx_addoninventory:getSharedInventory', 'society_police', function(inventory)
|
||||
cb(inventory.items)
|
||||
end)
|
||||
TriggerEvent('esx_addoninventory:getSharedInventory', 'society_police', function(inventory)
|
||||
cb(inventory.items)
|
||||
end)
|
||||
|
||||
end)
|
||||
|
||||
ESX.RegisterServerCallback('esx_policejob:getPlayerInventory', function(source, cb)
|
||||
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
local items = xPlayer.inventory
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
local items = xPlayer.inventory
|
||||
|
||||
cb({
|
||||
items = items
|
||||
})
|
||||
cb({
|
||||
items = items
|
||||
})
|
||||
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user