[HELP] the player's last location is not saved

The player’s last location is not saved.

When they leave the server and enter, they appear in the first generation point that configures by default in the map of five assignments and in the map skater of five elements (the changes in the two lines: {x = - 267.722, y = - 958.341, z = 31.2231}) so that when they appear for the first time they appear, but they always appear not only the first time.

forgive me for my English

store the location in the DB when the player times out or disconnects

then when player enters server or when player spawns after selecting character, update their ped position from the DB with
SetEntityCoords(entity, coords.x, coords.y, coords.z)

Where do I put it? sol otengo I write the SetEntityCoords (entity, coords.x, coords.y, coords.z) sorry but I speak spanish and use translator

there are a number of ways to go about it, but the common way would be to use “async”

would look something like:

local steamid = GetPlayerIdentifiers(source)[1]
local coords

MySQL.Async.fetchAll('SELECT position FROM users WHERE owner = @owner', {['@owner'] = steamid}, function(result)
	coords = result
end)

remember you will need to have “async” mod, and add async to your __resource.lua like:

server_scripts {
	'@mysql-async/lib/MySQL.lua',
}

I suggest you look through other addons you have installed that use the database so you can get a better idea of how it works. I am not sure but you may have to call the database from server scripts only (might not work from client script) I dont remember at the moment and I only have a few minutes.

Ill check back in next weekend when I get back. good luck!

1 Like