Jump to content

Get all player weapons on quit help :S =(


Ryder!

Recommended Posts

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 :S

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

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. :P

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...