mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-09-04 08:13:21 +00:00
Use new esx_status
This commit is contained in:
+25
-1
@@ -8,10 +8,16 @@ Citizen.CreateThread(function()
|
||||
end
|
||||
end)
|
||||
|
||||
AddEventHandler('esx_basicneeds:resetStatus', function()
|
||||
TriggerEvent('esx_status:set', 'hunger', 500000)
|
||||
TriggerEvent('esx_status:set', 'thirst', 500000)
|
||||
|
||||
end)
|
||||
|
||||
AddEventHandler('playerSpawned', function()
|
||||
|
||||
if IsDead then
|
||||
TriggerServerEvent('esx_basicneeds:resetStatus')
|
||||
TriggerEvent('esx_basicneeds:resetStatus')
|
||||
end
|
||||
|
||||
IsDead = false
|
||||
@@ -19,6 +25,24 @@ end)
|
||||
|
||||
AddEventHandler('esx_status:loaded', function(status)
|
||||
|
||||
TriggerEvent('esx_status:registerStatus', 'hunger', 1000000, '#CFAD0F',
|
||||
function(status)
|
||||
return true
|
||||
end,
|
||||
function(status)
|
||||
status.remove(200)
|
||||
end
|
||||
)
|
||||
|
||||
TriggerEvent('esx_status:registerStatus', 'thirst', 1000000, '#0C98F1',
|
||||
function(status)
|
||||
return true
|
||||
end,
|
||||
function(status)
|
||||
status.remove(250)
|
||||
end
|
||||
)
|
||||
|
||||
Citizen.CreateThread(function()
|
||||
|
||||
while true do
|
||||
|
||||
+8
-59
@@ -2,77 +2,26 @@ ESX = nil
|
||||
|
||||
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
|
||||
|
||||
TriggerEvent('esx_status:registerStatus', 'hunger', 1000000, '#CFAD0F',
|
||||
function(status)
|
||||
return true
|
||||
end,
|
||||
function(status)
|
||||
status.remove(6000)
|
||||
end,
|
||||
{remove = 6000}
|
||||
)
|
||||
|
||||
TriggerEvent('esx_status:registerStatus', 'thirst', 1000000, '#0C98F1',
|
||||
function(status)
|
||||
return true
|
||||
end,
|
||||
function(status)
|
||||
status.remove(7500)
|
||||
end,
|
||||
{remove = 7500}
|
||||
)
|
||||
|
||||
RegisterServerEvent('esx_basicneeds:resetStatus')
|
||||
AddEventHandler('esx_basicneeds:resetStatus', function()
|
||||
|
||||
local _source = source
|
||||
|
||||
TriggerEvent('esx_status:getStatus', _source, 'hunger', function(status)
|
||||
status.set(500000)
|
||||
status.updateClient()
|
||||
end)
|
||||
|
||||
TriggerEvent('esx_status:getStatus', _source, 'thirst', function(status)
|
||||
status.set(500000)
|
||||
status.updateClient()
|
||||
end)
|
||||
|
||||
end)
|
||||
|
||||
ESX.RegisterUsableItem('bread', function(source)
|
||||
|
||||
local _source = source
|
||||
local xPlayer = ESX.GetPlayerFromId(_source)
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
|
||||
xPlayer.removeInventoryItem('bread', 1)
|
||||
|
||||
TriggerEvent('esx_status:getStatus', _source, 'hunger', function(status)
|
||||
|
||||
status.add(200000)
|
||||
status.updateClient()
|
||||
|
||||
TriggerClientEvent('esx_basicneeds:onEat', _source)
|
||||
TriggerClientEvent('esx:showNotification', _source, _U('used_bread'))
|
||||
|
||||
end)
|
||||
TriggerClientEvent('esx_status:add', source, 'hunger', 200000)
|
||||
TriggerClientEvent('esx_basicneeds:onEat', source)
|
||||
TriggerClientEvent('esx:showNotification', source, _U('used_bread'))
|
||||
|
||||
end)
|
||||
|
||||
ESX.RegisterUsableItem('water', function(source)
|
||||
|
||||
local _source = source
|
||||
local xPlayer = ESX.GetPlayerFromId(_source)
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
|
||||
xPlayer.removeInventoryItem('water', 1)
|
||||
|
||||
TriggerEvent('esx_status:getStatus', _source, 'thirst', function(status)
|
||||
|
||||
status.add(200000)
|
||||
status.updateClient()
|
||||
|
||||
TriggerClientEvent('esx_basicneeds:onDrink', _source)
|
||||
TriggerClientEvent('esx:showNotification', _source, _U('used_water'))
|
||||
|
||||
end)
|
||||
TriggerClientEvent('esx_status:add', source, 'thirst', 200000)
|
||||
TriggerClientEvent('esx_basicneeds:onDrink', source)
|
||||
TriggerClientEvent('esx:showNotification', source, _U('used_water'))
|
||||
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user