forked from Simnation/Main
97 lines
2.2 KiB
Lua
97 lines
2.2 KiB
Lua
local QBCore = exports['qb-core']:GetCoreObject()
|
|
local savedLocation = nil
|
|
|
|
-- Relog-Befehl
|
|
RegisterCommand("relog", function()
|
|
local ped = PlayerPedId()
|
|
local coords = GetEntityCoords(ped)
|
|
local heading = GetEntityHeading(ped)
|
|
local playerData = QBCore.Functions.GetPlayerData()
|
|
|
|
if not playerData or not playerData.citizenid then
|
|
QBCore.Functions.Notify("Fehler beim Abrufen der Spielerdaten", "error")
|
|
return
|
|
end
|
|
|
|
|
|
if IsPedInAnyVehicle(ped, false) then
|
|
QBCore.Functions.Notify("Du kannst nicht im Fahrzeug relogen", "error")
|
|
return
|
|
end
|
|
|
|
TriggerServerEvent("qb-relogsave:server:saveLocation", playerData.citizenid, {
|
|
x = coords.x,
|
|
y = coords.y,
|
|
z = coords.z
|
|
}, heading)
|
|
|
|
QBCore.Functions.Notify("Position gespeichert. Leite zum Charaktermenü weiter...", "primary")
|
|
|
|
|
|
Wait(1000)
|
|
|
|
|
|
TriggerEvent("um-multicharacter:client:chooseChar")
|
|
|
|
|
|
Wait(100)
|
|
TriggerEvent("um-multicharacter:client:openUI")
|
|
|
|
|
|
Wait(100)
|
|
exports['qb-core']:Logout()
|
|
|
|
|
|
Wait(100)
|
|
TriggerServerEvent("QBCore:Server:OnPlayerUnload")
|
|
end, false)
|
|
|
|
|
|
RegisterNetEvent("qb-relogsave:client:restoreLocation", function(pos, heading)
|
|
if not pos or not pos.x or not pos.y or not pos.z then return end
|
|
|
|
savedLocation = {
|
|
pos = pos,
|
|
heading = heading
|
|
}
|
|
end)
|
|
|
|
|
|
RegisterNetEvent("QBCore:Client:OnPlayerLoaded", function()
|
|
Wait(1000)
|
|
RestorePosition()
|
|
end)
|
|
|
|
|
|
RegisterNetEvent("um-multicharacter:client:spawned", function()
|
|
Wait(1000)
|
|
RestorePosition()
|
|
end)
|
|
|
|
|
|
RegisterNetEvent("um-multicharacter:client:playerSpawned", function()
|
|
Wait(1000)
|
|
RestorePosition()
|
|
end)
|
|
|
|
|
|
function RestorePosition()
|
|
if savedLocation then
|
|
|
|
Wait(500)
|
|
DoScreenFadeOut(500)
|
|
Wait(600)
|
|
|
|
|
|
SetEntityCoords(PlayerPedId(), savedLocation.pos.x, savedLocation.pos.y, savedLocation.pos.z)
|
|
SetEntityHeading(PlayerPedId(), savedLocation.heading)
|
|
|
|
Wait(500)
|
|
DoScreenFadeIn(500)
|
|
|
|
|
|
savedLocation = nil
|
|
|
|
QBCore.Functions.Notify("Position wiederhergestellt", "success")
|
|
end
|
|
end
|