forked from boermansjo/HUD-GTAVRP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.lua
22 lines (21 loc) · 978 Bytes
/
server.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
-- Save hunger and thirst to database
RegisterServerEvent("saveHungerThirst")
AddEventHandler("saveHungerThirst", function(hunger, thirst)
TriggerEvent('es:getPlayerFromId', source, function(user)
local player = user.getIdentifier()
MySQL.Async.execute("UPDATE hungerthirst SET hunger=@hunger, thirst=@thirst WHERE idSteam=@identifier", {['@identifier'] = player, ['@hunger'] = hunger, ['@thirst'] = thirst})
end)
end)
-- Get hunger and thirst from database at spawn
RegisterServerEvent("getPlayerHungerThirst")
AddEventHandler("getPlayerHungerThirst", function()
TriggerEvent('es:getPlayerFromId', source, function(user)
local _source = source
local player = user.getIdentifier()
MySQL.Async.fetchAll('SELECT hunger, thirst FROM hungerthirst WHERE idSteam=@identifier', {['@identifier'] = player}, function(result)
if(result)then
TriggerClientEvent("PlayerHungerThirst", _source, result)
end
end)
end)
end)