Ryder! Posted February 17, 2009 Share Posted February 17, 2009 hi, I want to get all player weapons when they quit the server and then send the data to the server for saving it into the sqlite db. My problem is with the "onClientResourceStop" event, it's possible to retrieve the client weapons in this event ? I'm asking it because it doesn't work for me This is what i have: Client: function onClientResourceStop( resource ) triggerServerEvent( "getAllClientWeapons", getRootElement() ) -- for testing the event --[[local count = 0 local weapons = {} while count ~= 12 do local wep = getPedWeapon( localPlayer, count ) local ammo = getPedTotalAmmo( localPlayer, count ) table.insert( weapons, wep, ammo ) count = count + 1 end triggerServerEvent( "getAllClientWeapons", getRootElement(), weapons )]] end addEventHandler( "onClientResourceStop", getResourceRootElement( getThisResource() ), onClientResourceStop ) Server: function allClientWeapons() outputServerLog( "wololo" ) -- no print --[[for weapon,ammo in pairs( weapons ) do local slot = getSlotFromWeapon ( weapon ) executeSQLQuery( "UPDATE startToday_players SET slot"..slot.." = ? WHERE nick = ?", weapon.." "..ammo, getPlayerName( client ) ) end]] end addEvent( "getAllClientWeapons", true ) addEventHandler( "getAllClientWeapons", getRootElement() , allClientWeapons ) if it's not possible to do this way, how can i do it ? =) Thanks bye! Link to comment
Gamesnert Posted February 17, 2009 Share Posted February 17, 2009 Maybe saving all client weapons every 5 min or something? And that you also make a command for it in case the player wants to be sure? This has the simple advantage of having things saved in advance in case someone crashes, in which the code you gave obviously won't work at all. 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