forked from Simnation/Main
35 lines
1 KiB
Lua
35 lines
1 KiB
Lua
RegisterCommand("relog", function()
|
|
local ped = PlayerPedId()
|
|
local coords = GetEntityCoords(ped)
|
|
local heading = GetEntityHeading(ped)
|
|
|
|
-- Position an Server senden
|
|
TriggerServerEvent("duckrelog:saveCoords", {
|
|
x = coords.x,
|
|
y = coords.y,
|
|
z = coords.z,
|
|
w = heading
|
|
})
|
|
end, false)
|
|
|
|
-- Multichar-Menü öffnen, nachdem der Server Logout durchgeführt hat
|
|
RegisterNetEvent("duckrelog:openCharMenu", function()
|
|
ShutdownLoadingScreenNui()
|
|
TriggerEvent("um-multichar:client:chooseChar")
|
|
end)
|
|
|
|
-- Spielerposition wiederherstellen
|
|
RegisterNetEvent("duckrelog:setCoords", function(pos)
|
|
if pos then
|
|
local ped = PlayerPedId()
|
|
RequestCollisionAtCoord(pos.x, pos.y, pos.z)
|
|
SetEntityCoordsNoOffset(ped, pos.x, pos.y, pos.z, false, false, false)
|
|
SetEntityHeading(ped, pos.w or 0.0)
|
|
end
|
|
end)
|
|
|
|
-- Nach Login, Server fragen ob Position wiederhergestellt werden soll
|
|
RegisterNetEvent("QBCore:Client:OnPlayerLoaded", function()
|
|
TriggerServerEvent("duckrelog:requestCoords")
|
|
end)
|
|
|