forked from Simnation/Main
40 lines
1.1 KiB
Lua
40 lines
1.1 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:kickForRelog", function()
|
|
local src = source
|
|
DropPlayer(src, "Relog wird durchgeführt... Bitte erneut verbinden.")
|
|
end)
|