[Release] New Save/Respawn the last player position for Essential mode 5

Hello, today i have updated this original script: [Release] Save/Respawn the last player position with MySQL by @ZeCreeps

It’s an updated version which work with Essential mode 5 and my sql async !

Download: save-position-2.1.rar (1.7 KB)

Changelog v2.1: Patched a bug with the respawn coords !

8 Likes

Thanks for the share :slight_smile:

I’ll give it a try and tell you if all is ok on my side :slight_smile:

Perfect :slight_smile:
Thanks again for your release dude :slight_smile:

@K3rhos Hey man I think this is gonna save my server because Im having an issue now where last location doesnt get saved all the time, so all i gotta do is put this in my resouces, start in server.cfg and then import the SQL right?

Also, does this change the default spawn location for new players? I got a custom one and I dont want to change it, I just want returning players last location to be saved.

Im always getting this error "#1060 - Duplicate column name ‘lastpos’ "

Hey, I’m receiving an error of this for some reason. I’ve also compiled this script with my other essentiamode scripts into one resource, which shouldn’t affect this at all.

Here is my error code if you’d like to look it over.

InvokeNative: execution failed: Argument at index 1 was null.
Await failure: citizen:/scripting/lua/scheduler.lua:126: Execution of native 000000002f7a49e6 in script host failed.
stack traceback:
        [C]: in upvalue '_in'
        citizen:/scripting/lua/natives_server.lua:436: in function 'TriggerClientEventInternal'
        (...tail calls...)
        server/es-pos_server.lua:22: in upvalue 'ref'
        citizen:/scripting/lua/scheduler.lua:389: in function <citizen:/scripting/lua/scheduler.lua:388>
        [C]: in function 'xpcall'
        citizen:/scripting/lua/scheduler.lua:388: in function <citizen:/scripting/lua/scheduler.lua:387>
stack traceback:
        citizen:/scripting/lua/scheduler.lua:640: in local 'cb'
        server/player/login.lua:133: in upvalue 'handler'
        citizen:/scripting/lua/scheduler.lua:219: in function

have you found a fix?

i am getting this error plz help

[ERROR] [MySQL] [lastpostodb] An error happens on MySQL for query "[object Object]": ER_BAD_FIELD_ERROR: Unknown column 'lastpos' in 'field list'
Error: (node:1592) UnhandledPromiseRejectionWarning: AssertionError [ERR_ASSERTION]: unexpected PromiseRejectEvent
    at process.<anonymous> (internal/process/promises.js:27:25)
    at <anonymous>
    at Query.db.query [as _callback] (mysql-async.js:4973:13)
    at Query.Sequence.end (mysql-async.js:280:24)
    at Query.ErrorPacket (mysql-async.js:2122:8)
    at Protocol._parsePacket (mysql-async.js:5941:23)
    at Parser.write (mysql-async.js:6198:12)
    at Protocol.write (mysql-async.js:5701:16)
    at Socket.<anonymous> (mysql-async.js:693:28)
    at emitOne (events.js:116:13)
Error: (node:1592) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3)
Error: (node:1592) UnhandledPromiseRejectionWarning: Error: ER_BAD_FIELD_ERROR: Unknown column 'lastpos' in 'field list'
    at Query.Sequence._packetToError (mysql-async.js:244:14)
    at Query.ErrorPacket (mysql-async.js:2109:18)
    at Protocol._parsePacket (mysql-async.js:5941:23)
    at Parser.write (mysql-async.js:6198:12)
    at Protocol.write (mysql-async.js:5701:16)
    at Socket.<anonymous> (mysql-async.js:693:28)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:250:11)
    --------------------
    at Pool.query (mysql-async.js:4728:23)
    at Promise (mysql-async.js:4970:12)
    at new Promise (<anonymous>)
    at execute (mysql-async.js:4967:26)
    at Object.global.exports [as callback] (mysql-async.js:4993:5)
    at citizen:/scripting/v8/main.js:87:41
Error: (node:1592) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 4)

How can I save position when player is dropped?

Thats the easy part… For some reason I can’t get the client to spawn off the coordinates. The client is receiving the location perfectly fine, although SetEntityCoords is not accepting them

I just get a user error!!

i got this error when i try import

USE essentialmode;

– Vous pouvez remplacer {-887.48388671875, -2311.68872070313, -3.50776553153992, 142.503463745117} par la position par defaut où seront spawn les nouveaux utilisateurs

ALTER TABLE users ADD COLUMN lastpos VARCHAR(255) DEFAULT ‘{706.98700000000, -964.94200000000, 31.39550000000000, 142.503463745117}’;

1 Like

I have this error, how do I fix it?

SCRIPT ERROR: @save-position/server.lua:15: attempt to index a nil value (local 'user')
> ref (@save-position/server.lua:15)
> handler (@essentialmode/server/player/login.lua:134)
> handler (@save-position/server.lua:14)

You already have a column on the USER table with that name, thats why :slight_smile:

You Need To Change USE[servername] ;
Because if you type essentialmode; it wont exist you need to type the database name like mine is zap i type USE zap1232;

You’ll have to insert a colum called ‘lastpos’ in your users table in your SQL Database.

How tf do you use this?