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

41 lines
1.1 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:14:00 +02:00
RegisterNetEvent("qb-relogsave:server:kickForRelog", function()
2025-06-27 10:01:34 +02:00
local src = source
2025-06-27 10:14:00 +02:00
DropPlayer(src, "Relog wird durchgeführt... Bitte erneut verbinden.")
2025-06-27 10:01:34 +02:00
end)