forked from Simnation/Main
49 lines
1.4 KiB
Lua
49 lines
1.4 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
|
|
}
|
|
|
|
print("[Relog] Position für " .. cid .. " gespeichert")
|
|
end)
|
|
|
|
|
|
RegisterNetEvent('QBCore:Server:OnPlayerLoaded', function()
|
|
local src = source
|
|
local Player = QBCore.Functions.GetPlayer(src)
|
|
|
|
if not Player then return end
|
|
|
|
local cid = Player.PlayerData.citizenid
|
|
|
|
if savedLocations[cid] then
|
|
local pos = savedLocations[cid].pos
|
|
local heading = savedLocations[cid].heading
|
|
|
|
TriggerClientEvent("qb-relogsave:client:restoreLocation", src, pos, heading)
|
|
print("[Relog] Position für " .. cid .. " wiederhergestellt")
|
|
|
|
savedLocations[cid] = nil
|
|
end
|
|
end)
|
|
|
|
|
|
RegisterNetEvent('um-multicharacter:server:CharacterLoaded', function()
|
|
local src = source
|
|
local Player = QBCore.Functions.GetPlayer(src)
|
|
|
|
if not Player then return end
|
|
|
|
local cid = Player.PlayerData.citizenid
|
|
|
|
if savedLocations[cid] then
|
|
TriggerClientEvent("qb-relogsave:client:restoreLocation", src, savedLocations[cid].pos, savedLocations[cid].heading)
|
|
savedLocations[cid] = nil
|
|
end
|
|
end)
|