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

83 lines
1.9 KiB
Lua
Raw Normal View History

2025-06-26 06:01:56 +02:00
local QBCore = exports['qb-core']:GetCoreObject()
local savedLocation = nil
2025-06-27 10:01:34 +02:00
2025-06-26 06:01:56 +02:00
RegisterCommand("relog", function()
local ped = PlayerPedId()
local coords = GetEntityCoords(ped)
local heading = GetEntityHeading(ped)
2025-06-27 10:01:34 +02:00
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
2025-06-27 10:14:00 +02:00
TriggerServerEvent("qb-relogsave:server:saveLocation", playerData.citizenid, {
2025-06-26 06:01:56 +02:00
x = coords.x,
y = coords.y,
z = coords.z
2025-06-27 10:14:00 +02:00
}, heading)
2025-06-27 10:01:34 +02:00
2025-06-27 10:44:30 +02:00
QBCore.Functions.Notify("Position gespeichert. Leite zum Charaktermenü weiter...", "primary")
2025-06-27 10:01:34 +02:00
2025-06-27 10:44:30 +02:00
Wait(1000)
2025-06-27 10:14:00 +02:00
2025-06-27 10:44:30 +02:00
TriggerServerEvent("qb-relogsave:server:goToMultichar")
2025-06-26 06:01:56 +02:00
end, false)
2025-06-27 10:01:34 +02:00
2025-06-26 06:01:56 +02:00
RegisterNetEvent("qb-relogsave:client:restoreLocation", function(pos, heading)
2025-06-27 10:14:00 +02:00
if not pos or not pos.x or not pos.y or not pos.z then return end
2025-06-27 10:01:34 +02:00
2025-06-26 06:01:56 +02:00
savedLocation = {
pos = pos,
heading = heading
}
end)
2025-06-27 10:01:34 +02:00
2025-06-27 10:14:00 +02:00
RegisterNetEvent("QBCore:Client:OnPlayerLoaded", function()
2025-06-27 10:44:30 +02:00
Wait(1000) --
2025-06-27 10:14:00 +02:00
RestorePosition()
end)
RegisterNetEvent("um-multicharacter:client:spawned", function()
Wait(1000)
RestorePosition()
end)
2025-06-27 10:01:34 +02:00
function RestorePosition()
2025-06-26 06:01:56 +02:00
if savedLocation then
2025-06-27 10:01:34 +02:00
2025-06-27 10:14:00 +02:00
Wait(500)
2025-06-26 06:01:56 +02:00
DoScreenFadeOut(500)
2025-06-27 10:01:34 +02:00
Wait(600)
2025-06-27 10:14:00 +02:00
SetEntityCoords(PlayerPedId(), savedLocation.pos.x, savedLocation.pos.y, savedLocation.pos.z)
SetEntityHeading(PlayerPedId(), savedLocation.heading)
2025-06-27 10:01:34 +02:00
2025-06-26 06:01:56 +02:00
Wait(500)
DoScreenFadeIn(500)
2025-06-27 10:01:34 +02:00
2025-06-27 10:44:30 +02:00
2025-06-26 06:01:56 +02:00
savedLocation = nil
2025-06-27 10:14:00 +02:00
QBCore.Functions.Notify("Position wiederhergestellt", "success")
2025-06-26 06:01:56 +02:00
end
2025-06-27 10:01:34 +02:00
end
2025-06-27 10:44:30 +02:00