Hello, using essentialsmode(mysql) and es_freeroam1.3? so i can use police job.
But having and issue whenever i disconnect it sets my money (on Hand) in db to 0. No matter if +100 or -3000 it goes to 0.
So looking for a script that would save when a player disconnects.
Thanks allot of any help.
essentialmode/server/main.lua
AddEventHandler(âplayerDroppedâ, function()
if(Users[source])then
TriggerEvent(âes:playerDroppedâ, Users[source])
db.updateUser(Users[source].identifier, {money = Users[source].money, Users[source].bank}, function()
Users[source] = nil
end)
end
end)
By default itâs supposed to be there.
Thanks allot, it was changed. not sure if old version or what but it wasnât what you posted. Been trying to figure out the cause for hours apon hours now.
i narrowed down to line 54, but wasnât sure what to do to fix it, so thanks allot.
Thats for mysql right? just to confirm.
just checked new version, and it same 
need fix for mysql not sure what going on.
is in mysql version.
AddEventHandler('playerDropped', function()
if(Users[source])then
TriggerEvent("es:playerDropped", Users[source])
MySQL:executeQuery("UPDATE users SET `money`='@value' WHERE identifier = '@identifier'",
{['@value'] = 0, ['@identifier'] = Users[source].identifier})
Users[source] = nil
end
end)
is
{['@value'] = 0
setting db to 0?
My files for MySQL version with bonus to put any car in garage when player disconnect.
AddEventHandler(âplayerDroppedâ, function()
if(Users[source])then
TriggerEvent(âes:playerDroppedâ, Users[source])
MySQL:executeQuery("UPDATE users SET `money`='@value' WHERE identifier = '@identifier'",
{['@value'] = Users[source].money, ['@identifier'] = Users[source].identifier})
MySQL:executeQuery("UPDATE user_vehicle SET vehicle_state='Rentré' WHERE identifier = '@identifier'",
{['@identifier'] = Users[source].identifier})
Users[source] = nil
end
end)
1 Like
Thanks much, iâm literally just testing out
MySQL:executeQuery("UPDATE users SET `money`='@value' WHERE identifier = '@identifier'",
{['@value'] = Users[source].money, ['@identifier'] = Users[source].identifier})
Users[source] = nil
that i found,
and it worked, thanks allot.
hi, i follow your code but it seem to not working. Where do i place the code exactly? do i need to require mysql inorder for this code to work? I am trying to spawn back the car after user disconnected. Thank you!
Have you fixed it ? Can you tell me how ?
hello guys i have same problem,
money and bank cant be saved, dont get error⊠just don saveâŠ
i try put that codes on place but when i do that is like script dosent work anymore dont show bank and money :\
any ideia ?