1
0
Fork 0
forked from Simnation/Main

Fix Script

This commit is contained in:
Max 2025-06-26 06:01:56 +02:00
parent de9c6aeb91
commit 04949225df
3 changed files with 85 additions and 0 deletions

View file

@ -0,0 +1,38 @@
local QBCore = exports['qb-core']:GetCoreObject()
local savedLocation = nil
RegisterCommand("relog", function()
local ped = PlayerPedId()
local coords = GetEntityCoords(ped)
local heading = GetEntityHeading(ped)
local cid = QBCore.Functions.GetPlayerData().citizenid
-- Speicher Ort vor Relog
TriggerServerEvent("qb-relogsave:server:saveLocation", cid, {
x = coords.x,
y = coords.y,
z = coords.z
}, heading)
TriggerEvent("qb-multicharacter:client:chooseChar")
end, false)
RegisterNetEvent("qb-relogsave:client:restoreLocation", function(pos, heading)
savedLocation = {
pos = pos,
heading = heading
}
end)
RegisterNetEvent("qb-spawn:client:spawned", function()
if savedLocation then
DoScreenFadeOut(500)
Wait(500)
SetEntityCoords(PlayerPedId(), savedLocation.pos.x, savedLocation.pos.y, savedLocation.pos.z)
SetEntityHeading(PlayerPedId(), savedLocation.heading)
Wait(500)
DoScreenFadeIn(500)
savedLocation = nil
end
end)

View file

@ -0,0 +1,13 @@
fx_version 'cerulean'
game 'gta5'
description 'relog system'
author 'Duck'
version '1.0.1'
client_script 'client.lua'
server_script 'server.lua'
shared_script '@qb-core/shared/locale.lua'
dependency 'qb-core'
dependency 'um-multicharacter'

View file

@ -0,0 +1,34 @@
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,
timestamp = os.time()
}
print("Position für " .. cid .. " gespeichert: " .. json.encode(coords))
end)
AddEventHandler('QBCore:Server:PlayerLoaded', function(Player)
if not Player or not Player.PlayerData then return end
local cid = Player.PlayerData.citizenid
if savedLocations[cid] then
local pos = savedLocations[cid].pos
local heading = savedLocations[cid].heading
if pos and pos.x and pos.y and pos.z then
TriggerClientEvent("qb-relogsave:client:restoreLocation", Player.PlayerData.source, pos, heading)
print("Position für " .. cid .. " wiederhergestellt")
else
print("Ungültige Position für " .. cid .. " gefunden")
end
savedLocations[cid] = nil
end
end)