Jump to content

Basic Spawn Save Help!


Recommended Posts

SERVER SIDE

function getPos() 
    local account = getPlayerAccount(source) 
    if (account) then 
        local x,y,z = getElementPosition( source ) 
        setAccountData( account, "save.position", x,y,z ) 
    end 
end 
addEventHandler("onPlayerQuit", getRootElement(), getPos) 
  
function setPos() 
    local account = getPlayerAccount(source) 
    if (account) then 
        local x,y,z = getAccountData( account, "save.position") 
         
        if (position) then 
              setElementPosition (  source, x, y, z ) 
        end 
    end 
end 
addEventHandler("onPlayerLogin", getRootElement(), setPos) 

Outputs no errors! Help!

Link to comment
function getPos() 
    local account = getPlayerAccount(source) 
    if (account) then 
        local x,y,z = getElementPosition( source ) 
        setAccountData( account, "save.position", {x,y,z} ) -- x,y,z you cant save them like that, it's like 3 arguments when the function need just 1 argument 
    end 
end 
addEventHandler("onPlayerQuit", getRootElement(), getPos) 
  
function setPos() 
    local account = getPlayerAccount(source) 
    if (account) then 
        local position = getAccountData( account, "save.position") 
        
        if (position) then -- also here if position then, but position wasn't defined 
              setElementPosition (  source, position[1], position[2], position[3] ) 
        end 
    end 
end 
addEventHandler("onPlayerLogin", getRootElement(), setPos) 

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