forked from Simnation/Main
Script
Komplett neu geschrieben
This commit is contained in:
parent
da481ae71b
commit
8fd0da7d21
3 changed files with 81 additions and 0 deletions
25
resources/[qb]/Duck_Relog/client.lua
Normal file
25
resources/[qb]/Duck_Relog/client.lua
Normal 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)
|
18
resources/[qb]/Duck_Relog/fxmanifest.lua
Normal file
18
resources/[qb]/Duck_Relog/fxmanifest.lua
Normal 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'
|
38
resources/[qb]/Duck_Relog/server.lua
Normal file
38
resources/[qb]/Duck_Relog/server.lua
Normal 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)
|
Loading…
Add table
Add a link
Reference in a new issue