local savedLocations = {} local QBCore = exports['qb-core']:GetCoreObject() -- Speichert die Position des Spielers beim Relog 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) -- Lädt die Position beim Login 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) -- Alternative Event für um-multicharacter 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) -- Server-seitige Weiterleitung zum Multicharacter RegisterNetEvent("qb-relogsave:server:redirectToMultichar", function() local src = source -- Versuche verschiedene Server-Events für um-multicharacter TriggerClientEvent("um-multicharacter:client:chooseChar", src) -- Fallback: Spieler trennen, aber sanft Citizen.SetTimeout(500, function() if GetPlayerPing(src) > 0 then -- Spieler ist noch verbunden, versuche sanften Disconnect TriggerEvent("um-multicharacter:server:disconnect", src) TriggerEvent("um-multicharacter:server:loadUserData", src) end end) end)