[Release] SyncPos - Safe and Respawn on last Location - Cache function - better performance

Simple as it is, it caches the positions serverside and writes it in the database every few seconds (you can change the iteration speed in the server.lua file)

Uses less performance than other scripts and saves more locations at the same time :)!

No need for ESX, you can use it with every framework you like.
Dependency is MySQL-Async.
If you do not use ESX, you might need to change the MySQL queries.


thanks man, nice post ^^

If you call Server every 2.5 seconds. From every client on the server. That’s gonna hurt

1 Like

yeah, youre right.
was kind of a quick thing to do, updated the code, should be more efficient now c:

thats whats essential mode do

thank you m8,
tell me, whats wrong about my statement

is this to help with onesync?

nope, this just respawns you at the correct place

There is improvements you can do with your code…

  • First of all, instead of calling RegisterCommand in Client, do it Server side, with rest of the code.

I would recommend you, make one version that works with OneSync… Since it would be mutch more improved.

With OneSync you can get Player’s Coords in your Server-side code.

  local ped = GetPlayerPed(source)
  local pedCoords = GetEntityCoords(ped)

But remember, for being able to use such natives serversided you need to run onesync, you can do this by adding onesync_enabled 1 to your server.cfg

I actually did not know that, so I can just “use” the Ped Serversided with GetPlayerPed()?

And yeah, well the command is clientsided because it just triggers the event, if i’d do it serverside i would need to use TriggerClient -> Triggerserver. correct me if im wrong
but thank you for the onesync tip! :slight_smile:

Is there a kind of documentation of onesync natives?


RegisterCommand('savepos', function(source, args, raw)
    steamId = GetPlayerIdentifier(source, 0)
    if(steamId ~= nil) then
        x, y, z = table.unpack(positions[steamId])
        encoded = '{' .. x .. ', ' .. y .. ', ' .. z .. '}'
        MySQL.Async.execute('UPDATE users SET lastpos = "' .. encoded .. '" WHERE identifier = "' .. steamId .. '";', {}, function(success)
            if(success == 0) then
                print("MySQL failure")
        print("Failed to save position for " .. steamId)

Good Job

I have that error

i got this error:

Hmm long time didn’t not test this but am getting same error as yours,
Any fixes found I will tell ya about it soon.

1 Like