forked from Simnation/Main
35 lines
1.1 KiB
Lua
35 lines
1.1 KiB
Lua
![]() |
local savedLocations = {}
|
||
|
local QBCore = exports['qb-core']:GetCoreObject()
|
||
|
|
||
|
RegisterNetEvent("qb-relogsave:server:saveLocation", function(cid, coords, heading)
|
||
|
if not cid or not coords then return end
|
||
|
|
||
|
savedLocations[cid] = {
|
||
|
pos = coords,
|
||
|
heading = heading,
|
||
|
timestamp = os.time()
|
||
|
}
|
||
|
|
||
|
print("Position für " .. cid .. " gespeichert: " .. json.encode(coords))
|
||
|
end)
|
||
|
|
||
|
AddEventHandler('QBCore:Server:PlayerLoaded', function(Player)
|
||
|
if not Player or not Player.PlayerData then return end
|
||
|
|
||
|
local cid = Player.PlayerData.citizenid
|
||
|
|
||
|
if savedLocations[cid] then
|
||
|
local pos = savedLocations[cid].pos
|
||
|
local heading = savedLocations[cid].heading
|
||
|
|
||
|
if pos and pos.x and pos.y and pos.z then
|
||
|
TriggerClientEvent("qb-relogsave:client:restoreLocation", Player.PlayerData.source, pos, heading)
|
||
|
print("Position für " .. cid .. " wiederhergestellt")
|
||
|
else
|
||
|
print("Ungültige Position für " .. cid .. " gefunden")
|
||
|
end
|
||
|
|
||
|
savedLocations[cid] = nil
|
||
|
end
|
||
|
end)
|