Hi there, I would like to save client data when playerDropped.
Server-side, i have :
AddEventHandler("es:playerDropped", function(user)
TriggerClientEvent("pat_recolt:requestData", source)
print('requestData')
end)
RegisterServerEvent("pa_recolt:SaveData")
AddEventHandler("pa_recolt:SaveData", function(tValueA, tValueB)
print('Save Data')
SaveEphedrine = tValueA
SaveAcidMuria = tValueB
SaveData(source)
end)
function SaveData(source)
TriggerEvent('es:getPlayerFromId', source, function(user)
local playerid = user.getIdentifier()
MySQL.Async.fetchAll("UPDATE users SET Ephedrine=@Ephedrine, AcideMuriatic=@AcideMuriatic WHERE identifier = @user",{
['@Ephedrine'] = SaveEphedrine,
['@AcideMuriatic'] = SaveAcidMuria,
['@user'] = playerid })
end)
end
Client-side, i have :
local EphedrineAmount = 0
local AcideMuriaticAmount = 0
RegisterNetEvent("pat_recolt:requestData")
AddEventHandler("pat_recolt:requestData", function()
TriggerServerEvent("pa_recolt:SaveData", EphedrineAmount, AcideMuriaticAmount)
end)
This code doesn’t work, if you can help me… thanks!