Mahlukat Posted July 24, 2018 Share Posted July 24, 2018 Hey i want to save table in client-side when localPlayer disconnected --client addEventHandler( "onClientResourceStop", resourceRoot,function() triggerServerEvent("Freeroam:SureKaydet", localPlayer, sureVerileri, true) if sureVerileri[localPlayer] and isTimer(sureVerileri[localPlayer].timer) then killTimer(sureVerileri[localPlayer].timer) end end) --server addEvent("Freeroam:SureKaydet", true) addEventHandler("Freeroam:SureKaydet", root, function(sureVerileri,bosmu) outputServerLog("triggered server") -- i can't see this message in console local hesap = getPlayerAccount(source) if not isGuestAccount(hesap) then outputServerLog("not guest") local sure = 60*10 if sureVerileri[source] and sureVerileri[source].sure then sure = sureVerileri[source].sure end exports.Hesaplar:SAD(hesap, "KiralikSure", sure) outputServerLog("saved.") outputServerLog(sure) if bosmu then exports.Hesaplar:SAD(hesap, "KiralikSureBos", true) end end end) but event isn't triggered :(( how can ido it? - Link to comment
_Evo_ Posted July 24, 2018 Share Posted July 24, 2018 (edited) did you tried to use onClientPlayerQuit ? https://wiki.multitheftauto.com/wiki/OnClientPlayerQuit Edited July 24, 2018 by _Evo_ Link to comment
xMKHx Posted July 24, 2018 Share Posted July 24, 2018 try this -- Client function SureKaydet () triggerServerEvent("Freeroam:SureKaydet", localPlayer, sureVerileri, true) if sureVerileri[localPlayer] and isTimer(sureVerileri[localPlayer].timer) then killTimer(sureVerileri[localPlayer].timer) end end addEventHandler( "onClientPlayerQuit", getRootElement(), SureKaydet ) -- server function SureKaydet (sureVerileri,bosmu) outputServerLog("triggered server") local hesap = getPlayerAccount(source) if isGuestAccount(hesap) then return false end outputServerLog("not guest") local sure = 60*10 if sureVerileri[source] and sureVerileri[source].sure then sure = sureVerileri[source].sure end exports.Hesaplar:SAD(hesap, "KiralikSure", sure) outputServerLog("saved.") outputServerLog(sure) if bosmu then exports.Hesaplar:SAD(hesap, "KiralikSureBos", true) end end addEvent("Freeroam:SureKaydet", true) addEventHandler("Freeroam:SureKaydet", getRootElement(), SureKaydet) Link to comment
Mahlukat Posted July 24, 2018 Author Share Posted July 24, 2018 4 hours ago, _Evo_ said: did you tried to use onClientPlayerQuit ? https://wiki.multitheftauto.com/wiki/OnClientPlayerQuit Yea, i tried but wiki said;This event is triggered when a remote player quits the game or leaves the server. It will not get triggered on the source player's client. (Use onClientResourceStop to save client side data when the local player quits.) 19 minutes ago, xMKHx said: try this -- Client function SureKaydet () triggerServerEvent("Freeroam:SureKaydet", localPlayer, sureVerileri, true) if sureVerileri[localPlayer] and isTimer(sureVerileri[localPlayer].timer) then killTimer(sureVerileri[localPlayer].timer) end end addEventHandler( "onClientPlayerQuit", getRootElement(), SureKaydet ) -- server function SureKaydet (sureVerileri,bosmu) outputServerLog("triggered server") local hesap = getPlayerAccount(source) if isGuestAccount(hesap) then return false end outputServerLog("not guest") local sure = 60*10 if sureVerileri[source] and sureVerileri[source].sure then sure = sureVerileri[source].sure end exports.Hesaplar:SAD(hesap, "KiralikSure", sure) outputServerLog("saved.") outputServerLog(sure) if bosmu then exports.Hesaplar:SAD(hesap, "KiralikSureBos", true) end end addEvent("Freeroam:SureKaydet", true) addEventHandler("Freeroam:SureKaydet", getRootElement(), SureKaydet) thanks for help but it's still not triggered :(( Link to comment
Moderators IIYAMA Posted July 24, 2018 Moderators Share Posted July 24, 2018 Probably because the custom event you try to trigger is too late. The player has already left the game. Streaming data might be your only option. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now