mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-30 22:01:37 +00:00
UseItem fixes + add paycheck
This commit is contained in:
@@ -1003,12 +1003,11 @@ ESX.ShowInventory = function()
|
||||
|
||||
TriggerServerEvent('esx:useItem', data.current.value)
|
||||
|
||||
menu2.close()
|
||||
menu.close()
|
||||
|
||||
elseif data.current.action == 'return' then
|
||||
|
||||
ESX.UI.Menu.CloseAll()
|
||||
ESX.ShowInventory()
|
||||
|
||||
end
|
||||
|
||||
end,
|
||||
|
||||
@@ -158,6 +158,29 @@ ESX.StartDBSync = function()
|
||||
|
||||
end
|
||||
|
||||
ESX.StartPayCheck = function()
|
||||
|
||||
function payCheck()
|
||||
|
||||
local xPlayers = ESX.GetPlayers()
|
||||
|
||||
for k,v in pairs(xPlayers) do
|
||||
|
||||
if v.job.grade_salary > 0 then
|
||||
v.addMoney(v.job.grade_salary)
|
||||
TriggerClientEvent('esx:showNotification', v.source, 'Vous avez reçu votre salaire : ~g~$' .. v.job.grade_salary)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
SetTimeout(Config.PaycheckInterval, payCheck)
|
||||
|
||||
end
|
||||
|
||||
SetTimeout(Config.PaycheckInterval, payCheck)
|
||||
|
||||
end
|
||||
|
||||
ESX.GetPlayers = function()
|
||||
return ESX.Players
|
||||
end
|
||||
|
||||
@@ -510,8 +510,17 @@ AddEventHandler('esx:removeInventoryItem', function(type, itemName, itemCount)
|
||||
end)
|
||||
|
||||
RegisterServerEvent('esx:useItem')
|
||||
AddEventHandler('esx:useItem', function(item)
|
||||
ESX.UseItem(source, item)
|
||||
AddEventHandler('esx:useItem', function(itemName)
|
||||
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
local count = xPlayer.getInventoryItem(itemName).count
|
||||
|
||||
if count > 0 then
|
||||
ESX.UseItem(source, itemName)
|
||||
else
|
||||
TriggerClientEvent('esx:showNotification', xPlayer.source, 'Action impossible')
|
||||
end
|
||||
|
||||
end)
|
||||
|
||||
ESX.RegisterServerCallback('esx:getPlayerData', function(source, cb)
|
||||
@@ -547,3 +556,4 @@ end)
|
||||
TriggerEvent("es:addGroup", "jobmaster", "user", function(group) end)
|
||||
|
||||
ESX.StartDBSync()
|
||||
ESX.StartPayCheck()
|
||||
Reference in New Issue
Block a user