1
0
Fork 0
forked from Simnation/Main
Komplett neu geschrieben
This commit is contained in:
Max 2025-06-27 11:32:02 +02:00
parent da481ae71b
commit 8fd0da7d21
3 changed files with 81 additions and 0 deletions

View file

@ -0,0 +1,25 @@
local hasUsedRelog = false
RegisterCommand("relog", function()
local coords = GetEntityCoords(PlayerPedId())
TriggerServerEvent("relog:saveCoords", coords)
hasUsedRelog = true
ShutdownLoadingScreenNui()
TriggerEvent("um-multichar:client:chooseChar")
end, false)
RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function()
TriggerServerEvent("relog:checkLastPosition")
end)
RegisterNetEvent("relog:teleportPlayer", 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)
FreezeEntityPosition(ped, false)
end
end)

View file

@ -0,0 +1,18 @@
fx_version 'cerulean'
game 'gta5'
author 'Duck'
description 'Relog extra. UM-Multi ist erforderlich'
client_scripts {
'client.lua'
}
server_scripts {
'@oxmysql/lib/MySQL.lua',
'server.lua'
}
shared_script '@qb-core/shared/locale.lua'
dependency 'qb-core'

View file

@ -0,0 +1,38 @@
local QBCore = exports['qb-core']:GetCoreObject()
RegisterServerEvent("relog:saveCoords", function(coords)
local src = source
local Player = QBCore.Functions.GetPlayer(src)
if not Player then return end
local data = {
x = coords.x,
y = coords.y,
z = coords.z,
w = GetEntityHeading(GetPlayerPed(src))
}
MySQL.update('UPDATE players SET last_position = ? WHERE citizenid = ?', {
json.encode(data),
Player.PlayerData.citizenid
})
QBCore.Player.Logout(src)
SetPlayerRoutingBucket(src, 0)
end)
RegisterServerEvent("relog:checkLastPosition", function()
local src = source
local Player = QBCore.Functions.GetPlayer(src)
if not Player then return end
local result = MySQL.single.await('SELECT last_position FROM players WHERE citizenid = ?', {
Player.PlayerData.citizenid
})
if result and result.last_position then
local pos = json.decode(result.last_position)
TriggerClientEvent("relog:teleportPlayer", src, pos)
end
end)