forked from Simnation/Main
67 lines
1.8 KiB
Lua
67 lines
1.8 KiB
Lua
local savedLocations = {}
|
|
local QBCore = exports['qb-core']:GetCoreObject()
|
|
|
|
|
|
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)
|
|
|
|
|
|
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)
|
|
|
|
|
|
RegisterNetEvent("qb-relogsave:server:goToMultichar", function()
|
|
local src = source
|
|
|
|
|
|
|
|
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)
|
|
end)
|