Jump to content

Weapon save and load onPlayerSpawn


Recommended Posts

function onPlayerQuit ( ) 
      local playeraccount = getPlayerAccount ( source ) 
      if ( playeraccount ) then 
            local x,y,z = getElementPosition (source) 
            setAccountData ( playeraccount, "s.HandMoney", getPlayerMoney ( source ) ) 
            setAccountData (playeraccount, "s.skin", tostring (getPedSkin (source))) 
            setAccountData (playeraccount, "s.x", x) 
            setAccountData (playeraccount, "s.y", y) 
            setAccountData (playeraccount, "s.z", z) 
            setAccountData (playeraccount, "s.int", getElementInterior (source)) 
            setAccountData (playeraccount, "s.dim", getElementDimension (source)) 
            setAccountData (playeraccount, "s.rot", getPedRotation (source)) 
            setAccountData (playeraccount, "s.weap0", getPedWeapon ( source, 0 )) 
            setAccountData (playeraccount, "s.weap1", getPedWeapon ( source, 1 )) 
            setAccountData (playeraccount, "s.weap2", getPedWeapon ( source, 2 )) 
            setAccountData (playeraccount, "s.ammo2", getPedTotalAmmo ( source, 2 )) 
            setAccountData (playeraccount, "s.weap3", getPedWeapon ( source, 3 )) 
            setAccountData (playeraccount, "s.ammo3", getPedTotalAmmo ( source, 3 )) 
            setAccountData (playeraccount, "s.weap4", getPedWeapon ( source, 4 )) 
            setAccountData (playeraccount, "s.ammo4", getPedTotalAmmo ( source, 4 )) 
            setAccountData (playeraccount, "s.weap5", getPedWeapon ( source, 5 )) 
            setAccountData (playeraccount, "s.ammo5", getPedTotalAmmo ( source, 5 )) 
            setAccountData (playeraccount, "s.weap6", getPedWeapon ( source, 6 )) 
            setAccountData (playeraccount, "s.ammo6", getPedTotalAmmo ( source, 6 )) 
            setAccountData (playeraccount, "s.weap7", getPedWeapon ( source, 7 )) 
            setAccountData (playeraccount, "s.ammo7", getPedTotalAmmo ( source, 7 )) 
            setAccountData (playeraccount, "s.weap8", getPedWeapon ( source, 8 )) 
            setAccountData (playeraccount, "s.ammo8", getPedTotalAmmo ( source, 8 )) 
            setAccountData (playeraccount, "s.weap9", getPedWeapon ( source, 9 )) 
            setAccountData (playeraccount, "s.ammo9", getPedTotalAmmo ( source, 9 )) 
            setAccountData (playeraccount, "s.weap10", getPedWeapon ( source, 10 )) 
            setAccountData (playeraccount, "s.weap11", getPedWeapon ( source, 11 )) 
            setAccountData (playeraccount, "s.weap12", getPedWeapon ( source, 12 )) 
      end 
end 
addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) 
  
local root = getRootElement() 
addEventHandler("onPlayerLogin", root, 
  function() 
     local playeraccount = getPlayerAccount ( source ) 
      if ( playeraccount ) then 
            local playermoney = getAccountData ( playeraccount, "s.HandMoney" ) 
            if ( playermoney ) then 
                  setPlayerMoney ( source, playermoney ) 
            end 
            local playerInt = getAccountData (playeraccount, "s.int") 
            local playerDim = getAccountData (playeraccount, "s.dim")   
            local playerSkin = getAccountData (playeraccount, "s.skin") 
            local playerX = getAccountData (playeraccount, "s.x") 
            local playerY = getAccountData (playeraccount, "s.y") 
            local playerZ = getAccountData (playeraccount, "s.z") 
            local playerRot = getAccountData (playeraccount, "s.rot") 
            spawnPlayer(source, playerX, playerY, playerZ, playerRot, playerSkin, playerInt, playerDim) 
            fadeCamera (source, true) 
            setCameraTarget (source, source) 
            local weap0 = getAccountData(playeraccount, "s.weap0") 
            local weap1 = getAccountData(playeraccount, "s.weap1") 
            local weap2 = getAccountData(playeraccount, "s.weap2") 
            local ammo2 = getAccountData(playeraccount, "s.ammo2") 
            local weap3 = getAccountData(playeraccount, "s.weap3") 
            local ammo3 = getAccountData(playeraccount, "s.ammo3") 
            local weap4 = getAccountData(playeraccount, "s.weap4") 
            local ammo4 = getAccountData(playeraccount, "s.ammo4") 
            local weap5 = getAccountData(playeraccount, "s.weap5") 
            local ammo5 = getAccountData(playeraccount, "s.ammo5") 
            local weap6 = getAccountData(playeraccount, "s.weap6") 
            local ammo6 = getAccountData(playeraccount, "s.ammo6") 
            local weap7 = getAccountData(playeraccount, "s.weap7") 
            local ammo7 = getAccountData(playeraccount, "s.ammo7") 
            local weap8 = getAccountData(playeraccount, "s.weap8") 
            local ammo8 = getAccountData(playeraccount, "s.ammo8") 
            local weap9 = getAccountData(playeraccount, "s.weap9") 
            local ammo9 = getAccountData(playeraccount, "s.ammo9") 
            local weap10 = getAccountData(playeraccount, "s.weap10") 
            local weap11 = getAccountData(playeraccount, "s.weap11") 
            local weap12 = getAccountData(playeraccount, "s.weap12") 
            giveWeapon ( source, weap0, 1 ) 
            giveWeapon ( source, weap1, 1 ) 
            giveWeapon ( source, weap2, ammo2 ) 
            giveWeapon ( source, weap3, ammo3 ) 
            giveWeapon ( source, weap4, ammo4 ) 
            giveWeapon ( source, weap5, ammo5 ) 
            giveWeapon ( source, weap6, ammo6 ) 
            giveWeapon ( source, weap7, ammo7 ) 
            giveWeapon ( source, weap8, ammo8 ) 
            giveWeapon ( source, weap9, ammo9 ) 
            giveWeapon ( source, weap10, 1 ) 
            giveWeapon ( source, weap11, 1 ) 
            giveWeapon ( source, weap12, 1 )         
      end 
  end 
) 
  

I have this script which saves weapon, skin, location, etc.

How can I add a spawnpoint for new registered players which dont spawn old accounts there,?

Edited by Guest
Link to comment

like this?

local playerInt = getAccountData (playeraccount, "s.int") 
local playerDim = getAccountData (playeraccount, "s.dim")   
local playerSkin = getAccountData (playeraccount, "s.skin") 
local playerX = getAccountData (playeraccount, "s.x") 
local playerY = getAccountData (playeraccount, "s.y") 
local playerZ = getAccountData (playeraccount, "s.z") 
local playerRot = getAccountData (playeraccount, "s.rot") 
if playerInt and playerDim and playerSkin and playerX and playerY and playerZ and playerRot then 
    spawnPlayer(source, playerX, playerY, playerZ, playerRot, playerSkin, playerInt, playerDim) 
    else 
    spawnPlayer(source, 0, 0, 0, 0, 0, 0, 0)    -- your cordenates custom 
end 

Link to comment
function onPlayerQuit ( ) 
      local playeraccount = getPlayerAccount ( source ) 
      if ( playeraccount ) then 
            local x,y,z = getElementPosition (source) 
            setAccountData ( playeraccount, "s.HandMoney", getPlayerMoney ( source ) ) 
            setAccountData (playeraccount, "s.skin", tostring (getPedSkin (source))) 
            setAccountData (playeraccount, "s.x", x) 
            setAccountData (playeraccount, "s.y", y) 
            setAccountData (playeraccount, "s.z", z) 
            setAccountData (playeraccount, "s.int", getElementInterior (source)) 
            setAccountData (playeraccount, "s.dim", getElementDimension (source)) 
            setAccountData (playeraccount, "s.rot", getPedRotation (source)) 
            setAccountData (playeraccount, "s.weap0", getPedWeapon ( source, 0 )) 
            setAccountData (playeraccount, "s.weap1", getPedWeapon ( source, 1 )) 
            setAccountData (playeraccount, "s.weap2", getPedWeapon ( source, 2 )) 
            setAccountData (playeraccount, "s.ammo2", getPedTotalAmmo ( source, 2 )) 
            setAccountData (playeraccount, "s.weap3", getPedWeapon ( source, 3 )) 
            setAccountData (playeraccount, "s.ammo3", getPedTotalAmmo ( source, 3 )) 
            setAccountData (playeraccount, "s.weap4", getPedWeapon ( source, 4 )) 
            setAccountData (playeraccount, "s.ammo4", getPedTotalAmmo ( source, 4 )) 
            setAccountData (playeraccount, "s.weap5", getPedWeapon ( source, 5 )) 
            setAccountData (playeraccount, "s.ammo5", getPedTotalAmmo ( source, 5 )) 
            setAccountData (playeraccount, "s.weap6", getPedWeapon ( source, 6 )) 
            setAccountData (playeraccount, "s.ammo6", getPedTotalAmmo ( source, 6 )) 
            setAccountData (playeraccount, "s.weap7", getPedWeapon ( source, 7 )) 
            setAccountData (playeraccount, "s.ammo7", getPedTotalAmmo ( source, 7 )) 
            setAccountData (playeraccount, "s.weap8", getPedWeapon ( source, 8 )) 
            setAccountData (playeraccount, "s.ammo8", getPedTotalAmmo ( source, 8 )) 
            setAccountData (playeraccount, "s.weap9", getPedWeapon ( source, 9 )) 
            setAccountData (playeraccount, "s.ammo9", getPedTotalAmmo ( source, 9 )) 
            setAccountData (playeraccount, "s.weap10", getPedWeapon ( source, 10 )) 
            setAccountData (playeraccount, "s.weap11", getPedWeapon ( source, 11 )) 
            setAccountData (playeraccount, "s.weap12", getPedWeapon ( source, 12 )) 
      end 
end 
addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) 
  
local root = getRootElement() 
addEventHandler("onPlayerLogin", root, 
  function() 
     local playeraccount = getPlayerAccount ( source ) 
      if ( playeraccount ) then 
            local playermoney = getAccountData ( playeraccount, "s.HandMoney" ) 
            if ( playermoney ) then 
                  setPlayerMoney ( source, playermoney ) 
            end 
            local playerInt = getAccountData (playeraccount, "s.int") 
            local playerDim = getAccountData (playeraccount, "s.dim")   
            local playerSkin = getAccountData (playeraccount, "s.skin") 
            local playerX = getAccountData (playeraccount, "s.x") 
            local playerY = getAccountData (playeraccount, "s.y") 
            local playerZ = getAccountData (playeraccount, "s.z") 
            local playerRot = getAccountData (playeraccount, "s.rot") 
            if playerInt and playerDim and playerSkin and playerX and playerY and playerZ and playerRot then 
        spawnPlayer(source, playerX, playerY, playerZ, playerRot, playerSkin, playerInt, playerDim) 
        else 
        spawnPlayer(source, 2485, -1665, 13.5, 0, 0, 0, 0, 0) 
        end 
            spawnPlayer(source, playerX, playerY, playerZ, playerRot, playerSkin, playerInt, playerDim) 
            fadeCamera (source, true) 
            setCameraTarget (source, source) 
            local weap0 = getAccountData(playeraccount, "s.weap0") 
            local weap1 = getAccountData(playeraccount, "s.weap1") 
            local weap2 = getAccountData(playeraccount, "s.weap2") 
            local ammo2 = getAccountData(playeraccount, "s.ammo2") 
            local weap3 = getAccountData(playeraccount, "s.weap3") 
            local ammo3 = getAccountData(playeraccount, "s.ammo3") 
            local weap4 = getAccountData(playeraccount, "s.weap4") 
            local ammo4 = getAccountData(playeraccount, "s.ammo4") 
            local weap5 = getAccountData(playeraccount, "s.weap5") 
            local ammo5 = getAccountData(playeraccount, "s.ammo5") 
            local weap6 = getAccountData(playeraccount, "s.weap6") 
            local ammo6 = getAccountData(playeraccount, "s.ammo6") 
            local weap7 = getAccountData(playeraccount, "s.weap7") 
            local ammo7 = getAccountData(playeraccount, "s.ammo7") 
            local weap8 = getAccountData(playeraccount, "s.weap8") 
            local ammo8 = getAccountData(playeraccount, "s.ammo8") 
            local weap9 = getAccountData(playeraccount, "s.weap9") 
            local ammo9 = getAccountData(playeraccount, "s.ammo9") 
            local weap10 = getAccountData(playeraccount, "s.weap10") 
            local weap11 = getAccountData(playeraccount, "s.weap11") 
            local weap12 = getAccountData(playeraccount, "s.weap12") 
            giveWeapon ( source, weap0, 1 ) 
            giveWeapon ( source, weap1, 1 ) 
            giveWeapon ( source, weap2, ammo2 ) 
            giveWeapon ( source, weap3, ammo3 ) 
            giveWeapon ( source, weap4, ammo4 ) 
            giveWeapon ( source, weap5, ammo5 ) 
            giveWeapon ( source, weap6, ammo6 ) 
            giveWeapon ( source, weap7, ammo7 ) 
            giveWeapon ( source, weap8, ammo8 ) 
            giveWeapon ( source, weap9, ammo9 ) 
            giveWeapon ( source, weap10, 1 ) 
            giveWeapon ( source, weap11, 1 ) 
            giveWeapon ( source, weap12, 1 )             
      end 
  end 
) 
  

