1
0
Fork 0
forked from Simnation/Main
Main/resources/[qb]/Duck_relogextra/server.lua

68 lines
1.8 KiB
Lua
Raw Normal View History

2025-06-26 06:01:56 +02:00
local savedLocations = {}
local QBCore = exports['qb-core']:GetCoreObject()
2025-06-27 10:01:34 +02:00
2025-06-26 06:01:56 +02:00
RegisterNetEvent("qb-relogsave:server:saveLocation", function(cid, coords, heading)
2025-06-27 10:14:00 +02:00
if not cid or not coords then return end
2025-06-26 06:01:56 +02:00
savedLocations[cid] = {
pos = coords,
2025-06-27 10:14:00 +02:00
heading = heading
2025-06-26 06:01:56 +02:00
}
2025-06-27 10:14:00 +02:00
print("[Relog] Position für " .. cid .. " gespeichert")
2025-06-26 06:01:56 +02:00
end)
2025-06-27 10:01:34 +02:00
RegisterNetEvent('QBCore:Server:OnPlayerLoaded', function()
local src = source
local Player = QBCore.Functions.GetPlayer(src)
2025-06-27 10:14:00 +02:00
if not Player then return end
2025-06-26 06:01:56 +02:00
local cid = Player.PlayerData.citizenid
if savedLocations[cid] then
local pos = savedLocations[cid].pos
local heading = savedLocations[cid].heading
2025-06-27 10:01:34 +02:00
2025-06-27 10:14:00 +02:00
TriggerClientEvent("qb-relogsave:client:restoreLocation", src, pos, heading)
print("[Relog] Position für " .. cid .. " wiederhergestellt")
2025-06-27 10:01:34 +02:00
2025-06-26 06:01:56 +02:00
savedLocations[cid] = nil
end
end)
2025-06-27 10:01:34 +02:00
2025-06-27 10:44:30 +02:00
RegisterNetEvent("qb-relogsave:server:goToMultichar", function()
2025-06-27 10:01:34 +02:00
local src = source
2025-06-27 10:44:30 +02:00
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)
2025-06-27 10:01:34 +02:00
end)