1
0
Fork 0
forked from Simnation/Main
Main/resources/[qb]/Duck_Relog/server.lua
Max 8fd0da7d21 Script
Komplett neu geschrieben
2025-06-27 11:32:02 +02:00

38 lines
1 KiB
Lua

local QBCore = exports['qb-core']:GetCoreObject()
RegisterServerEvent("relog:saveCoords", function(coords)
local src = source
local Player = QBCore.Functions.GetPlayer(src)
if not Player then return end
local data = {
x = coords.x,
y = coords.y,
z = coords.z,
w = GetEntityHeading(GetPlayerPed(src))
}
MySQL.update('UPDATE players SET last_position = ? WHERE citizenid = ?', {
json.encode(data),
Player.PlayerData.citizenid
})
QBCore.Player.Logout(src)
SetPlayerRoutingBucket(src, 0)
end)
RegisterServerEvent("relog:checkLastPosition", function()
local src = source
local Player = QBCore.Functions.GetPlayer(src)
if not Player then return end
local result = MySQL.single.await('SELECT last_position FROM players WHERE citizenid = ?', {
Player.PlayerData.citizenid
})
if result and result.last_position then
local pos = json.decode(result.last_position)
TriggerClientEvent("relog:teleportPlayer", src, pos)
end
end)