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 savedLocation = nil
-- Relog-Befehl
RegisterCommand("relog", function()
local ped = PlayerPedId()
local coords = GetEntityCoords(ped)
@ -19,7 +19,6 @@ RegisterCommand("relog", function()
return
end
TriggerServerEvent("qb-relogsave:server:saveLocation", playerData.citizenid, {
x = coords.x,
y = coords.y,
@ -32,7 +31,19 @@ RegisterCommand("relog", function()
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)
@ -47,7 +58,7 @@ end)
RegisterNetEvent("QBCore:Client:OnPlayerLoaded", function()
Wait(1000) --
Wait(1000)
RestorePosition()
end)
@ -58,6 +69,12 @@ RegisterNetEvent("um-multicharacter:client:spawned", function()
end)
RegisterNetEvent("um-multicharacter:client:playerSpawned", function()
Wait(1000)
RestorePosition()
end)
function RestorePosition()
if savedLocation then
@ -78,5 +95,3 @@ function RestorePosition()
QBCore.Functions.Notify("Position wiederhergestellt", "success")
end
end

View file

@ -34,34 +34,16 @@ RegisterNetEvent('QBCore:Server:OnPlayerLoaded', function()
end)
RegisterNetEvent("qb-relogsave:server:goToMultichar", function()
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
TriggerClientEvent('um-multicharacter:client:chooseChar', src)
Citizen.SetTimeout(500, function()
if GetPlayerPing(src) > 0 then
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)
if savedLocations[cid] then
TriggerClientEvent("qb-relogsave:client:restoreLocation", src, savedLocations[cid].pos, savedLocations[cid].heading)
savedLocations[cid] = nil
end
end)