Errors: 83 - 95 : Bad Argument @ 'giveWeapon' [Expected weapon-type at argument 2, got boolean.

And it does not also spawn me to the exact coordinates I put in spawnPlayer.

Link to comment
function onLogout(quitType, reason, resposibleElement) 
    if not (isGuestAccount(getPlayerAccount(source))) then 
        local account = getPlayerAccount(source) 
        if (account) then 
            local x, y, z = getElementPosition(source) 
            setAccountData(account, "s.HandMoney", tostring(getPlayerMoney(source))) 
            setAccountData(account, "s.skin", tostring(getPedSkin(source))) 
            setAccountData(account , "s.health", tostring(getElementHealth(source))) 
            setAccountData(account, "s.armor", tostring(getPedArmor(source))) 
            setAccountData(account, "s.x", x) 
            setAccountData(account, "s.y", y) 
            setAccountData(account, "s.z", z) 
            setAccountData(account, "s.int", getElementInterior(source)) 
            setAccountData(account, "s.dim", getElementDimension(source)) 
            setAccountData(account, "s.rot", getElementRotation(source)) 
            setAccountData(account, "s.weap0", getPedWeapon(source, 0)) 
            setAccountData(account, "s.weap1", getPedWeapon(source, 1)) 
            setAccountData(account, "s.weap2", getPedWeapon(source, 2)) 
            setAccountData(account, "s.weap3", getPedWeapon(source, 3)) 
            setAccountData(account, "s.weap4", getPedWeapon(source, 4)) 
            setAccountData(account, "s.weap5", getPedWeapon(source, 5)) 
            setAccountData(account, "s.weap6", getPedWeapon(source, 6)) 
            setAccountData(account, "s.weap7", getPedWeapon(source, 7)) 
            setAccountData(account, "s.weap8", getPedWeapon(source, ) 
            setAccountData(account, "s.weap9", getPedWeapon(source, 9)) 
            setAccountData(account, "s.weap10", getPedWeapon(source, 10)) 
            setAccountData(account, "s.weap11", getPedWeapon(source, 11)) 
            setAccountData(account, "s.weap12", getPedWeapon(source, 12)) 
            setAccountData(account, "s.ammo0", getPedTotalAmmo(source, 0)) 
            setAccountData(account, "s.ammo1", getPedTotalAmmo(source, 1)) 
            setAccountData(account, "s.ammo2", getPedTotalAmmo(source, 2)) 
            setAccountData(account, "s.ammo3", getPedTotalAmmo(source, 3)) 
            setAccountData(account, "s.ammo4", getPedTotalAmmo(source, 4)) 
            setAccountData(account, "s.ammo5", getPedTotalAmmo(source, 5)) 
            setAccountData(account, "s.ammo6", getPedTotalAmmo(source, 6)) 
            setAccountData(account, "s.ammo7", getPedTotalAmmo(source, 7)) 
            setAccountData(account, "s.ammo8", getPedTotalAmmo(source, ) 
            setAccountData(account, "s.ammo9", getPedTotalAmmo(source, 9)) 
            setAccountData(account, "s.ammo10", getPedTotalAmmo(source, 10)) 
            setAccountData(account, "s.ammo11", getPedTotalAmmo(source, 11)) 
            setAccountData(account, "s.ammo12", getPedTotalAmmo(source, 12)) 
       end 
   end 
end 
addEventHandler("onPlayerQuit", getRootElement(), onQuit) 
  
function onLogin(thePreviousAccount, theCurrentAccount, autoLogin) 
   if not (isGuestAccount(getPlayerAccount(source))) then 
       local accountData = getAccountData(theCurrentAccount, "s.HandMoney") 
       if (accountData) then 
            local playerMoney = getAccountData(theCurrentAccount, "s.HandMoney") 
            local playerSkin = getAccountData(theCurrentAccount, "s.skin") 
            local playerHealth = getAccountData(theCurrentAccount, "s.health") 
            local playerArmor = getAccountData(theCurrentAccount, "s.armor") 
            local playerX = getAccountData(theCurrentAccount, "s.x") 
            local playerY = getAccountData(theCurrentAccount, "s.y") 
            local playerZ = getAccountData(theCurrentAccount, "s.z") 
            local playerRot = getAccountData(theCurrentAccount, "s.rot") 
            local playerInt = getAccountData(theCurrentAccount, "s.int") 
            local playerDim = getAccountData(theCurrentAccount, "s.dim") 
            local weap0 = getAccountData(theCurrentAccount, "s.weap0") 
            local weap1 = getAccountData(theCurrentAccount, "s.weap1") 
            local weap2 = getAccountData(theCurrentAccount, "s.weap2") 
            local weap3 = getAccountData(theCurrentAccount, "s.weap3") 
            local weap4 = getAccountData(theCurrentAccount, "s.weap4") 
            local weap5 = getAccountData(theCurrentAccount, "s.weap5") 
            local weap6 = getAccountData(theCurrentAccount, "s.weap6") 
            local weap7 = getAccountData(theCurrentAccount, "s.weap7") 
            local weap8 = getAccountData(theCurrentAccount, "s.weap8") 
            local weap9 = getAccountData(theCurrentAccount, "s.weap9") 
            local weap10 = getAccountData(theCurrentAccount, "s.weap10") 
            local weap11 = getAccountData(theCurrentAccount, "s.weap11") 
            local weap12 = getAccountData(theCurrentAccount, "s.weap12") 
            local ammo0 = getAccountData(theCurrentAccount, "s.ammo0") 
            local ammo1 = getAccountData(theCurrentAccount, "s.ammo1") 
            local ammo2 = getAccountData(theCurrentAccount, "s.ammo2") 
            local ammo3 = getAccountData(theCurrentAccount, "s.ammo3") 
            local ammo4 = getAccountData(theCurrentAccount, "s.ammo4") 
            local ammo5 = getAccountData(theCurrentAccount, "s.ammo5") 
            local ammo6 = getAccountData(theCurrentAccount, "s.ammo6") 
            local ammo7 = getAccountData(theCurrentAccount, "s.ammo7") 
            local ammo8 = getAccountData(theCurrentAccount, "s.ammo8") 
            local ammo9 = getAccountData(theCurrentAccount, "s.ammo9") 
            local ammo10 = getAccountData(theCurrentAccount, "s.ammo10") 
            local ammo11 = getAccountData(theCurrentAccount, "s.ammo11") 
            local ammo12 = getAccountData(theCurrentAccount, "s.ammo12") 
            setPlayerMoney(source, playerMoney) 
            setElementHealth(source, playerHealth) 
            setPedArmor(source, playerArmor) 
            spawnPlayer(source, playerX, playerY, playerZ+1, playerRot, playerSkin, playerInt, playerDim) 
            fadeCamera(source, true, 2.0) 
            setCameraTarget(source, source) 
            giveWeapon(source, weap0, ammo0, true) 
            giveWeapon(source, weap1, ammo1, false) 
            giveWeapon(source, weap2, ammo2, false) 
            giveWeapon(source, weap3, ammo3, false) 
            giveWeapon(source, weap4, ammo4, false) 
            giveWeapon(source, weap5, ammo5, false) 
            giveWeapon(source, weap6, ammo6, false) 
            giveWeapon(source, weap7, ammo7, false) 
            giveWeapon(source, weap8, ammo8, false) 
            giveWeapon(source, weap9, ammo9, false) 
            giveWeapon(source, weap10, ammo10, false) 
            giveWeapon(source, weap11, ammo11, false) 
            giveWeapon(source, weap12, ammo12, false) 
       else 
            spawnPlayer(source, 2485, -1665, 13.5, 0, 0, 0, 0) 
            fadeCamera(source, true, 2.0) 
            setCameraTarget(source, source) 
       end 
   end 
end 
addEventHandler("onPlayerLogin", getRootElement(), onLogin)  

Edited by Guest
Link to comment

Enargy`s script is better. But, the location where it always spawns me when using newbie accounts is in LOS SANTOS NORTH-WEST in the farm. The weird thing is, I`m beneath the ground.

Errors: 83 - 95 : Bad Argument @ 'giveWeapon' [Expected weapon-type at argument 2, got boolean.

And it does not also spawn me to the exact coordinates I put in spawnPlayer.

Link to comment
function onQuit(quitType, reason, resposibleElement) 
    if not (isGuestAccount(getPlayerAccount(source))) then 
        local account = getPlayerAccount(source) 
        if (account) then 
            local x, y, z = getElementPosition(source) 
            setAccountData(account, "s.HandMoney", tostring(getPlayerMoney(source))) 
            setAccountData(account, "s.skin", tostring(getPedSkin(source))) 
            setAccountData(account , "s.health", tostring(getElementHealth(source))) 
            setAccountData(account, "s.armor", tostring(getPedArmor(source))) 
            setAccountData(account, "s.x", x) 
            setAccountData(account, "s.y", y) 
            setAccountData(account, "s.z", z) 
            setAccountData(account, "s.int", getElementInterior(source)) 
            setAccountData(account, "s.dim", getElementDimension(source)) 
            setAccountData(account, "s.rot", getElementRotation(source)) 
            setAccountData(account, "s.weap0", getPedWeapon(source, 0)) 
            setAccountData(account, "s.weap1", getPedWeapon(source, 1)) 
            setAccountData(account, "s.weap2", getPedWeapon(source, 2)) 
            setAccountData(account, "s.weap3", getPedWeapon(source, 3)) 
            setAccountData(account, "s.weap4", getPedWeapon(source, 4)) 
            setAccountData(account, "s.weap5", getPedWeapon(source, 5)) 
            setAccountData(account, "s.weap6", getPedWeapon(source, 6)) 
            setAccountData(account, "s.weap7", getPedWeapon(source, 7)) 
            setAccountData(account, "s.weap8", getPedWeapon(source, ) 
            setAccountData(account, "s.weap9", getPedWeapon(source, 9)) 
            setAccountData(account, "s.weap10", getPedWeapon(source, 10)) 
            setAccountData(account, "s.weap11", getPedWeapon(source, 11)) 
            setAccountData(account, "s.weap12", getPedWeapon(source, 12)) 
            setAccountData(account, "s.ammo0", getPedTotalAmmo(source, 0)) 
            setAccountData(account, "s.ammo1", getPedTotalAmmo(source, 1)) 
            setAccountData(account, "s.ammo2", getPedTotalAmmo(source, 2)) 
            setAccountData(account, "s.ammo3", getPedTotalAmmo(source, 3)) 
            setAccountData(account, "s.ammo4", getPedTotalAmmo(source, 4)) 
            setAccountData(account, "s.ammo5", getPedTotalAmmo(source, 5)) 
            setAccountData(account, "s.ammo6", getPedTotalAmmo(source, 6)) 
            setAccountData(account, "s.ammo7", getPedTotalAmmo(source, 7)) 
            setAccountData(account, "s.ammo8", getPedTotalAmmo(source, ) 
            setAccountData(account, "s.ammo9", getPedTotalAmmo(source, 9)) 
            setAccountData(account, "s.ammo10", getPedTotalAmmo(source, 10)) 
            setAccountData(account, "s.ammo11", getPedTotalAmmo(source, 11)) 
            setAccountData(account, "s.ammo12", getPedTotalAmmo(source, 12)) 
       end 
   end 
end 
addEventHandler("onPlayerQuit", getRootElement(), onQuit) 
  
function onLogin(thePreviousAccount, theCurrentAccount, autoLogin) 
   if not (isGuestAccount(getPlayerAccount(source))) then 
       local accountData = getAccountData(theCurrentAccount, "s.HandMoney") 
       if (accountData) then 
            local playerMoney = getAccountData(theCurrentAccount, "s.HandMoney") 
            local playerSkin = getAccountData(theCurrentAccount, "s.skin") 
            local playerHealth = getAccountData(theCurrentAccount, "s.health") 
            local playerArmor = getAccountData(theCurrentAccount, "s.armor") 
            local playerX = getAccountData(theCurrentAccount, "s.x") 
            local playerY = getAccountData(theCurrentAccount, "s.y") 
            local playerZ = getAccountData(theCurrentAccount, "s.z") 
            local playerRot = getAccountData(theCurrentAccount, "s.rot") 
            local playerInt = getAccountData(theCurrentAccount, "s.int") 
            local playerDim = getAccountData(theCurrentAccount, "s.dim") 
            local weap0 = getAccountData(theCurrentAccount, "s.weap0") 
            local weap1 = getAccountData(theCurrentAccount, "s.weap1") 
            local weap2 = getAccountData(theCurrentAccount, "s.weap2") 
            local weap3 = getAccountData(theCurrentAccount, "s.weap3") 
            local weap4 = getAccountData(theCurrentAccount, "s.weap4") 
            local weap5 = getAccountData(theCurrentAccount, "s.weap5") 
            local weap6 = getAccountData(theCurrentAccount, "s.weap6") 
            local weap7 = getAccountData(theCurrentAccount, "s.weap7") 
            local weap8 = getAccountData(theCurrentAccount, "s.weap8") 
            local weap9 = getAccountData(theCurrentAccount, "s.weap9") 
            local weap10 = getAccountData(theCurrentAccount, "s.weap10") 
            local weap11 = getAccountData(theCurrentAccount, "s.weap11") 
            local weap12 = getAccountData(theCurrentAccount, "s.weap12") 
            local ammo0 = getAccountData(theCurrentAccount, "s.ammo0") 
            local ammo1 = getAccountData(theCurrentAccount, "s.ammo1") 
            local ammo2 = getAccountData(theCurrentAccount, "s.ammo2") 
            local ammo3 = getAccountData(theCurrentAccount, "s.ammo3") 
            local ammo4 = getAccountData(theCurrentAccount, "s.ammo4") 
            local ammo5 = getAccountData(theCurrentAccount, "s.ammo5") 
            local ammo6 = getAccountData(theCurrentAccount, "s.ammo6") 
            local ammo7 = getAccountData(theCurrentAccount, "s.ammo7") 
            local ammo8 = getAccountData(theCurrentAccount, "s.ammo8") 
            local ammo9 = getAccountData(theCurrentAccount, "s.ammo9") 
            local ammo10 = getAccountData(theCurrentAccount, "s.ammo10") 
            local ammo11 = getAccountData(theCurrentAccount, "s.ammo11") 
            local ammo12 = getAccountData(theCurrentAccount, "s.ammo12") 
            setPlayerMoney(source, playerMoney) 
            setElementHealth(source, playerHealth) 
            setPedArmor(source, playerArmor) 
            spawnPlayer(source, playerX, playerY, playerZ+1, playerRot, playerSkin, playerInt, playerDim) 
            fadeCamera(source, true, 2.0) 
            setCameraTarget(source, source) 
            giveWeapon(source, weap0, ammo0, true) 
            giveWeapon(source, weap1, ammo1, false) 
            giveWeapon(source, weap2, ammo2, false) 
            giveWeapon(source, weap3, ammo3, false) 
            giveWeapon(source, weap4, ammo4, false) 
            giveWeapon(source, weap5, ammo5, false) 
            giveWeapon(source, weap6, ammo6, false) 
            giveWeapon(source, weap7, ammo7, false) 
            giveWeapon(source, weap8, ammo8, false) 
            giveWeapon(source, weap9, ammo9, false) 
            giveWeapon(source, weap10, ammo10, false) 
            giveWeapon(source, weap11, ammo11, false) 
            giveWeapon(source, weap12, ammo12, false) 
       else 
            spawnPlayer(source, 2485, -1665, 13.5, 0, 0, 0, 0) 
            fadeCamera(source, true, 2.0) 
            setCameraTarget(source, source) 
       end 
   end 
end 
addEventHandler("onPlayerLogin", getRootElement(), onLogin) 

Link to comment
local default = { 
interior = 0, 
dimension = 0, 
skin = 0, 
x = 0, 
y = 0, 
z = 5, 
rot = 90, 
} 
  
function onPlayerQuit ( ) 
      local playeraccount = getPlayerAccount ( source ) 
      if ( playeraccount ) then 
            local x,y,z = getElementPosition (source) 
            setAccountData ( playeraccount, "s.HandMoney", getPlayerMoney ( source ) ) 
            setAccountData (playeraccount, "s.skin", tostring (getPedSkin (source))) 
            setAccountData (playeraccount, "s.x", x) 
            setAccountData (playeraccount, "s.y", y) 
            setAccountData (playeraccount, "s.z", z) 
            setAccountData (playeraccount, "s.int", getElementInterior (source)) 
            setAccountData (playeraccount, "s.dim", getElementDimension (source)) 
            setAccountData (playeraccount, "s.rot", getPedRotation (source)) 
            setAccountData (playeraccount, "s.weap0", getPedWeapon ( source, 0 )) 
            setAccountData (playeraccount, "s.weap1", getPedWeapon ( source, 1 )) 
            setAccountData (playeraccount, "s.weap2", getPedWeapon ( source, 2 )) 
            setAccountData (playeraccount, "s.ammo2", getPedTotalAmmo ( source, 2 )) 
            setAccountData (playeraccount, "s.weap3", getPedWeapon ( source, 3 )) 
            setAccountData (playeraccount, "s.ammo3", getPedTotalAmmo ( source, 3 )) 
            setAccountData (playeraccount, "s.weap4", getPedWeapon ( source, 4 )) 
            setAccountData (playeraccount, "s.ammo4", getPedTotalAmmo ( source, 4 )) 
            setAccountData (playeraccount, "s.weap5", getPedWeapon ( source, 5 )) 
            setAccountData (playeraccount, "s.ammo5", getPedTotalAmmo ( source, 5 )) 
            setAccountData (playeraccount, "s.weap6", getPedWeapon ( source, 6 )) 
            setAccountData (playeraccount, "s.ammo6", getPedTotalAmmo ( source, 6 )) 
            setAccountData (playeraccount, "s.weap7", getPedWeapon ( source, 7 )) 
            setAccountData (playeraccount, "s.ammo7", getPedTotalAmmo ( source, 7 )) 
            setAccountData (playeraccount, "s.weap8", getPedWeapon ( source, 8 )) 
            setAccountData (playeraccount, "s.ammo8", getPedTotalAmmo ( source, 8 )) 
            setAccountData (playeraccount, "s.weap9", getPedWeapon ( source, 9 )) 
            setAccountData (playeraccount, "s.ammo9", getPedTotalAmmo ( source, 9 )) 
            setAccountData (playeraccount, "s.weap10", getPedWeapon ( source, 10 )) 
            setAccountData (playeraccount, "s.weap11", getPedWeapon ( source, 11 )) 
            setAccountData (playeraccount, "s.weap12", getPedWeapon ( source, 12 )) 
      end 
end 
addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) 
  
local root = getRootElement() 
addEventHandler("onPlayerLogin", root, 
  function() 
     local playeraccount = getPlayerAccount ( source ) 
      if ( playeraccount ) then 
            local playermoney = getAccountData ( playeraccount, "s.HandMoney" ) 
            if ( playermoney ) then 
                  setPlayerMoney ( source, playermoney ) 
            end 
            local playerInt = getAccountData (playeraccount, "s.int") or default.interior 
            local playerDim = getAccountData (playeraccount, "s.dim") or default.dimension 
            local playerSkin = getAccountData (playeraccount, "s.skin") or default. 
            local playerX = getAccountData (playeraccount, "s.x") or default.x 
            local playerY = getAccountData (playeraccount, "s.y") or default.y 
            local playerZ = getAccountData (playeraccount, "s.z") or default.z 
            local playerRot = getAccountData (playeraccount, "s.rot") or default.rot 
            spawnPlayer(source, playerX, playerY, playerZ, playerRot, playerSkin, playerInt, playerDim) 
            fadeCamera (source, true) 
            setCameraTarget (source, source) 
            local weap0 = getAccountData(playeraccount, "s.weap0") 
            local weap1 = getAccountData(playeraccount, "s.weap1") 
            local weap2 = getAccountData(playeraccount, "s.weap2") 
            local ammo2 = getAccountData(playeraccount, "s.ammo2") 
            local weap3 = getAccountData(playeraccount, "s.weap3") 
            local ammo3 = getAccountData(playeraccount, "s.ammo3") 
            local weap4 = getAccountData(playeraccount, "s.weap4") 
            local ammo4 = getAccountData(playeraccount, "s.ammo4") 
            local weap5 = getAccountData(playeraccount, "s.weap5") 
            local ammo5 = getAccountData(playeraccount, "s.ammo5") 
            local weap6 = getAccountData(playeraccount, "s.weap6") 
            local ammo6 = getAccountData(playeraccount, "s.ammo6") 
            local weap7 = getAccountData(playeraccount, "s.weap7") 
            local ammo7 = getAccountData(playeraccount, "s.ammo7") 
            local weap8 = getAccountData(playeraccount, "s.weap8") 
            local ammo8 = getAccountData(playeraccount, "s.ammo8") 
            local weap9 = getAccountData(playeraccount, "s.weap9") 
            local ammo9 = getAccountData(playeraccount, "s.ammo9") 
            local weap10 = getAccountData(playeraccount, "s.weap10") 
            local weap11 = getAccountData(playeraccount, "s.weap11") 
            local weap12 = getAccountData(playeraccount, "s.weap12") 
            if ( weap2 ) then 
            giveWeapon ( source, weap0, 1 ) 
            end 
            if ( weap2 ) then 
            giveWeapon ( source, weap1, 1 ) 
            end 
            if ( weap2 ) then 
            giveWeapon ( source, weap2, ammo2 ) 
            end 
            if ( weap3 ) then 
            giveWeapon ( source, weap3, ammo3 ) 
            end 
            if ( weap4 ) then 
            giveWeapon ( source, weap4, ammo4 ) 
            end 
            if ( weap5 ) then 
            giveWeapon ( source, weap5, ammo5 ) 
            end 
            if ( weap6 ) then 
            giveWeapon ( source, weap6, ammo6 ) 
            end 
            if ( weap7 ) then 
            giveWeapon ( source, weap7, ammo7 ) 
            end 
            if ( weap8 ) then 
            giveWeapon ( source, weap8, ammo8 ) 
            end 
            if ( weap9 ) then 
            giveWeapon ( source, weap9, ammo9 ) 
            end 
            if ( weap2 ) then 
            giveWeapon ( source, weap10, 1 ) 
            end 
            if ( weap2 ) then 
            giveWeapon ( source, weap11, 1 ) 
            end 
            if ( weap2 ) then 
            giveWeapon ( source, weap12, 1 )        
            end 
      end 
  end 
) 

Link to comment
function onQuit(quitType, reason, resposibleElement) 
    if not (isGuestAccount(getPlayerAccount(source))) then 
        local account = getPlayerAccount(source) 
        if (account) then 
            local x, y, z = getElementPosition(source) 
            setAccountData(account, "s.HandMoney", tostring(getPlayerMoney(source))) 
            setAccountData(account, "s.skin", tostring(getPedSkin(source))) 
            setAccountData(account , "s.health", tostring(getElementHealth(source))) 
            setAccountData(account, "s.armor", tostring(getPedArmor(source))) 
            setAccountData(account, "s.x", x) 
            setAccountData(account, "s.y", y) 
            setAccountData(account, "s.z", z) 
            setAccountData(account, "s.int", getElementInterior(source)) 
            setAccountData(account, "s.dim", getElementDimension(source)) 
            setAccountData(account, "s.rot", getElementRotation(source)) 
            setAccountData(account, "s.weap0", getPedWeapon(source, 0)) 
            setAccountData(account, "s.weap1", getPedWeapon(source, 1)) 
            setAccountData(account, "s.weap2", getPedWeapon(source, 2)) 
            setAccountData(account, "s.weap3", getPedWeapon(source, 3)) 
            setAccountData(account, "s.weap4", getPedWeapon(source, 4)) 
            setAccountData(account, "s.weap5", getPedWeapon(source, 5)) 
            setAccountData(account, "s.weap6", getPedWeapon(source, 6)) 
            setAccountData(account, "s.weap7", getPedWeapon(source, 7)) 
            setAccountData(account, "s.weap8", getPedWeapon(source, -- s8) -->) 
            setAccountData(account, "s.weap9", getPedWeapon(source, 9)) 
            setAccountData(account, "s.weap10", getPedWeapon(source, 10)) 
            setAccountData(account, "s.weap11", getPedWeapon(source, 11)) 
            setAccountData(account, "s.weap12", getPedWeapon(source, 12)) 
            setAccountData(account, "s.ammo0", getPedTotalAmmo(source, 0)) 
            setAccountData(account, "s.ammo1", getPedTotalAmmo(source, 1)) 
            setAccountData(account, "s.ammo2", getPedTotalAmmo(source, 2)) 
            setAccountData(account, "s.ammo3", getPedTotalAmmo(source, 3)) 
            setAccountData(account, "s.ammo4", getPedTotalAmmo(source, 4)) 
            setAccountData(account, "s.ammo5", getPedTotalAmmo(source, 5)) 
            setAccountData(account, "s.ammo6", getPedTotalAmmo(source, 6)) 
            setAccountData(account, "s.ammo7", getPedTotalAmmo(source, 7)) 
            setAccountData(account, "s.ammo8", getPedTotalAmmo(source, -- s8) -->) 
            setAccountData(account, "s.ammo9", getPedTotalAmmo(source, 9)) 
            setAccountData(account, "s.ammo10", getPedTotalAmmo(source, 10)) 
            setAccountData(account, "s.ammo11", getPedTotalAmmo(source, 11)) 
            setAccountData(account, "s.ammo12", getPedTotalAmmo(source, 12)) 
       end 
   end 
end 
addEventHandler("onPlayerQuit", getRootElement(), onQuit) 
addEventHandler("onPlayerWasted", getRootElement(), onQuit) 
  
function onLogin(thePreviousAccount, theCurrentAccount, autoLogin) 
   if not (isGuestAccount(getPlayerAccount(source))) then 
       local accountData = getAccountData(theCurrentAccount, "s.HandMoney") 
       if (accountData) then 
            local playerMoney = getAccountData(theCurrentAccount, "s.HandMoney") 
            local playerSkin = getAccountData(theCurrentAccount, "s.skin") 
            local playerHealth = getAccountData(theCurrentAccount, "s.health") 
            local playerArmor = getAccountData(theCurrentAccount, "s.armor") 
            local playerX = getAccountData(theCurrentAccount, "s.x") 
            local playerY = getAccountData(theCurrentAccount, "s.y") 
            local playerZ = getAccountData(theCurrentAccount, "s.z") 
            local playerRot = getAccountData(theCurrentAccount, "s.rot") 
            local playerInt = getAccountData(theCurrentAccount, "s.int") 
            local playerDim = getAccountData(theCurrentAccount, "s.dim") 
            local weap0 = getAccountData(theCurrentAccount, "s.weap0") 
            local weap1 = getAccountData(theCurrentAccount, "s.weap1") 
            local weap2 = getAccountData(theCurrentAccount, "s.weap2") 
            local weap3 = getAccountData(theCurrentAccount, "s.weap3") 
            local weap4 = getAccountData(theCurrentAccount, "s.weap4") 
            local weap5 = getAccountData(theCurrentAccount, "s.weap5") 
            local weap6 = getAccountData(theCurrentAccount, "s.weap6") 
            local weap7 = getAccountData(theCurrentAccount, "s.weap7") 
            local weap8 = getAccountData(theCurrentAccount, "s.weap8") 
            local weap9 = getAccountData(theCurrentAccount, "s.weap9") 
            local weap10 = getAccountData(theCurrentAccount, "s.weap10") 
            local weap11 = getAccountData(theCurrentAccount, "s.weap11") 
            local weap12 = getAccountData(theCurrentAccount, "s.weap12") 
            local ammo0 = getAccountData(theCurrentAccount, "s.ammo0") 
            local ammo1 = getAccountData(theCurrentAccount, "s.ammo1") 
            local ammo2 = getAccountData(theCurrentAccount, "s.ammo2") 
            local ammo3 = getAccountData(theCurrentAccount, "s.ammo3") 
            local ammo4 = getAccountData(theCurrentAccount, "s.ammo4") 
            local ammo5 = getAccountData(theCurrentAccount, "s.ammo5") 
            local ammo6 = getAccountData(theCurrentAccount, "s.ammo6") 
            local ammo7 = getAccountData(theCurrentAccount, "s.ammo7") 
            local ammo8 = getAccountData(theCurrentAccount, "s.ammo8") 
            local ammo9 = getAccountData(theCurrentAccount, "s.ammo9") 
            local ammo10 = getAccountData(theCurrentAccount, "s.ammo10") 
            local ammo11 = getAccountData(theCurrentAccount, "s.ammo11") 
            local ammo12 = getAccountData(theCurrentAccount, "s.ammo12") 
            setPlayerMoney(source, playerMoney) 
            setElementHealth(source, playerHealth) 
            setPedArmor(source, playerArmor) 
            spawnPlayer(source, playerX, playerY, playerZ+1, playerRot, playerSkin, playerInt, playerDim) 
            fadeCamera(source, true, 2.0) 
            setCameraTarget(source, source) 
            giveWeapon(source, weap0, ammo0, true) 
            giveWeapon(source, weap1, ammo1, false) 
            giveWeapon(source, weap2, ammo2, false) 
            giveWeapon(source, weap3, ammo3, false) 
            giveWeapon(source, weap4, ammo4, false) 
            giveWeapon(source, weap5, ammo5, false) 
            giveWeapon(source, weap6, ammo6, false) 
            giveWeapon(source, weap7, ammo7, false) 
            giveWeapon(source, weap8, ammo8, false) 
            giveWeapon(source, weap9, ammo9, false) 
            giveWeapon(source, weap10, ammo10, false) 
            giveWeapon(source, weap11, ammo11, false) 
            giveWeapon(source, weap12, ammo12, false) 
       else 
            spawnPlayer(source, 2485, -1665, 13.5, 0, 0, 0, 0) 
            fadeCamera(source, true, 2.0) 
            setCameraTarget(source, source) 
       end 
   end 
end 
addEventHandler("onPlayerLogin", getRootElement(), onLogin) 

Error : 89: Bad argument @ 'setElementHealth' [Expected number at argument 2, got boolean]

Error : 90: Bad argument @ 'setPedArmor' [Expected number at argument 2, got boolean]

Error : 94: Bad argument @ 'giveWeapon' [Expected number at argument 3, got boolean]

Error : 95: Bad argument @ 'giveWeapon' [Expected number at argument 3, got boolean]

Error : 104: Bad argument @ 'giveWeapon' [Expected number at argument 3, got boolean]

Error : 105: Bad argument @ 'giveWeapon' [Expected number at argument 3, got boolean]

Error : 106: Bad argument @ 'giveWeapon' [Expected number at argument 3, got boolean]

Still shows this error when a newly registered accounts logged in. And doesnt spawn exactly on spawnPlayer coordinates.

Link to comment
local default = { 
interior = 0, 
dimension = 0, 
skin = 0, 
x = 0, 
y = 0, 
z = 5, 
rot = 90, 
} 
  
function onPlayerQuit ( ) 
      local playeraccount = getPlayerAccount ( source ) 
      if ( playeraccount ) then 
            local x,y,z = getElementPosition (source) 
            setAccountData ( playeraccount, "s.HandMoney", getPlayerMoney ( source ) ) 
            setAccountData (playeraccount, "s.skin", tostring (getPedSkin (source))) 
            setAccountData (playeraccount, "s.x", x) 
            setAccountData (playeraccount, "s.y", y) 
            setAccountData (playeraccount, "s.z", z) 
            setAccountData (playeraccount, "s.int", getElementInterior (source)) 
            setAccountData (playeraccount, "s.dim", getElementDimension (source)) 
            setAccountData (playeraccount, "s.rot", getPedRotation (source)) 
            setAccountData (playeraccount, "s.weap0", getPedWeapon ( source, 0 )) 
            setAccountData (playeraccount, "s.weap1", getPedWeapon ( source, 1 )) 
            setAccountData (playeraccount, "s.weap2", getPedWeapon ( source, 2 )) 
            setAccountData (playeraccount, "s.ammo2", getPedTotalAmmo ( source, 2 )) 
            setAccountData (playeraccount, "s.weap3", getPedWeapon ( source, 3 )) 
            setAccountData (playeraccount, "s.ammo3", getPedTotalAmmo ( source, 3 )) 
            setAccountData (playeraccount, "s.weap4", getPedWeapon ( source, 4 )) 
            setAccountData (playeraccount, "s.ammo4", getPedTotalAmmo ( source, 4 )) 
            setAccountData (playeraccount, "s.weap5", getPedWeapon ( source, 5 )) 
            setAccountData (playeraccount, "s.ammo5", getPedTotalAmmo ( source, 5 )) 
            setAccountData (playeraccount, "s.weap6", getPedWeapon ( source, 6 )) 
            setAccountData (playeraccount, "s.ammo6", getPedTotalAmmo ( source, 6 )) 
            setAccountData (playeraccount, "s.weap7", getPedWeapon ( source, 7 )) 
            setAccountData (playeraccount, "s.ammo7", getPedTotalAmmo ( source, 7 )) 
            setAccountData (playeraccount, "s.weap8", getPedWeapon ( source, 8 )) 
            setAccountData (playeraccount, "s.ammo8", getPedTotalAmmo ( source, 8 )) 
            setAccountData (playeraccount, "s.weap9", getPedWeapon ( source, 9 )) 
            setAccountData (playeraccount, "s.ammo9", getPedTotalAmmo ( source, 9 )) 
            setAccountData (playeraccount, "s.weap10", getPedWeapon ( source, 10 )) 
            setAccountData (playeraccount, "s.weap11", getPedWeapon ( source, 11 )) 
            setAccountData (playeraccount, "s.weap12", getPedWeapon ( source, 12 )) 
      end 
end 
addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) 
  
local root = getRootElement() 
addEventHandler("onPlayerLogin", root, 
  function() 
     local playeraccount = getPlayerAccount ( source ) 
      if ( playeraccount ) then 
            local playermoney = getAccountData ( playeraccount, "s.HandMoney" ) 
            if ( playermoney ) then 
                  setPlayerMoney ( source, playermoney ) 
            end 
            local playerInt = getAccountData (playeraccount, "s.int") or default.interior 
            local playerDim = getAccountData (playeraccount, "s.dim") or default.dimension 
            local playerSkin = getAccountData (playeraccount, "s.skin") or default. 
            local playerX = getAccountData (playeraccount, "s.x") or default.x 
            local playerY = getAccountData (playeraccount, "s.y") or default.y 
            local playerZ = getAccountData (playeraccount, "s.z") or default.z 
            local playerRot = getAccountData (playeraccount, "s.rot") or default.rot 
            spawnPlayer(source, playerX, playerY, playerZ, playerRot, playerSkin, playerInt, playerDim) 
            fadeCamera (source, true) 
            setCameraTarget (source, source) 
            local weap0 = getAccountData(playeraccount, "s.weap0") 
            local weap1 = getAccountData(playeraccount, "s.weap1") 
            local weap2 = getAccountData(playeraccount, "s.weap2") 
            local ammo2 = getAccountData(playeraccount, "s.ammo2") 
            local weap3 = getAccountData(playeraccount, "s.weap3") 
            local ammo3 = getAccountData(playeraccount, "s.ammo3") 
            local weap4 = getAccountData(playeraccount, "s.weap4") 
            local ammo4 = getAccountData(playeraccount, "s.ammo4") 
            local weap5 = getAccountData(playeraccount, "s.weap5") 
            local ammo5 = getAccountData(playeraccount, "s.ammo5") 
            local weap6 = getAccountData(playeraccount, "s.weap6") 
            local ammo6 = getAccountData(playeraccount, "s.ammo6") 
            local weap7 = getAccountData(playeraccount, "s.weap7") 
            local ammo7 = getAccountData(playeraccount, "s.ammo7") 
            local weap8 = getAccountData(playeraccount, "s.weap8") 
            local ammo8 = getAccountData(playeraccount, "s.ammo8") 
            local weap9 = getAccountData(playeraccount, "s.weap9") 
            local ammo9 = getAccountData(playeraccount, "s.ammo9") 
            local weap10 = getAccountData(playeraccount, "s.weap10") 
            local weap11 = getAccountData(playeraccount, "s.weap11") 
            local weap12 = getAccountData(playeraccount, "s.weap12") 
            if ( weap2 ) then 
            giveWeapon ( source, weap0, 1 ) 
            end 
            if ( weap2 ) then 
            giveWeapon ( source, weap1, 1 ) 
            end 
            if ( weap2 ) then 
            giveWeapon ( source, weap2, ammo2 ) 
            end 
            if ( weap3 ) then 
            giveWeapon ( source, weap3, ammo3 ) 
            end 
            if ( weap4 ) then 
            giveWeapon ( source, weap4, ammo4 ) 
            end 
            if ( weap5 ) then 
            giveWeapon ( source, weap5, ammo5 ) 
            end 
            if ( weap6 ) then 
            giveWeapon ( source, weap6, ammo6 ) 
            end 
            if ( weap7 ) then 
            giveWeapon ( source, weap7, ammo7 ) 
            end 
            if ( weap8 ) then 
            giveWeapon ( source, weap8, ammo8 ) 
            end 
            if ( weap9 ) then 
            giveWeapon ( source, weap9, ammo9 ) 
            end 
            if ( weap2 ) then 
            giveWeapon ( source, weap10, 1 ) 
            end 
            if ( weap2 ) then 
            giveWeapon ( source, weap11, 1 ) 
            end 
            if ( weap2 ) then 
            giveWeapon ( source, weap12, 1 )        
            end 
      end 
  end 
) 

Link to comment
function onQuit(quitType, reason, resposibleElement) 
    if not (isGuestAccount(getPlayerAccount(source))) then 
        local account = getPlayerAccount(source) 
        if (account) then 
            local x, y, z = getElementPosition(source) 
            setAccountData(account, "s.HandMoney", tostring(getPlayerMoney(source))) 
            setAccountData(account, "s.skin", tostring(getPedSkin(source))) 
            setAccountData(account , "s.health", tostring(getElementHealth(source))) 
            setAccountData(account, "s.armor", tostring(getPedArmor(source))) 
            setAccountData(account, "s.x", x) 
            setAccountData(account, "s.y", y) 
            setAccountData(account, "s.z", z) 
            setAccountData(account, "s.int", getElementInterior(source)) 
            setAccountData(account, "s.dim", getElementDimension(source)) 
            setAccountData(account, "s.rot", getElementRotation(source)) 
            setAccountData(account, "s.weap0", getPedWeapon(source, 0)) 
            setAccountData(account, "s.weap1", getPedWeapon(source, 1)) 
            setAccountData(account, "s.weap2", getPedWeapon(source, 2)) 
            setAccountData(account, "s.weap3", getPedWeapon(source, 3)) 
            setAccountData(account, "s.weap4", getPedWeapon(source, 4)) 
            setAccountData(account, "s.weap5", getPedWeapon(source, 5)) 
            setAccountData(account, "s.weap6", getPedWeapon(source, 6)) 
            setAccountData(account, "s.weap7", getPedWeapon(source, 7)) 
            setAccountData(account, "s.weap8", getPedWeapon(source, -- s8) -->) 
            setAccountData(account, "s.weap9", getPedWeapon(source, 9)) 
            setAccountData(account, "s.weap10", getPedWeapon(source, 10)) 
            setAccountData(account, "s.weap11", getPedWeapon(source, 11)) 
            setAccountData(account, "s.weap12", getPedWeapon(source, 12)) 
            setAccountData(account, "s.ammo0", getPedTotalAmmo(source, 0)) 
            setAccountData(account, "s.ammo1", getPedTotalAmmo(source, 1)) 
            setAccountData(account, "s.ammo2", getPedTotalAmmo(source, 2)) 
            setAccountData(account, "s.ammo3", getPedTotalAmmo(source, 3)) 
            setAccountData(account, "s.ammo4", getPedTotalAmmo(source, 4)) 
            setAccountData(account, "s.ammo5", getPedTotalAmmo(source, 5)) 
            setAccountData(account, "s.ammo6", getPedTotalAmmo(source, 6)) 
            setAccountData(account, "s.ammo7", getPedTotalAmmo(source, 7)) 
            setAccountData(account, "s.ammo8", getPedTotalAmmo(source, -- s8) -->) 
            setAccountData(account, "s.ammo9", getPedTotalAmmo(source, 9)) 
            setAccountData(account, "s.ammo10", getPedTotalAmmo(source, 10)) 
            setAccountData(account, "s.ammo11", getPedTotalAmmo(source, 11)) 
            setAccountData(account, "s.ammo12", getPedTotalAmmo(source, 12)) 
       end 
   end 
end 
addEventHandler("onPlayerQuit", getRootElement(), onQuit) 
addEventHandler("onPlayerWasted", getRootElement(), onQuit) 
  
function onLogin(thePreviousAccount, theCurrentAccount, autoLogin) 
   if not (isGuestAccount(getPlayerAccount(source))) then 
       local accountData = getAccountData(theCurrentAccount, "s.HandMoney") 
       if (accountData) then 
            local playerMoney = getAccountData(theCurrentAccount, "s.HandMoney") 
            local playerSkin = getAccountData(theCurrentAccount, "s.skin") 
            local playerHealth = getAccountData(theCurrentAccount, "s.health") 
            local playerArmor = getAccountData(theCurrentAccount, "s.armor") 
            local playerX = getAccountData(theCurrentAccount, "s.x") 
            local playerY = getAccountData(theCurrentAccount, "s.y") 
            local playerZ = getAccountData(theCurrentAccount, "s.z") 
            local playerRot = getAccountData(theCurrentAccount, "s.rot") 
            local playerInt = getAccountData(theCurrentAccount, "s.int") 
            local playerDim = getAccountData(theCurrentAccount, "s.dim") 
            local weap0 = getAccountData(theCurrentAccount, "s.weap0") 
            local weap1 = getAccountData(theCurrentAccount, "s.weap1") 
            local weap2 = getAccountData(theCurrentAccount, "s.weap2") 
            local weap3 = getAccountData(theCurrentAccount, "s.weap3") 
            local weap4 = getAccountData(theCurrentAccount, "s.weap4") 
            local weap5 = getAccountData(theCurrentAccount, "s.weap5") 
            local weap6 = getAccountData(theCurrentAccount, "s.weap6") 
            local weap7 = getAccountData(theCurrentAccount, "s.weap7") 
            local weap8 = getAccountData(theCurrentAccount, "s.weap8") 
            local weap9 = getAccountData(theCurrentAccount, "s.weap9") 
            local weap10 = getAccountData(theCurrentAccount, "s.weap10") 
            local weap11 = getAccountData(theCurrentAccount, "s.weap11") 
            local weap12 = getAccountData(theCurrentAccount, "s.weap12") 
            local ammo0 = getAccountData(theCurrentAccount, "s.ammo0") 
            local ammo1 = getAccountData(theCurrentAccount, "s.ammo1") 
            local ammo2 = getAccountData(theCurrentAccount, "s.ammo2") 
            local ammo3 = getAccountData(theCurrentAccount, "s.ammo3") 
            local ammo4 = getAccountData(theCurrentAccount, "s.ammo4") 
            local ammo5 = getAccountData(theCurrentAccount, "s.ammo5") 
            local ammo6 = getAccountData(theCurrentAccount, "s.ammo6") 
            local ammo7 = getAccountData(theCurrentAccount, "s.ammo7") 
            local ammo8 = getAccountData(theCurrentAccount, "s.ammo8") 
            local ammo9 = getAccountData(theCurrentAccount, "s.ammo9") 
            local ammo10 = getAccountData(theCurrentAccount, "s.ammo10") 
            local ammo11 = getAccountData(theCurrentAccount, "s.ammo11") 
            local ammo12 = getAccountData(theCurrentAccount, "s.ammo12") 
            setPlayerMoney(source, playerMoney) 
            setElementHealth(source, playerHealth) 
            setPedArmor(source, playerArmor) 
            spawnPlayer(source, playerX, playerY, playerZ+1, playerRot, playerSkin, playerInt, playerDim) 
            fadeCamera(source, true, 2.0) 
            setCameraTarget(source, source) 
            giveWeapon(source, weap0, ammo0, true) 
            giveWeapon(source, weap1, ammo1, false) 
            giveWeapon(source, weap2, ammo2, false) 
            giveWeapon(source, weap3, ammo3, false) 
            giveWeapon(source, weap4, ammo4, false) 
            giveWeapon(source, weap5, ammo5, false) 
            giveWeapon(source, weap6, ammo6, false) 
            giveWeapon(source, weap7, ammo7, false) 
            giveWeapon(source, weap8, ammo8, false) 
            giveWeapon(source, weap9, ammo9, false) 
            giveWeapon(source, weap10, ammo10, false) 
            giveWeapon(source, weap11, ammo11, false) 
            giveWeapon(source, weap12, ammo12, false) 
       else 
            spawnPlayer(source, 2485, -1665, 13.5, 0, 0, 0, 0) 
            fadeCamera(source, true, 2.0) 
            setCameraTarget(source, source) 
       end 
   end 
end 
addEventHandler("onPlayerLogin", getRootElement(), onLogin) 

Error : 89: Bad argument @ 'setElementHealth' [Expected number at argument 2, got boolean]

Error : 90: Bad argument @ 'setPedArmor' [Expected number at argument 2, got boolean]

Error : 94: Bad argument @ 'giveWeapon' [Expected number at argument 3, got boolean]

Error : 95: Bad argument @ 'giveWeapon' [Expected number at argument 3, got boolean]

Error : 104: Bad argument @ 'giveWeapon' [Expected number at argument 3, got boolean]

Error : 105: Bad argument @ 'giveWeapon' [Expected number at argument 3, got boolean]

Error : 106: Bad argument @ 'giveWeapon' [Expected number at argument 3, got boolean]

Still shows this error when a newly registered accounts logged in. And doesnt spawn exactly on spawnPlayer coordinates.

Link to comment

Instead of setting every value invidually, I suggest using JSON to save the trouble and make it a little bit cleaner. Try the following, I tested it and seems to work just fine.

function saveAccount( account ) 
    local account = eventName == "onPlayerLogout" and account or getPlayerAccount( source ) 
     
    if ( account ) and ( not isGuestAccount( account ) ) then 
        local x, y, z = getElementPosition( source ) 
        local _, _, rotation = getElementRotation( source ) 
        local position = { skin = getElementModel( source ), x = x, y = y, z = z, interior = getElementInterior( source ), dimension = getElementDimension( source ), rotation = rotation } 
        local stats = { money = getPlayerMoney( source ), health = getElementHealth( source ), armor = getPedArmor( source ) } 
        local weapons = { } 
         
        for i = 0, 12 do 
            weapons[ i ] = { weapon = getPedWeapon( source ), ammo = getPedTotalAmmo( source, i ) } 
        end 
         
        setAccountData( account, "account.position", toJSON( position ) ) 
        setAccountData( account, "account.stats", toJSON( stats ) ) 
        setAccountData( account, "account.weapons", toJSON( weapons ) ) 
    end 
end 
addEventHandler( "onPlayerQuit", root, saveAccount ) 
addEventHandler( "onPlayerWasted", root, saveAccount ) 
addEventHandler( "onPlayerLogout", root, saveAccount ) 
  
addEventHandler( "onPlayerLogin", root, 
    function( _, account ) 
        local position = getAccountData( account, "account.position" ) 
         
        if ( position ) then 
            position = fromJSON( position ) 
             
            spawnPlayer( source, position.x, position.y, position.z, position.rotation, position.skin, position.interior, position.dimension ) 
        else 
            spawnPlayer( source, 2485, -1665, 13.5, 0, 0, 0, 0 ) 
        end 
         
        setCameraTarget( source, source ) 
        fadeCamera( source, true, 2.0 ) 
         
        local stats = getAccountData( account, "account.stats" ) 
         
        if ( stats ) then 
            stats = fromJSON( stats ) 
             
            setElementHealth( source, stats.health ) 
            setPedArmor( source, stats.armor ) 
            setPlayerMoney( source, stats.money ) 
        end 
         
        local weapons = getAccountData( account, "account.weapons" ) 
         
        if ( weapons ) then 
            weapons = fromJSON( weapons ) 
             
            for i, data in pairs( weapons ) do 
                giveWeapon( source, data.weapon, data.ammo, false ) 
            end 
        end 
    end 
) 

  • Thanks 1
Link to comment
function onLogin(thePreviousAccount, theCurrentAccount, autoLogin) 
    if not (isGuestAccount(getPlayerAccount(source))) then  
        local accountData = getAccountData(theCurrentAccount, "s.HandMoney") 
        if (accountData) then 
            local playerMoney = getAccountData(theCurrentAccount, "s.HandMoney") 
            local playerSkin = getAccountData(theCurrentAccount, "s.skin") 
            local playerHealth = getAccountData(theCurrentAccount, "s.health") 
            local playerArmor = getAccountData(theCurrentAccount, "s.armor") 
            local playerX = getAccountData(theCurrentAccount, "s.x") 
            local playerY = getAccountData(theCurrentAccount, "s.y") 
            local playerZ = getAccountData(theCurrentAccount, "s.z") 
            local playerRot = getAccountData(theCurrentAccount, "s.rot") 
            local playerInt = getAccountData(theCurrentAccount, "s.int") 
            local playerDim = getAccountData(theCurrentAccount, "s.dim") 
            local playerWanted = getAccountData(theCurrentAccount, "s.wantedlevel") 
            local weap0 = getAccountData(theCurrentAccount, "s.weap0") 
            local weap1 = getAccountData(theCurrentAccount, "s.weap1") 
            local weap2 = getAccountData(theCurrentAccount, "s.weap2") 
            local weap3 = getAccountData(theCurrentAccount, "s.weap3") 
            local weap4 = getAccountData(theCurrentAccount, "s.weap4") 
            local weap5 = getAccountData(theCurrentAccount, "s.weap5") 
            local weap6 = getAccountData(theCurrentAccount, "s.weap6") 
            local weap7 = getAccountData(theCurrentAccount, "s.weap7") 
            local weap8 = getAccountData(theCurrentAccount, "s.weap8") 
            local weap9 = getAccountData(theCurrentAccount, "s.weap9") 
            local weap10 = getAccountData(theCurrentAccount, "s.weap10") 
            local weap11 = getAccountData(theCurrentAccount, "s.weap11") 
            local weap12 = getAccountData(theCurrentAccount, "s.weap12") 
            local ammo0 = getAccountData(theCurrentAccount, "s.ammo0") 
            local ammo1 = getAccountData(theCurrentAccount, "s.ammo1") 
            local ammo2 = getAccountData(theCurrentAccount, "s.ammo2") 
            local ammo3 = getAccountData(theCurrentAccount, "s.ammo3") 
            local ammo4 = getAccountData(theCurrentAccount, "s.ammo4") 
            local ammo5 = getAccountData(theCurrentAccount, "s.ammo5") 
            local ammo6 = getAccountData(theCurrentAccount, "s.ammo6") 
            local ammo7 = getAccountData(theCurrentAccount, "s.ammo7") 
            local ammo8 = getAccountData(theCurrentAccount, "s.ammo8") 
            local ammo9 = getAccountData(theCurrentAccount, "s.ammo9") 
            local ammo10 = getAccountData(theCurrentAccount, "s.ammo10") 
            local ammo11 = getAccountData(theCurrentAccount, "s.ammo11") 
            local ammo12 = getAccountData(theCurrentAccount, "s.ammo12") 
            setPlayerMoney(source, playerMoney) 
            setTimer(setElementHealth, 500, 1, source, playerHealth) 
            setTimer(setPedArmor, 500, 1, source, playerArmor) 
            setTimer(setPlayerWantedLevel, 1500, 1, source, playerWanted) 
            spawnPlayer(source, playerX, playerY, playerZ+1, playerRot, playerSkin, playerInt, playerDim) 
            fadeCamera(source, true, 2.0) 
            setCameraTarget(source, source) 
            giveWeapon(source, weap0, ammo0, true) 
            giveWeapon(source, weap1, ammo1, false) 
            giveWeapon(source, weap2, ammo2, false) 
            giveWeapon(source, weap3, ammo3, false) 
            giveWeapon(source, weap4, ammo4, false) 
            giveWeapon(source, weap5, ammo5, false) 
            giveWeapon(source, weap6, ammo6, false) 
            giveWeapon(source, weap7, ammo7, false) 
            giveWeapon(source, weap8, ammo8, false) 
            giveWeapon(source, weap9, ammo9, false) 
            giveWeapon(source, weap10, ammo10, false) 
            giveWeapon(source, weap11, ammo11, false) 
            giveWeapon(source, weap12, ammo12, false) 
        else 
           spawnPlayer(source, 2485, -1665, 13.5, 0, 0, 0, 0) 
           fadeCamera(source, true, 2.0) 
           setCameraTarget(source, source) 
        end 
    end 
end 
addEventHandler("onPlayerLogin", getRootElement(), onLogin) 
  
function onLogout() 
    kickPlayer(source, nil, "disallowed logout.") 
end 
addEventHandler("onPlayerLogout", getRootElement(), onLogout) 
  
function onQuit(quitTupe, reason, resposibleElement) 
    if not (isGuestAccount(getPlayerAccount(source))) then 
       local account = getPlayerAccount(source) 
       if (account) then 
          local x, y, z = getElementPosition(source) 
          setAccountData(account, "s.HandMoney", tostring(getPlayerMoney(source))) 
          setAccountData(account, "s.skin", tostring(getPedSkin(source))) 
          setAccountData(account, "s.health", tostring(getElementHealth(source))) 
          setAccountData(account, "s.armor", tostring(getPedArmor(source))) 
          setAccountData(account, "s.x", x) 
          setAccountData(account, "s.y", y) 
          setAccountData(account, "s.z", z) 
          setAccountData(account, "s.rot", getElementRotation(source)) 
          setAccountData(account, "s.int", getElementInterior(source)) 
          setAccountData(account, "s.dim", getElementDimension(source)) 
          setAccountData(account, "s.wantedlevel", getPlayerWantedLevel(source)) 
          setAccountData(account, "s.weap0", getPedWeapon(source, 0)) 
          setAccountData(account, "s.weap1", getPedWeapon(source, 1)) 
          setAccountData(account, "s.weap2", getPedWeapon(source, 2)) 
          setAccountData(account, "s.weap3", getPedWeapon(source, 3)) 
          setAccountData(account, "s.weap4", getPedWeapon(source, 4)) 
          setAccountData(account, "s.weap5", getPedWeapon(source, 5)) 
          setAccountData(account, "s.weap6", getPedWeapon(source, 6)) 
          setAccountData(account, "s.weap7", getPedWeapon(source, 7)) 
          setAccountData(account, "s.weap8", getPedWeapon(source, 8)) 
          setAccountData(account, "s.weap9", getPedWeapon(source, 9)) 
          setAccountData(account, "s.weap10", getPedWeapon(source, 10)) 
          setAccountData(account, "s.weap11", getPedWeapon(source, 11)) 
          setAccountData(account, "s.weap12", getPedWeapon(source, 12)) 
          setAccountData(account, "s.ammo0", getPedTotalAmmo(source, 0)) 
          setAccountData(account, "s.ammo1", getPedTotalAmmo(source, 1)) 
          setAccountData(account, "s.ammo2", getPedTotalAmmo(source, 2)) 
          setAccountData(account, "s.ammo3", getPedTotalAmmo(source, 3)) 
          setAccountData(account, "s.ammo4", getPedTotalAmmo(source, 4)) 
          setAccountData(account, "s.ammo5", getPedTotalAmmo(source, 5)) 
          setAccountData(account, "s.ammo6", getPedTotalAmmo(source, 6)) 
          setAccountData(account, "s.ammo7", getPedTotalAmmo(source, 7)) 
          setAccountData(account, "s.ammo8", getPedTotalAmmo(source, 8)) 
          setAccountData(account, "s.ammo9", getPedTotalAmmo(source, 9)) 
          setAccountData(account, "s.ammo10", getPedTotalAmmo(source, 10)) 
          setAccountData(account, "s.ammo11", getPedTotalAmmo(source, 11)) 
          setAccountData(account, "s.ammo12", getPedTotalAmmo(source, 12)) 
        end 
    end 
end 
addEventHandler("onPlayerQuit", getRootElement(), onQuit) 
  
function onWasted(killer, weapon, ammo, bodypart) 
    if not (isGuestAccount(getPlayerAccount(source))) then 
        fadeCamera(source, false) 
        setTimer(spawnPlayer, 1500, 1, source, x, y, z, , getPedSkin(source), 0, 0) 
        setTimer(fadeCamera, 2000, 1, source, true) 
        setTimer(setCameraTarget, 2000, 1, source, source) 
        takeAllWeapons(source) 
    end 
end 
addEventHandler("onPlayerWasted", getRootElement(), onWasted) 

in x, y, z and rot put there you want spawn onWasted

Link to comment
function onLogin(thePreviousAccount, theCurrentAccount, autoLogin) 
    if not (isGuestAccount(getPlayerAccount(source))) then  
        local accountData = getAccountData(theCurrentAccount, "s.HandMoney") 
        if (accountData) then 
            local playerMoney = getAccountData(theCurrentAccount, "s.HandMoney") 
            local playerSkin = getAccountData(theCurrentAccount, "s.skin") 
            local playerHealth = getAccountData(theCurrentAccount, "s.health") 
            local playerArmor = getAccountData(theCurrentAccount, "s.armor") 
            local playerX = getAccountData(theCurrentAccount, "s.x") 
            local playerY = getAccountData(theCurrentAccount, "s.y") 
            local playerZ = getAccountData(theCurrentAccount, "s.z") 
            local playerRot = getAccountData(theCurrentAccount, "s.rot") 
            local playerInt = getAccountData(theCurrentAccount, "s.int") 
            local playerDim = getAccountData(theCurrentAccount, "s.dim") 
            local playerWanted = getAccountData(theCurrentAccount, "s.wantedlevel") 
            local weap0 = getAccountData(theCurrentAccount, "s.weap0") 
            local weap1 = getAccountData(theCurrentAccount, "s.weap1") 
            local weap2 = getAccountData(theCurrentAccount, "s.weap2") 
            local weap3 = getAccountData(theCurrentAccount, "s.weap3") 
            local weap4 = getAccountData(theCurrentAccount, "s.weap4") 
            local weap5 = getAccountData(theCurrentAccount, "s.weap5") 
            local weap6 = getAccountData(theCurrentAccount, "s.weap6") 
            local weap7 = getAccountData(theCurrentAccount, "s.weap7") 
            local weap8 = getAccountData(theCurrentAccount, "s.weap8") 
            local weap9 = getAccountData(theCurrentAccount, "s.weap9") 
            local weap10 = getAccountData(theCurrentAccount, "s.weap10") 
            local weap11 = getAccountData(theCurrentAccount, "s.weap11") 
            local weap12 = getAccountData(theCurrentAccount, "s.weap12") 
            local ammo0 = getAccountData(theCurrentAccount, "s.ammo0") 
            local ammo1 = getAccountData(theCurrentAccount, "s.ammo1") 
            local ammo2 = getAccountData(theCurrentAccount, "s.ammo2") 
            local ammo3 = getAccountData(theCurrentAccount, "s.ammo3") 
            local ammo4 = getAccountData(theCurrentAccount, "s.ammo4") 
            local ammo5 = getAccountData(theCurrentAccount, "s.ammo5") 
            local ammo6 = getAccountData(theCurrentAccount, "s.ammo6") 
            local ammo7 = getAccountData(theCurrentAccount, "s.ammo7") 
            local ammo8 = getAccountData(theCurrentAccount, "s.ammo8") 
            local ammo9 = getAccountData(theCurrentAccount, "s.ammo9") 
            local ammo10 = getAccountData(theCurrentAccount, "s.ammo10") 
            local ammo11 = getAccountData(theCurrentAccount, "s.ammo11") 
            local ammo12 = getAccountData(theCurrentAccount, "s.ammo12") 
            setPlayerMoney(source, playerMoney) 
            setTimer(setElementHealth, 500, 1, source, playerHealth) 
            setTimer(setPedArmor, 500, 1, source, playerArmor) 
            setTimer(setPlayerWantedLevel, 1500, 1, source, playerWanted) 
            spawnPlayer(source, playerX, playerY, playerZ+1, playerRot, playerSkin, playerInt, playerDim) 
            fadeCamera(source, true, 2.0) 
            setCameraTarget(source, source) 
            giveWeapon(source, weap0, ammo0, true) 
            giveWeapon(source, weap1, ammo1, false) 
            giveWeapon(source, weap2, ammo2, false) 
            giveWeapon(source, weap3, ammo3, false) 
            giveWeapon(source, weap4, ammo4, false) 
            giveWeapon(source, weap5, ammo5, false) 
            giveWeapon(source, weap6, ammo6, false) 
            giveWeapon(source, weap7, ammo7, false) 
            giveWeapon(source, weap8, ammo8, false) 
            giveWeapon(source, weap9, ammo9, false) 
            giveWeapon(source, weap10, ammo10, false) 
            giveWeapon(source, weap11, ammo11, false) 
            giveWeapon(source, weap12, ammo12, false) 
        else 
           spawnPlayer(source, 2485, -1665, 13.5, 0, 0, 0, 0) 
           fadeCamera(source, true, 2.0) 
           setCameraTarget(source, source) 
        end 
    end 
end 
addEventHandler("onPlayerLogin", getRootElement(), onLogin) 
  
function onLogout() 
    kickPlayer(source, nil, "disallowed logout.") 
end 
addEventHandler("onPlayerLogout", getRootElement(), onLogout) 
  
function onQuit(quitTupe, reason, resposibleElement) 
    if not (isGuestAccount(getPlayerAccount(source))) then 
       local account = getPlayerAccount(source) 
       if (account) then 
          local x, y, z = getElementPosition(source) 
          setAccountData(account, "s.HandMoney", tostring(getPlayerMoney(source))) 
          setAccountData(account, "s.skin", tostring(getPedSkin(source))) 
          setAccountData(account, "s.health", tostring(getElementHealth(source))) 
          setAccountData(account, "s.armor", tostring(getPedArmor(source))) 
          setAccountData(account, "s.x", x) 
          setAccountData(account, "s.y", y) 
          setAccountData(account, "s.z", z) 
          setAccountData(account, "s.rot", getElementRotation(source)) 
          setAccountData(account, "s.int", getElementInterior(source)) 
          setAccountData(account, "s.dim", getElementDimension(source)) 
          setAccountData(account, "s.wantedlevel", getPlayerWantedLevel(source)) 
          setAccountData(account, "s.weap0", getPedWeapon(source, 0)) 
          setAccountData(account, "s.weap1", getPedWeapon(source, 1)) 
          setAccountData(account, "s.weap2", getPedWeapon(source, 2)) 
          setAccountData(account, "s.weap3", getPedWeapon(source, 3)) 
          setAccountData(account, "s.weap4", getPedWeapon(source, 4)) 
          setAccountData(account, "s.weap5", getPedWeapon(source, 5)) 
          setAccountData(account, "s.weap6", getPedWeapon(source, 6)) 
          setAccountData(account, "s.weap7", getPedWeapon(source, 7)) 
          setAccountData(account, "s.weap8", getPedWeapon(source, 8)) 
          setAccountData(account, "s.weap9", getPedWeapon(source, 9)) 
          setAccountData(account, "s.weap10", getPedWeapon(source, 10)) 
          setAccountData(account, "s.weap11", getPedWeapon(source, 11)) 
          setAccountData(account, "s.weap12", getPedWeapon(source, 12)) 
          setAccountData(account, "s.ammo0", getPedTotalAmmo(source, 0)) 
          setAccountData(account, "s.ammo1", getPedTotalAmmo(source, 1)) 
          setAccountData(account, "s.ammo2", getPedTotalAmmo(source, 2)) 
          setAccountData(account, "s.ammo3", getPedTotalAmmo(source, 3)) 
          setAccountData(account, "s.ammo4", getPedTotalAmmo(source, 4)) 
          setAccountData(account, "s.ammo5", getPedTotalAmmo(source, 5)) 
          setAccountData(account, "s.ammo6", getPedTotalAmmo(source, 6)) 
          setAccountData(account, "s.ammo7", getPedTotalAmmo(source, 7)) 
          setAccountData(account, "s.ammo8", getPedTotalAmmo(source, 8)) 
          setAccountData(account, "s.ammo9", getPedTotalAmmo(source, 9)) 
          setAccountData(account, "s.ammo10", getPedTotalAmmo(source, 10)) 
          setAccountData(account, "s.ammo11", getPedTotalAmmo(source, 11)) 
          setAccountData(account, "s.ammo12", getPedTotalAmmo(source, 12)) 
        end 
    end 
end 
addEventHandler("onPlayerQuit", getRootElement(), onQuit) 
  
function onWasted(killer, weapon, ammo, bodypart) 
    if not (isGuestAccount(getPlayerAccount(source))) then 
        fadeCamera(source, false) 
        setTimer(spawnPlayer, 1500, 1, source, x, y, z, , getPedSkin(source), 0, 0) 
        setTimer(fadeCamera, 2000, 1, source, true) 
        setTimer(setCameraTarget, 2000, 1, source, source) 
        takeAllWeapons(source) 
    end 
end 
addEventHandler("onPlayerWasted", getRootElement(), onWasted) 

in x, y, z and rot put there you want spawn onWasted

Your script doesn't work, and besides, why are you kicking people who are trying to log out? Just cancel it or do it some other way, instead of kicking them. I suggest you use my script as a base for your attempt to do that.

Link to comment

The way it works right now, is that whenever you die, log out or quit, it will save your data. Whenever you log in, it will fetch that data and spawn you to that location you were saved at.

If you are using another respawn script, it will never work with the save system. This system does not have a respawn script in it, so obviously that happens. You need to apply that onPlayerWasted event to the same function as onPlayerLogin. You should also set the priority of the event to trigger after the initial save so it doesn't stack up incorrectly.

Link to comment
function saveAccount( account ) 
    local account = eventName == "onPlayerLogout" and account or getPlayerAccount( source ) 
    
    if ( account ) and ( not isGuestAccount( account ) ) then 
        local x, y, z = getElementPosition( source ) 
        local _, _, rotation = getElementRotation( source ) 
        local position = { skin = getElementModel( source ), x = x, y = y, z = z, interior = getElementInterior( source ), dimension = getElementDimension( source ), rotation = rotation } 
        local stats = { money = getPlayerMoney( source ), health = getElementHealth( source ), armor = getPedArmor( source ) } 
        local weapons = { } 
        
        for i = 0, 12 do 
            weapons[ i ] = { weapon = getPedWeapon( source ), ammo = getPedTotalAmmo( source, i ) } 
        end 
        
        setAccountData( account, "account.position", toJSON( position ) ) 
        setAccountData( account, "account.stats", toJSON( stats ) ) 
        setAccountData( account, "account.weapons", toJSON( weapons ) ) 
    end 
end 
addEventHandler( "onPlayerQuit", root, saveAccount ) 
addEventHandler( "onPlayerWasted", root, saveAccount ) 
addEventHandler( "onPlayerLogout", root, saveAccount ) 
  
addEventHandler( "onPlayerLogin", root, 
    function( _, account ) 
        local position = getAccountData( account, "account.position" ) 
        
        if ( position ) then 
            position = fromJSON( position ) 
            
            spawnPlayer( source, position.x, position.y, position.z, position.rotation, position.skin, position.interior, position.dimension ) 
        else 
            spawnPlayer( source, 2485, -1665, 13.5, 0, 0, 0, 0 ) 
        end 
        
        setCameraTarget( source, source ) 
        fadeCamera( source, true, 2.0 ) 
        
        local stats = getAccountData( account, "account.stats" ) 
        
        if ( stats ) then 
            stats = fromJSON( stats ) 
            
            setElementHealth( source, stats.health ) 
            setPedArmor( source, stats.armor ) 
            setPlayerMoney( source, stats.money ) 
        end 
        
        local weapons = getAccountData( account, "account.weapons" ) 
        
        if ( weapons ) then 
            weapons = fromJSON( weapons ) 
            
            for i, data in pairs( weapons ) do 
                giveWeapon( source, data.weapon, data.ammo, false ) 
            end 
        end 
    end 
) 
addEventHandler( "onPlayerWasted", root, 
    function( _, account ) 
        local position = getAccountData( account, "account.position" ) 
        
        if ( position ) then 
            position = fromJSON( position ) 
            
            spawnPlayer( source, position.x, position.y, position.z, position.rotation, position.skin, position.interior, position.dimension ) 
        else 
            spawnPlayer( source, 2485, -1665, 13.5, 0, 0, 0, 0 ) 
        end 
        
        setCameraTarget( source, source ) 
        fadeCamera( source, true, 2.0 ) 
        
        local stats = getAccountData( account, "account.stats" ) 
        
        if ( stats ) then 
            stats = fromJSON( stats ) 
            
            setElementHealth( source, stats.health ) 
            setPedArmor( source, stats.armor ) 
            setPlayerMoney( source, stats.money ) 
        end 
        
        local weapons = getAccountData( account, "account.weapons" ) 
        
        if ( weapons ) then 
            weapons = fromJSON( weapons ) 
            
            for i, data in pairs( weapons ) do 
                giveWeapon( source, data.weapon, data.ammo, false ) 
            end 
        end 
    end 
) 

Ive added an event where onPlayerWasted happens. But doesnt still load weapons, skins. etc.

Error :62: 75: 85: Bad Argument @ 'getAccountData' [Expected account at argument 1, got ped]

Link to comment
function saveAccount( account ) 
    local account = eventName == "onPlayerLogout" and account or getPlayerAccount( source ) 
    
    if ( account ) and ( not isGuestAccount( account ) ) then 
        local x, y, z = getElementPosition( source ) 
        local _, _, rotation = getElementRotation( source ) 
        local position = { skin = getElementModel( source ), x = x, y = y, z = z, interior = getElementInterior( source ), dimension = getElementDimension( source ), rotation = rotation } 
        local stats = { money = getPlayerMoney( source ), health = getElementHealth( source ), armor = getPedArmor( source ) } 
        local weapons = { } 
        
        for i = 0, 12 do 
            weapons[ i ] = { weapon = getPedWeapon( source ), ammo = getPedTotalAmmo( source, i ) } 
        end 
        
        setAccountData( account, "account.position", toJSON( position ) ) 
        setAccountData( account, "account.stats", toJSON( stats ) ) 
        setAccountData( account, "account.weapons", toJSON( weapons ) ) 
    end 
end 
addEventHandler( "onPlayerQuit", root, saveAccount ) 
addEventHandler( "onPlayerWasted", root, saveAccount ) 
addEventHandler( "onPlayerLogout", root, saveAccount ) 
  
addEventHandler( "onPlayerLogin", root, 
    function( _, account ) 
        local position = getAccountData( account, "account.position" ) 
        
        if ( position ) then 
            position = fromJSON( position ) 
            
            spawnPlayer( source, position.x, position.y, position.z, position.rotation, position.skin, position.interior, position.dimension ) 
        else 
            spawnPlayer( source, 2485, -1665, 13.5, 0, 0, 0, 0 ) 
        end 
        
        setCameraTarget( source, source ) 
        fadeCamera( source, true, 2.0 ) 
        
        local stats = getAccountData( account, "account.stats" ) 
        
        if ( stats ) then 
            stats = fromJSON( stats ) 
            
            setElementHealth( source, stats.health ) 
            setPedArmor( source, stats.armor ) 
            setPlayerMoney( source, stats.money ) 
        end 
        
        local weapons = getAccountData( account, "account.weapons" ) 
        
        if ( weapons ) then 
            weapons = fromJSON( weapons ) 
            
            for i, data in pairs( weapons ) do 
                giveWeapon( source, data.weapon, data.ammo, false ) 
            end 
        end 
    end 
) 
addEventHandler( "onPlayerWasted", root, 
    function( _, account ) 
        local position = getAccountData( account, "account.position" ) 
        
        if ( position ) then 
            position = fromJSON( position ) 
            
            spawnPlayer( source, position.x, position.y, position.z, position.rotation, position.skin, position.interior, position.dimension ) 
        else 
            spawnPlayer( source, 2485, -1665, 13.5, 0, 0, 0, 0 ) 
        end 
        
        setCameraTarget( source, source ) 
        fadeCamera( source, true, 2.0 ) 
        
        local stats = getAccountData( account, "account.stats" ) 
        
        if ( stats ) then 
            stats = fromJSON( stats ) 
            
            setElementHealth( source, stats.health ) 
            setPedArmor( source, stats.armor ) 
            setPlayerMoney( source, stats.money ) 
        end 
        
        local weapons = getAccountData( account, "account.weapons" ) 
        
        if ( weapons ) then 
            weapons = fromJSON( weapons ) 
            
            for i, data in pairs( weapons ) do 
                giveWeapon( source, data.weapon, data.ammo, false ) 
            end 
        end 
    end 
) 

Ive added an event where onPlayerWasted happens. But doesnt still load weapons, skins. etc.

Error :62: 75: 85: Bad Argument @ 'getAccountData' [Expected account at argument 1, got ped]

function saveAccount( account ) 
    local account = eventName == "onPlayerLogout" and account or getPlayerAccount( source ) 
    
    if ( account ) and ( not isGuestAccount( account ) ) then 
        local x, y, z = getElementPosition( source ) 
        local _, _, rotation = getElementRotation( source ) 
        local position = { skin = getElementModel( source ), x = x, y = y, z = z, interior = getElementInterior( source ), dimension = getElementDimension( source ), rotation = rotation } 
        local stats = { money = getPlayerMoney( source ), health = getElementHealth( source ), armor = getPedArmor( source ) } 
        local weapons = { } 
        
        for i = 0, 12 do 
            weapons[ i ] = { weapon = getPedWeapon( source ), ammo = getPedTotalAmmo( source, i ) } 
        end 
        
        setAccountData( account, "account.position", toJSON( position ) ) 
        setAccountData( account, "account.stats", toJSON( stats ) ) 
        setAccountData( account, "account.weapons", toJSON( weapons ) ) 
    end 
end 
addEventHandler( "onPlayerQuit", root, saveAccount ) 
addEventHandler( "onPlayerWasted", root, saveAccount ) 
addEventHandler( "onPlayerLogout", root, saveAccount ) 
  
addEventHandler( "onPlayerLogin", root, 
    function( _, account ) 
        local position = getAccountData( account, "account.position" ) 
        
        if ( position ) then 
            position = fromJSON( position ) 
            
            spawnPlayer( source, position.x, position.y, position.z, position.rotation, position.skin, position.interior, position.dimension ) 
        else 
            spawnPlayer( source, 2485, -1665, 13.5, 0, 0, 0, 0 ) 
        end 
        
        setCameraTarget( source, source ) 
        fadeCamera( source, true, 2.0 ) 
        
        local stats = getAccountData( account, "account.stats" ) 
        
        if ( stats ) then 
            stats = fromJSON( stats ) 
            
            setElementHealth( source, stats.health ) 
            setPedArmor( source, stats.armor ) 
            setPlayerMoney( source, stats.money ) 
        end 
        
        local weapons = getAccountData( account, "account.weapons" ) 
        
        if ( weapons ) then 
            weapons = fromJSON( weapons ) 
            
            for i, data in pairs( weapons ) do 
                giveWeapon( source, data.weapon, data.ammo, false ) 
            end 
        end 
    end 
) 
addEventHandler( "onPlayerWasted", root, 
    function( ) 
        local position = getAccountData( source, "account.position" ) 
        
        if ( position ) then 
            position = fromJSON( position ) 
            
            spawnPlayer( source, position.x, position.y, position.z, position.rotation, position.skin, position.interior, position.dimension ) 
        else 
            spawnPlayer( source, 2485, -1665, 13.5, 0, 0, 0, 0 ) 
        end 
        
        setCameraTarget( source, source ) 
        fadeCamera( source, true, 2.0 ) 
        
        local stats = getAccountData( source, "account.stats" ) 
        
        if ( stats ) then 
            stats = fromJSON( stats ) 
            
            setElementHealth( source, stats.health ) 
            setPedArmor( source, stats.armor ) 
            setPlayerMoney( source, stats.money ) 
        end 
        
        local weapons = getAccountData( source, "account.weapons" ) 
        
        if ( weapons ) then 
            weapons = fromJSON( weapons ) 
            
            for i, data in pairs( weapons ) do 
                giveWeapon( source, data.weapon, data.ammo, false ) 
            end 
        end 
    end 
) 

Link to comment
function saveAccount( account ) 
    local account = eventName == "onPlayerLogout" and account or getPlayerAccount( source ) 
    
    if ( account ) and ( not isGuestAccount( account ) ) then 
        local x, y, z = getElementPosition( source ) 
        local _, _, rotation = getElementRotation( source ) 
        local position = { skin = getElementModel( source ), x = x, y = y, z = z, interior = getElementInterior( source ), dimension = getElementDimension( source ), rotation = rotation } 
        local stats = { money = getPlayerMoney( source ), health = getElementHealth( source ), armor = getPedArmor( source ) } 
        local weapons = { } 
        
        for i = 0, 12 do 
            weapons[ i ] = { weapon = getPedWeapon( source ), ammo = getPedTotalAmmo( source, i ) } 
        end 
        
        setAccountData( account, "account.position", toJSON( position ) ) 
        setAccountData( account, "account.stats", toJSON( stats ) ) 
        setAccountData( account, "account.weapons", toJSON( weapons ) ) 
    end 
end 
addEventHandler( "onPlayerQuit", root, saveAccount ) 
addEventHandler( "onPlayerWasted", root, saveAccount ) 
addEventHandler( "onPlayerLogout", root, saveAccount ) 
  
addEventHandler( "onPlayerLogin", root, 
    function( _, account ) 
        local position = getAccountData( account, "account.position" ) 
        
        if ( position ) then 
            position = fromJSON( position ) 
            
            spawnPlayer( source, position.x, position.y, position.z, position.rotation, position.skin, position.interior, position.dimension ) 
        else 
            spawnPlayer( source, 2485, -1665, 13.5, 0, 0, 0, 0 ) 
        end 
        
        setCameraTarget( source, source ) 
        fadeCamera( source, true, 2.0 ) 
        
        local stats = getAccountData( account, "account.stats" ) 
        
        if ( stats ) then 
            stats = fromJSON( stats ) 
            
            setElementHealth( source, stats.health ) 
            setPedArmor( source, stats.armor ) 
            setPlayerMoney( source, stats.money ) 
        end 
        
        local weapons = getAccountData( account, "account.weapons" ) 
        
        if ( weapons ) then 
            weapons = fromJSON( weapons ) 
            
            for i, data in pairs( weapons ) do 
                giveWeapon( source, data.weapon, data.ammo, false ) 
            end 
        end 
    end 
) 
 

This script from myonlake really works. But only applies to onPlayerLogin. Theres too many error when I copy the onPlayerLogin and change to onPlayerWasted. Really mess up and many errordebug

Link to comment
bosslorenz said:

function saveAccount( account ) 
    local account = eventName == "onPlayerLogout" and account or getPlayerAccount( source ) 
    
    if ( account ) and ( not isGuestAccount( account ) ) then 
        local x, y, z = getElementPosition( source ) 
        local _, _, rotation = getElementRotation( source ) 
        local position = { skin = getElementModel( source ), x = x, y = y, z = z, interior = getElementInterior( source ), dimension = getElementDimension( source ), rotation = rotation } 
        local stats = { money = getPlayerMoney( source ), health = getElementHealth( source ), armor = getPedArmor( source ) } 
        local weapons = { } 
        
        for i = 0, 12 do 
            weapons[ i ] = { weapon = getPedWeapon( source ), ammo = getPedTotalAmmo( source, i ) } 
        end 
        
        setAccountData( account, "account.position", toJSON( position ) ) 
        setAccountData( account, "account.stats", toJSON( stats ) ) 
        setAccountData( account, "account.weapons", toJSON( weapons ) ) 
    end 
end 
addEventHandler( "onPlayerQuit", root, saveAccount ) 
addEventHandler( "onPlayerWasted", root, saveAccount ) 
addEventHandler( "onPlayerLogout", root, saveAccount ) 
  
addEventHandler( "onPlayerLogin", root, 
    function( _, account ) 
        local position = getAccountData( account, "account.position" ) 
        
        if ( position ) then 
            position = fromJSON( position ) 
            
            spawnPlayer( source, position.x, position.y, position.z, position.rotation, position.skin, position.interior, position.dimension ) 
        else 
            spawnPlayer( source, 2485, -1665, 13.5, 0, 0, 0, 0 ) 
        end 
        
        setCameraTarget( source, source ) 
        fadeCamera( source, true, 2.0 ) 
        
        local stats = getAccountData( account, "account.stats" ) 
        
        if ( stats ) then 
            stats = fromJSON( stats ) 
            
            setElementHealth( source, stats.health ) 
            setPedArmor( source, stats.armor ) 
            setPlayerMoney( source, stats.money ) 
        end 
        
        local weapons = getAccountData( account, "account.weapons" ) 
        
        if ( weapons ) then 
            weapons = fromJSON( weapons ) 
            
            for i, data in pairs( weapons ) do 
                giveWeapon( source, data.weapon, data.ammo, false ) 
            end 
        end 
    end 
) 
 

This script from myonlake really works. But only applies to onPlayerLogin. Theres too many error when I copy the onPlayerLogin and change to onPlayerWasted. Really mess up and many errordebug

That's because you have not read the Wiki for information of the onPlayerWasted event. There are a lot of differences between onPlayerLogin and that, so just a copy paste does not work. Please do some of the work yourself and investigate, instead of just throwing your problem here so we can permanently fix it for you.

Link to comment
function saveAccount( account ) 
    local account = eventName == "onPlayerLogout" and account or getPlayerAccount( source ) 
    
    if ( account ) and ( not isGuestAccount( account ) ) then 
        local x, y, z = getElementPosition( source ) 
        local _, _, rotation = getElementRotation( source ) 
        local position = { skin = getElementModel( source ), x = x, y = y, z = z, interior = getElementInterior( source ), dimension = getElementDimension( source ), rotation = rotation } 
        local stats = { money = getPlayerMoney( source ), health = getElementHealth( source ), armor = getPedArmor( source ) } 
        local weapons = { } 
        
        for i = 0, 12 do 
            weapons[ i ] = { weapon = getPedWeapon( source ), ammo = getPedTotalAmmo( source, i ) } 
        end 
        
        setAccountData( account, "account.position", toJSON( position ) ) 
        setAccountData( account, "account.stats", toJSON( stats ) ) 
        setAccountData( account, "account.weapons", toJSON( weapons ) ) 
    end 
end 
addEventHandler( "onPlayerQuit", root, saveAccount ) 
addEventHandler( "onPlayerWasted", root, saveAccount ) 
addEventHandler( "onPlayerLogout", root, saveAccount ) 
  
addEventHandler( "onPlayerLogin", root, 
    function( _, account ) 
        local position = getAccountData( account, "account.position" ) 
        
        if ( position ) then 
            position = fromJSON( position ) 
            
            spawnPlayer( source, position.x, position.y, position.z, position.rotation, position.skin, position.interior, position.dimension ) 
        else 
            spawnPlayer( source, 2485, -1665, 13.5, 0, 0, 0, 0 ) 
        end 
        
        setCameraTarget( source, source ) 
        fadeCamera( source, true, 2.0 ) 
        
        local stats = getAccountData( account, "account.stats" ) 
        
        if ( stats ) then 
            stats = fromJSON( stats ) 
            
            setElementHealth( source, stats.health ) 
            setPedArmor( source, stats.armor ) 
            setPlayerMoney( source, stats.money ) 
        end 
        
        local weapons = getAccountData( account, "account.weapons" ) 
        
        if ( weapons ) then 
            weapons = fromJSON( weapons ) 
            
            for i, data in pairs( weapons ) do 
                giveWeapon( source, data.weapon, data.ammo, false ) 
            end 
        end 
    end 
) 
  
function dead( account ) 
        spawnPlayer( source, 2485, -1665, 13.5, 0, 0, 0, 0 ) 
  
    local stats = getAccountData( account, "account.stats" ) 
     
    if ( stats ) then 
            stats = fromJSON( stats ) 
            
            setElementHealth( source, stats.health ) 
            setPedArmor( source, stats.armor ) 
            setPlayerMoney( source, stats.money ) 
        end 
         
    local weapons = getAccountData( account, "account.weapons" ) 
        
        if ( weapons ) then 
            weapons = fromJSON( weapons ) 
            
            for i, data in pairs( weapons ) do 
                giveWeapon( source, data.weapon, data.ammo, false ) 
            end 
        end 
end 
addEventHandler ("onPlayerWasted", root, dead) 
  
     
  

Still not working.

Error: 64:74: Bad argument @ 'getAccountData' [Expected account at argument 1, got number '0']

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