mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 17:28:53 +00:00
Indent cleanup
This commit is contained in:
@@ -1138,7 +1138,7 @@ ESX.ShowInventory = function()
|
||||
local players = ESX.Game.GetPlayersInArea(GetEntityCoords(playerPed), 3.0)
|
||||
local foundPlayers = false
|
||||
local elements = {}
|
||||
|
||||
|
||||
for i=1, #players, 1 do
|
||||
if players[i] ~= PlayerId() then
|
||||
foundPlayers = true
|
||||
@@ -1168,7 +1168,7 @@ ESX.ShowInventory = function()
|
||||
|
||||
for i=1, #players, 1 do
|
||||
if players[i] ~= PlayerId() then
|
||||
|
||||
|
||||
if players[i] == data2.current.player then
|
||||
foundPlayers = true
|
||||
nearbyPlayer = players[i]
|
||||
@@ -1347,20 +1347,16 @@ end)
|
||||
-- SetTimeout
|
||||
Citizen.CreateThread(function()
|
||||
while true do
|
||||
|
||||
Citizen.Wait(0)
|
||||
local currTime = GetGameTimer()
|
||||
|
||||
for i=1, #ESX.TimeoutCallbacks, 1 do
|
||||
|
||||
if ESX.TimeoutCallbacks[i] ~= nil then
|
||||
if ESX.TimeoutCallbacks[i] then
|
||||
if currTime >= ESX.TimeoutCallbacks[i].time then
|
||||
ESX.TimeoutCallbacks[i].cb()
|
||||
ESX.TimeoutCallbacks[i] = nil
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end)
|
||||
|
||||
+2
-11
@@ -37,14 +37,12 @@ ESX.TriggerServerCallback = function(name, requestId, source, cb, ...)
|
||||
end
|
||||
|
||||
ESX.SavePlayer = function(xPlayer, cb)
|
||||
local asyncTasks = {}
|
||||
local asyncTasks = {}
|
||||
xPlayer.setLastPosition(xPlayer.getCoords())
|
||||
|
||||
-- User accounts
|
||||
for i=1, #xPlayer.accounts, 1 do
|
||||
|
||||
if ESX.LastPlayerData[xPlayer.source].accounts[xPlayer.accounts[i].name] ~= xPlayer.accounts[i].money then
|
||||
|
||||
table.insert(asyncTasks, function(cb)
|
||||
MySQL.Async.execute('UPDATE user_accounts SET `money` = @money WHERE identifier = @identifier AND name = @name', {
|
||||
['@money'] = xPlayer.accounts[i].money,
|
||||
@@ -56,16 +54,12 @@ ESX.SavePlayer = function(xPlayer, cb)
|
||||
end)
|
||||
|
||||
ESX.LastPlayerData[xPlayer.source].accounts[xPlayer.accounts[i].name] = xPlayer.accounts[i].money
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- Inventory items
|
||||
for i=1, #xPlayer.inventory, 1 do
|
||||
|
||||
if ESX.LastPlayerData[xPlayer.source].items[xPlayer.inventory[i].name] ~= xPlayer.inventory[i].count then
|
||||
|
||||
table.insert(asyncTasks, function(cb)
|
||||
MySQL.Async.execute('UPDATE user_inventory SET `count` = @count WHERE identifier = @identifier AND item = @item', {
|
||||
['@count'] = xPlayer.inventory[i].count,
|
||||
@@ -77,9 +71,7 @@ ESX.SavePlayer = function(xPlayer, cb)
|
||||
end)
|
||||
|
||||
ESX.LastPlayerData[xPlayer.source].items[xPlayer.inventory[i].name] = xPlayer.inventory[i].count
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- Job, loadout and position
|
||||
@@ -96,13 +88,12 @@ ESX.SavePlayer = function(xPlayer, cb)
|
||||
end)
|
||||
|
||||
Async.parallel(asyncTasks, function(results)
|
||||
RconPrint('[SAVED] ' .. xPlayer.name .. "\n")
|
||||
RconPrint('[SAVED] ' .. xPlayer.name .. "^7\n")
|
||||
|
||||
if cb ~= nil then
|
||||
cb()
|
||||
end
|
||||
end)
|
||||
|
||||
end
|
||||
|
||||
ESX.SavePlayers = function(cb)
|
||||
|
||||
+2
-26
@@ -12,7 +12,6 @@ AddEventHandler('es:playerLoaded', function(source, _player)
|
||||
}
|
||||
|
||||
TriggerEvent('es:getPlayerFromId', _source, function(player)
|
||||
|
||||
-- Update user name in DB
|
||||
table.insert(tasks, function(cb)
|
||||
MySQL.Async.execute('UPDATE `users` SET `name` = @name WHERE `identifier` = @identifier', {
|
||||
@@ -78,7 +77,6 @@ AddEventHandler('es:playerLoaded', function(source, _player)
|
||||
end
|
||||
|
||||
if not found then
|
||||
|
||||
table.insert(userData.inventory, {
|
||||
name = k,
|
||||
count = 0,
|
||||
@@ -90,7 +88,6 @@ AddEventHandler('es:playerLoaded', function(source, _player)
|
||||
})
|
||||
|
||||
local scope = function(item, identifier)
|
||||
|
||||
table.insert(tasks2, function(cb2)
|
||||
MySQL.Async.execute('INSERT INTO user_inventory (identifier, item, count) VALUES (@identifier, @item, @count)', {
|
||||
['@identifier'] = identifier,
|
||||
@@ -100,11 +97,9 @@ AddEventHandler('es:playerLoaded', function(source, _player)
|
||||
cb2()
|
||||
end)
|
||||
end)
|
||||
|
||||
end
|
||||
|
||||
scope(k, player.getIdentifier())
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
@@ -204,11 +199,9 @@ AddEventHandler('es:playerLoaded', function(source, _player)
|
||||
|
||||
-- Run Tasks
|
||||
Async.parallel(tasks, function(results)
|
||||
|
||||
local xPlayer = CreateExtendedPlayer(player, userData.accounts, userData.inventory, userData.job, userData.loadout, userData.playerName, userData.lastPosition)
|
||||
|
||||
xPlayer.getMissingAccounts(function(missingAccounts)
|
||||
|
||||
if #missingAccounts > 0 then
|
||||
|
||||
for i=1, #missingAccounts, 1 do
|
||||
@@ -237,24 +230,21 @@ AddEventHandler('es:playerLoaded', function(source, _player)
|
||||
})
|
||||
|
||||
xPlayer.displayMoney(xPlayer.getMoney())
|
||||
|
||||
end)
|
||||
|
||||
end)
|
||||
|
||||
end)
|
||||
|
||||
end)
|
||||
|
||||
AddEventHandler('playerDropped', function(reason)
|
||||
local _source = source
|
||||
local xPlayer = ESX.GetPlayerFromId(_source)
|
||||
|
||||
if xPlayer ~= nil then
|
||||
if xPlayer then
|
||||
TriggerEvent('esx:playerDropped', _source, reason)
|
||||
|
||||
ESX.SavePlayer(xPlayer, function()
|
||||
ESX.Players[_source] = nil
|
||||
ESX.Players[_source] = nil
|
||||
ESX.LastPlayerData[_source] = nil
|
||||
end)
|
||||
end
|
||||
@@ -303,13 +293,11 @@ AddEventHandler('esx:giveInventoryItem', function(target, type, itemName, itemCo
|
||||
elseif type == 'item_money' then
|
||||
|
||||
if itemCount > 0 and sourceXPlayer.getMoney() >= itemCount then
|
||||
|
||||
sourceXPlayer.removeMoney(itemCount)
|
||||
targetXPlayer.addMoney (itemCount)
|
||||
|
||||
TriggerClientEvent('esx:showNotification', _source, _U('gave_money', ESX.Math.GroupDigits(itemCount), targetXPlayer.name))
|
||||
TriggerClientEvent('esx:showNotification', target, _U('received_money', ESX.Math.GroupDigits(itemCount), sourceXPlayer.name))
|
||||
|
||||
else
|
||||
TriggerClientEvent('esx:showNotification', _source, _U('imp_invalid_amount'))
|
||||
end
|
||||
@@ -317,13 +305,11 @@ AddEventHandler('esx:giveInventoryItem', function(target, type, itemName, itemCo
|
||||
elseif type == 'item_account' then
|
||||
|
||||
if itemCount > 0 and sourceXPlayer.getAccount(itemName).money >= itemCount then
|
||||
|
||||
sourceXPlayer.removeAccountMoney(itemName, itemCount)
|
||||
targetXPlayer.addAccountMoney (itemName, itemCount)
|
||||
|
||||
TriggerClientEvent('esx:showNotification', _source, _U('gave_account_money', ESX.Math.GroupDigits(itemCount), Config.AccountLabels[itemName], targetXPlayer.name))
|
||||
TriggerClientEvent('esx:showNotification', target, _U('received_account_money', ESX.Math.GroupDigits(itemCount), Config.AccountLabels[itemName], sourceXPlayer.name))
|
||||
|
||||
else
|
||||
TriggerClientEvent('esx:showNotification', _source, _U('imp_invalid_amount'))
|
||||
end
|
||||
@@ -331,7 +317,6 @@ AddEventHandler('esx:giveInventoryItem', function(target, type, itemName, itemCo
|
||||
elseif type == 'item_weapon' then
|
||||
|
||||
if not targetXPlayer.hasWeapon(itemName) then
|
||||
|
||||
sourceXPlayer.removeWeapon(itemName)
|
||||
targetXPlayer.addWeapon(itemName, itemCount)
|
||||
|
||||
@@ -344,14 +329,12 @@ AddEventHandler('esx:giveInventoryItem', function(target, type, itemName, itemCo
|
||||
TriggerClientEvent('esx:showNotification', _source, _U('gave_weapon', weaponLabel, targetXPlayer.name))
|
||||
TriggerClientEvent('esx:showNotification', target, _U('received_weapon', weaponLabel, sourceXPlayer.name))
|
||||
end
|
||||
|
||||
else
|
||||
TriggerClientEvent('esx:showNotification', _source, _U('gave_weapon_hasalready', targetXPlayer.name, weaponLabel))
|
||||
TriggerClientEvent('esx:showNotification', _source, _U('received_weapon_hasalready', sourceXPlayer.name, weaponLabel))
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end)
|
||||
|
||||
RegisterServerEvent('esx:removeInventoryItem')
|
||||
@@ -363,7 +346,6 @@ AddEventHandler('esx:removeInventoryItem', function(type, itemName, itemCount)
|
||||
if itemCount == nil or itemCount < 1 then
|
||||
TriggerClientEvent('esx:showNotification', _source, _U('imp_invalid_quantity'))
|
||||
else
|
||||
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
local xItem = xPlayer.getInventoryItem(itemName)
|
||||
|
||||
@@ -376,7 +358,6 @@ AddEventHandler('esx:removeInventoryItem', function(type, itemName, itemCount)
|
||||
ESX.CreatePickup('item_standard', itemName, itemCount, pickupLabel, _source)
|
||||
TriggerClientEvent('esx:showNotification', _source, _U('threw_standard', itemCount, xItem.label))
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
elseif type == 'item_money' then
|
||||
@@ -384,7 +365,6 @@ AddEventHandler('esx:removeInventoryItem', function(type, itemName, itemCount)
|
||||
if itemCount == nil or itemCount < 1 then
|
||||
TriggerClientEvent('esx:showNotification', _source, _U('imp_invalid_amount'))
|
||||
else
|
||||
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
local playerCash = xPlayer.getMoney()
|
||||
|
||||
@@ -397,7 +377,6 @@ AddEventHandler('esx:removeInventoryItem', function(type, itemName, itemCount)
|
||||
ESX.CreatePickup('item_money', 'money', itemCount, pickupLabel, _source)
|
||||
TriggerClientEvent('esx:showNotification', _source, _U('threw_money', ESX.Math.GroupDigits(itemCount)))
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
elseif type == 'item_account' then
|
||||
@@ -405,7 +384,6 @@ AddEventHandler('esx:removeInventoryItem', function(type, itemName, itemCount)
|
||||
if itemCount == nil or itemCount < 1 then
|
||||
TriggerClientEvent('esx:showNotification', _source, _U('imp_invalid_amount'))
|
||||
else
|
||||
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
local account = xPlayer.getAccount(itemName)
|
||||
|
||||
@@ -418,7 +396,6 @@ AddEventHandler('esx:removeInventoryItem', function(type, itemName, itemCount)
|
||||
ESX.CreatePickup('item_account', itemName, itemCount, pickupLabel, _source)
|
||||
TriggerClientEvent('esx:showNotification', _source, _U('threw_account', ESX.Math.GroupDigits(itemCount), string.lower(account.label)))
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
elseif type == 'item_weapon' then
|
||||
@@ -449,7 +426,6 @@ AddEventHandler('esx:removeInventoryItem', function(type, itemName, itemCount)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end)
|
||||
|
||||
RegisterServerEvent('esx:useItem')
|
||||
|
||||
Reference in New Issue
Block a user