Jump to content

Weapon Table


Snow-Man

Recommended Posts

On Monday, January 02, 2017 at 11:05 PM, Miika said:

Are you trying to save weapons when player quit?

Yes, that's Exactly What I Mean

 

19 hours ago, #_iMr,[E]coo said:

onPlayerQuit 
onPlayerWasted 
setAccountData
or
executeSQLQuery 

 

I Know Functions

But I Need Help With Table

Link to comment
addEventHandler("onPlayerQuit", root,
function()
   local account = getPlayerAccount(source)
   if account and not isGuestAccount(account) then
     local t = {}
     for i=0, 12 do
        local weapon = getPedWeapon(source, i)
        local ammo = getPedTotalAmmo(source, i)
        table.insert(t, weapon..", "..ammo)
     end
      setAccountData(account, "playerweapons", toJSON(t))
   end
end
)
addEventHandler("onPlayerLogin", root,
function()
   local account = getPlayerAccount(source)
   local t = fromJSON(getAccountData(account, "playerweapons"))
   for i=0, 12 do
      local wp = split(t[i+1][1], ", ")
      giveWeapon(source, wp[1], wp[2], true)
      setAccountData(account, "playerweapons", false)
   end
end
)

 

Edited by Miika
  • Like 1
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...