1
0
Fork 0
forked from Simnation/Main
This commit is contained in:
Max 2025-06-27 10:59:43 +02:00
parent b217c8ff3d
commit 47f6f76107
2 changed files with 30 additions and 33 deletions

View file

@ -1,7 +1,7 @@
local QBCore = exports['qb-core']:GetCoreObject() local QBCore = exports['qb-core']:GetCoreObject()
local savedLocation = nil local savedLocation = nil
-- Relog-Befehl
RegisterCommand("relog", function() RegisterCommand("relog", function()
local ped = PlayerPedId() local ped = PlayerPedId()
local coords = GetEntityCoords(ped) local coords = GetEntityCoords(ped)
@ -13,13 +13,12 @@ RegisterCommand("relog", function()
return return
end end
if IsPedInAnyVehicle(ped, false) then if IsPedInAnyVehicle(ped, false) then
QBCore.Functions.Notify("Du kannst nicht im Fahrzeug relogen", "error") QBCore.Functions.Notify("Du kannst nicht im Fahrzeug relogen", "error")
return return
end end
TriggerServerEvent("qb-relogsave:server:saveLocation", playerData.citizenid, { TriggerServerEvent("qb-relogsave:server:saveLocation", playerData.citizenid, {
x = coords.x, x = coords.x,
y = coords.y, y = coords.y,
@ -32,7 +31,19 @@ RegisterCommand("relog", function()
Wait(1000) Wait(1000)
TriggerServerEvent("qb-relogsave:server:goToMultichar") TriggerEvent("um-multicharacter:client:chooseChar")
Wait(100)
TriggerEvent("um-multicharacter:client:openUI")
Wait(100)
exports['qb-core']:Logout()
Wait(100)
TriggerServerEvent("QBCore:Server:OnPlayerUnload")
end, false) end, false)
@ -47,7 +58,7 @@ end)
RegisterNetEvent("QBCore:Client:OnPlayerLoaded", function() RegisterNetEvent("QBCore:Client:OnPlayerLoaded", function()
Wait(1000) -- Wait(1000)
RestorePosition() RestorePosition()
end) end)
@ -58,6 +69,12 @@ RegisterNetEvent("um-multicharacter:client:spawned", function()
end) end)
RegisterNetEvent("um-multicharacter:client:playerSpawned", function()
Wait(1000)
RestorePosition()
end)
function RestorePosition() function RestorePosition()
if savedLocation then if savedLocation then
@ -78,5 +95,3 @@ function RestorePosition()
QBCore.Functions.Notify("Position wiederhergestellt", "success") QBCore.Functions.Notify("Position wiederhergestellt", "success")
end end
end end

View file

@ -34,34 +34,16 @@ RegisterNetEvent('QBCore:Server:OnPlayerLoaded', function()
end) end)
RegisterNetEvent("qb-relogsave:server:goToMultichar", function() RegisterNetEvent('um-multicharacter:server:CharacterLoaded', function()
local src = source local src = source
local Player = QBCore.Functions.GetPlayer(src)
if not Player then return end
local cid = Player.PlayerData.citizenid
TriggerClientEvent('um-multicharacter:client:chooseChar', src)
if savedLocations[cid] then
Citizen.SetTimeout(500, function() TriggerClientEvent("qb-relogsave:client:restoreLocation", src, savedLocations[cid].pos, savedLocations[cid].heading)
savedLocations[cid] = nil
if GetPlayerPing(src) > 0 then end
local Player = QBCore.Functions.GetPlayer(src)
if Player then
Player.Functions.Save()
TriggerClientEvent('qb-multicharacter:client:chooseChar', src)
TriggerEvent("um-multicharacter:server:loadUserData", src)
Citizen.SetTimeout(500, function()
if GetPlayerPing(src) > 0 then
DropPlayer(src, "Relog wird durchgeführt... Bitte erneut verbinden.")
end
end)
end
end
end)
end) end)