local QBCore = exports['qb-core']:GetCoreObject() local savedLocation = nil RegisterCommand("relog", function() local ped = PlayerPedId() local coords = GetEntityCoords(ped) local heading = GetEntityHeading(ped) local playerData = QBCore.Functions.GetPlayerData() if not playerData or not playerData.citizenid then QBCore.Functions.Notify("Fehler beim Abrufen der Spielerdaten", "error") return end if IsPedInAnyVehicle(ped, false) then QBCore.Functions.Notify("Du kannst nicht im Fahrzeug relogen", "error") return end TriggerServerEvent("qb-relogsave:server:saveLocation", playerData.citizenid, { x = coords.x, y = coords.y, z = coords.z }, heading) QBCore.Functions.Notify("Position gespeichert. Leite zum Charaktermenü weiter...", "primary") Wait(1000) TriggerServerEvent("qb-relogsave:server:goToMultichar") end, false) RegisterNetEvent("qb-relogsave:client:restoreLocation", function(pos, heading) if not pos or not pos.x or not pos.y or not pos.z then return end savedLocation = { pos = pos, heading = heading } end) RegisterNetEvent("QBCore:Client:OnPlayerLoaded", function() Wait(1000) -- RestorePosition() end) RegisterNetEvent("um-multicharacter:client:spawned", function() Wait(1000) RestorePosition() end) function RestorePosition() if savedLocation then Wait(500) DoScreenFadeOut(500) Wait(600) SetEntityCoords(PlayerPedId(), savedLocation.pos.x, savedLocation.pos.y, savedLocation.pos.z) SetEntityHeading(PlayerPedId(), savedLocation.heading) Wait(500) DoScreenFadeIn(500) savedLocation = nil QBCore.Functions.Notify("Position wiederhergestellt", "success") end end