Jump to content

save player position, money


Recommended Posts

addEventHandler("onPlayerQuit",root, 
function() 
     local acc = getPlayerAccount(source) 
     if (acc) and not isGuestAccount(acc) then 
          local x,y,z = getElementPosition(source) 
          local money = getPlayerMoney(source) 
          setAccountData(acc,"PosX",x) 
          setAccountData(acc,"PosY",y) 
          setAccountData(acc,"PosZ",z) 
          setAccountData(acc,"Money",money) 
     end 
end) 
  
addEventHandler("onPlayerLogin",root, 
function(_,acc) 
     local x,y,z = getAccountData(acc,"PosX"),getAccountData(acc,"PosY"),getAccountData(acc,"PosZ") 
     local Money = getAccountData(acc,"Money") or 0 
     setPlayerMoney(source,Money) 
     spawnPlayer(source,x,y,z) 
     fadeCamera(source, true) 
     setCameraTarget(source) 
end 

  • Like 2
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...