forked from Simnation/Main
fix
This commit is contained in:
parent
47f6f76107
commit
bbc1f0014c
1 changed files with 21 additions and 17 deletions
|
@ -13,12 +13,13 @@ RegisterCommand("relog", function()
|
|||
return
|
||||
end
|
||||
|
||||
|
||||
-- Prüft, ob der Spieler in einem Fahrzeug ist
|
||||
if IsPedInAnyVehicle(ped, false) then
|
||||
QBCore.Functions.Notify("Du kannst nicht im Fahrzeug relogen", "error")
|
||||
return
|
||||
end
|
||||
|
||||
-- Speichert die Position vor dem Relog
|
||||
TriggerServerEvent("qb-relogsave:server:saveLocation", playerData.citizenid, {
|
||||
x = coords.x,
|
||||
y = coords.y,
|
||||
|
@ -27,26 +28,29 @@ RegisterCommand("relog", function()
|
|||
|
||||
QBCore.Functions.Notify("Position gespeichert. Leite zum Charaktermenü weiter...", "primary")
|
||||
|
||||
|
||||
-- Kurze Verzögerung für die Benachrichtigung
|
||||
Wait(1000)
|
||||
|
||||
-- DIREKTE WEITERLEITUNG ZUM MULTICHARACTER-MENÜ
|
||||
-- Wir verwenden mehrere Methoden, um sicherzustellen, dass eine funktioniert
|
||||
|
||||
-- Methode 1: Standard um-multicharacter Event
|
||||
TriggerEvent("um-multicharacter:client:chooseChar")
|
||||
|
||||
|
||||
-- Methode 2: Alternative Events für um-multicharacter
|
||||
Wait(100)
|
||||
TriggerEvent("um-multicharacter:client:openUI")
|
||||
|
||||
|
||||
Wait(100)
|
||||
exports['qb-core']:Logout()
|
||||
|
||||
|
||||
-- Methode 3: Spieler vom Server trennen (ohne Kick)
|
||||
Wait(100)
|
||||
TriggerServerEvent("QBCore:Server:OnPlayerUnload")
|
||||
|
||||
-- Methode 4: Direkte Weiterleitung zum Multicharacter-Menü über Server
|
||||
Wait(100)
|
||||
TriggerServerEvent("qb-relogsave:server:redirectToMultichar")
|
||||
end, false)
|
||||
|
||||
|
||||
-- Empfängt die gespeicherte Position vom Server
|
||||
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
|
||||
|
||||
|
@ -56,40 +60,40 @@ RegisterNetEvent("qb-relogsave:client:restoreLocation", function(pos, heading)
|
|||
}
|
||||
end)
|
||||
|
||||
|
||||
-- Setzt die Position nach dem Spawn (QBCore Standard)
|
||||
RegisterNetEvent("QBCore:Client:OnPlayerLoaded", function()
|
||||
Wait(1000)
|
||||
Wait(1000) -- Warte kurz, bis alles geladen ist
|
||||
RestorePosition()
|
||||
end)
|
||||
|
||||
|
||||
-- Fallback für um-multicharacter
|
||||
RegisterNetEvent("um-multicharacter:client:spawned", function()
|
||||
Wait(1000)
|
||||
RestorePosition()
|
||||
end)
|
||||
|
||||
|
||||
-- Alternative Events für um-multicharacter
|
||||
RegisterNetEvent("um-multicharacter:client:playerSpawned", function()
|
||||
Wait(1000)
|
||||
RestorePosition()
|
||||
end)
|
||||
|
||||
|
||||
-- Funktion zum Wiederherstellen der Position
|
||||
function RestorePosition()
|
||||
if savedLocation then
|
||||
|
||||
-- Verzögerung für sicheres Teleportieren
|
||||
Wait(500)
|
||||
DoScreenFadeOut(500)
|
||||
Wait(600)
|
||||
|
||||
|
||||
-- Teleportiere den Spieler
|
||||
SetEntityCoords(PlayerPedId(), savedLocation.pos.x, savedLocation.pos.y, savedLocation.pos.z)
|
||||
SetEntityHeading(PlayerPedId(), savedLocation.heading)
|
||||
|
||||
Wait(500)
|
||||
DoScreenFadeIn(500)
|
||||
|
||||
|
||||
-- Löscht die gespeicherte Position
|
||||
savedLocation = nil
|
||||
|
||||
QBCore.Functions.Notify("Position wiederhergestellt", "success")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue