local savedLocations = {} local QBCore = exports['qb-core']:GetCoreObject() local function DebugPrint(msg) print("^2[RELOG-DEBUG] ^7" .. msg) end RegisterNetEvent("qb-relogsave:server:saveLocation", function(cid, coords, heading) local src = source local playerName = GetPlayerName(src) or "Unbekannt" if not cid or not coords then DebugPrint("Fehler: Ungültige Daten von " .. playerName .. " (ID: " .. src .. ")") return end savedLocations[cid] = { pos = coords, heading = heading, timestamp = os.time(), playerName = playerName } DebugPrint("Position für " .. playerName .. " (CID: " .. cid .. ") gespeichert: X=" .. coords.x .. ", Y=" .. coords.y .. ", Z=" .. coords.z) end) RegisterNetEvent('QBCore:Server:OnPlayerLoaded', function() local src = source local Player = QBCore.Functions.GetPlayer(src) if not Player then DebugPrint("Fehler: Spieler nicht gefunden (ID: " .. src .. ")") return end local cid = Player.PlayerData.citizenid DebugPrint("Spieler geladen: " .. Player.PlayerData.name .. " (CID: " .. cid .. ")") if savedLocations[cid] then local pos = savedLocations[cid].pos local heading = savedLocations[cid].heading local timestamp = savedLocations[cid].timestamp local timeAgo = os.time() - timestamp DebugPrint("Gespeicherte Position gefunden für " .. cid .. " (vor " .. timeAgo .. " Sekunden)") if pos and pos.x and pos.y and pos.z then DebugPrint("Position wird wiederhergestellt: X=" .. pos.x .. ", Y=" .. pos.y .. ", Z=" .. pos.z) TriggerClientEvent("qb-relogsave:client:restoreLocation", src, pos, heading) else DebugPrint("Ungültige Position für " .. cid) end savedLocations[cid] = nil else DebugPrint("Keine gespeicherte Position für " .. cid .. " gefunden") 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 DebugPrint("um-multicharacter: Charakter geladen für " .. cid) if savedLocations[cid] then TriggerClientEvent("qb-relogsave:client:restoreLocation", src, savedLocations[cid].pos, savedLocations[cid].heading) savedLocations[cid] = nil end end) QBCore.Commands.Add('relogpositions', 'Zeigt alle gespeicherten Relog-Positionen', {}, false, function(source) local count = 0 for cid, data in pairs(savedLocations) do count = count + 1 local timeAgo = os.time() - (data.timestamp or 0) TriggerClientEvent('QBCore:Notify', source, cid .. ": " .. "X=" .. math.floor(data.pos.x) .. " Y=" .. math.floor(data.pos.y) .. " Z=" .. math.floor(data.pos.z) .. " (vor " .. timeAgo .. "s)") end if count == 0 then TriggerClientEvent('QBCore:Notify', source, "Keine gespeicherten Positionen") end end, 'admin')