Jump to content

[HELP] how to save player position


FoxSnow

Recommended Posts

This example is with setAccountData & getAccountData, not what you requested but maybe you will use it :)

function saveStuff()
  local theAcc = getPlayerAccount(source)
  if theAcc and not isGuestAccount(theAcc) then
    local x, y, z = getElementPosition(source)
    setAccountData(theAcc, "posX", x)
    setAccountData(theAcc, "posY", y)
    setAccountData(theAcc, "posZ", z)
    end
  end
addEventHandler("onPlayerQuit", getRootElement(), saveStuff)

function loadStuff(_,account)
  if account then
    local x, y, z = getAccountData(account, "posX"), getAccountData(account, "posY"), getAccountData(account, "posZ")
    setElementPosition(source, x, y, z)
    end
  end
addEventHandler("onPlayerLogin", getRootElement(), loadStuff)

 

Link to comment
3 hours ago, Hydra said:

This example is with setAccountData & getAccountData, not what you requested but maybe you will use it :)


function saveStuff()
  local theAcc = getPlayerAccount(source)
  if theAcc and not isGuestAccount(theAcc) then
    local x, y, z = getElementPosition(source)
    setAccountData(theAcc, "posX", x)
    setAccountData(theAcc, "posY", y)
    setAccountData(theAcc, "posZ", z)
    end
  end
addEventHandler("onPlayerQuit", getRootElement(), saveStuff)

function loadStuff(_,account)
  if account then
    local x, y, z = getAccountData(account, "posX"), getAccountData(account, "posY"), getAccountData(account, "posZ")
    setElementPosition(source, x, y, z)
    end
  end
addEventHandler("onPlayerLogin", getRootElement(), loadStuff)

 

Thanks for your answer but i don't want use setAccountData.. i need a example with dbExec for save the position in my DataBase 

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