Jump to content

SavePlayerData


CodX

Recommended Posts

Hello !
 

function savePlayerData(thePlayer)
	local account = getPlayerAccount(thePlayer);
	if account then
		for _,v in ipairs(playerDataTable) do
			setAccountData(account, v[1], getElementData(thePlayer, v[1]));
		end
		local x,y,z = getElementPosition(thePlayer);
		setAccountData(account, "last_x", x);
		setAccountData(account, "last_y", y);
		setAccountData(account, "last_z", z);
	end
end

I have some problems with this script. He always get player name as "nil" and i don't know why can't.

Warning Text from debugger: Bad Argument @'getPlayerAccount' [Expected element at argument 1, got nil]

Link to comment
8 hours ago, NeXuS™ said:

There is no way it isn't saved with this method. It is called every single time a player is disconnected.

In fact, there are at least two ways. One way is that the server crashes; nothing you can do there.. or that the resource gets stopped and a player leaves within the time the resource is not running; this can be solved using onResourceStop.

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