Jump to content

getElementData. offline player


fairyoggy

Recommended Posts

Posted (edited)

You can not do that, elementData is temporary, what you can that about is using setAccountData (when the player leaves save elementData) and getAccountData (get the data saved by the account)

 

Try this:

-- load elementData
function load(_, account)
    local name = getAccountData(account, "name") or "N/A"

    setElementData(source, "name", name)
end
addEventHandler("onPlayerLogin", getRootElement(), load)

-- save elementData
function save()
    local name = getElementData(source, "name") or "N/A"

    setAccountData(getPlayerAccount(source), "name", name)
end
addEventHandler("onPlayerQuit", getRootElement(), save)

-- find elementAccount
function find (source, cmd, playerAccount)
    if cmd and playerAccount then
        if getAccount(playerAccount) then
            local gName = getAccountData(getAccount(playerAccount), "name")

            outputChatBox("Name of "..playerAccount.." is #FFFFFF"..""..gName, source, 152, 95, 161, true)
        end
    end
end
addCommandHandler("find", find)

EDIT: I do not tested!

Edited by Tommy.
  • Like 1
Posted

Use

setAccountData -- save player's nickname to his account

Use the function above on login, on nick name change and on quit so it stays up to date. 

Then you may just call it by

getAccountData

to get the player's name from his account name.

  • Like 1

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