forked from Simnation/Main
fix
This commit is contained in:
parent
8fd0da7d21
commit
d620dd2499
2 changed files with 24 additions and 33 deletions
|
@ -1,38 +1,22 @@
|
|||
local QBCore = exports['qb-core']:GetCoreObject()
|
||||
local LastPositions = {}
|
||||
|
||||
RegisterServerEvent("relog:saveCoords", function(coords)
|
||||
RegisterServerEvent("duckrelog:saveCoords", function(pos)
|
||||
local src = source
|
||||
local Player = QBCore.Functions.GetPlayer(src)
|
||||
if not Player then return end
|
||||
LastPositions[src] = pos
|
||||
|
||||
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
|
||||
})
|
||||
|
||||
|
||||
-- Spieler korrekt abmelden
|
||||
QBCore.Player.Logout(src)
|
||||
|
||||
-- RoutingBucket auf 0 setzen
|
||||
SetPlayerRoutingBucket(src, 0)
|
||||
end)
|
||||
|
||||
RegisterServerEvent("relog:checkLastPosition", function()
|
||||
RegisterServerEvent("duckrelog:requestCoords", 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)
|
||||
local pos = LastPositions[src]
|
||||
if pos then
|
||||
TriggerClientEvent("duckrelog:setCoords", src, pos)
|
||||
LastPositions[src] = nil -- nach der Verwendung löschen
|
||||
end
|
||||
end)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue