forked from Simnation/Main
fix
This commit is contained in:
parent
b217c8ff3d
commit
47f6f76107
2 changed files with 30 additions and 33 deletions
|
@ -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)
|
||||
|
@ -13,13 +13,12 @@ RegisterCommand("relog", function()
|
|||
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,
|
||||
|
@ -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
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
TriggerClientEvent('um-multicharacter:client:chooseChar', src)
|
||||
local cid = Player.PlayerData.citizenid
|
||||
|
||||
|
||||
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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue