forked from Simnation/Main
Script
Komplett neu geschrieben
This commit is contained in:
parent
da481ae71b
commit
8fd0da7d21
3 changed files with 81 additions and 0 deletions
38
resources/[qb]/Duck_Relog/server.lua
Normal file
38
resources/[qb]/Duck_Relog/server.lua
Normal file
|
@ -0,0 +1,38 @@
|
|||
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)
|
Loading…
Add table
Add a link
Reference in a new issue