forked from Simnation/Main
Merge branch 'master' of https://git.evolution-state-life.de/Evolution-State-Life/Main
This commit is contained in:
commit
ba57f0f054
3 changed files with 85 additions and 73 deletions
|
@ -1,38 +1,38 @@
|
||||||
local QBCore = exports['qb-core']:GetCoreObject()
|
local QBCore = exports['qb-core']:GetCoreObject()
|
||||||
local savedLocation = nil
|
local savedLocation = nil
|
||||||
|
|
||||||
RegisterCommand("relog", function()
|
RegisterCommand("relog", function()
|
||||||
local ped = PlayerPedId()
|
local ped = PlayerPedId()
|
||||||
local coords = GetEntityCoords(ped)
|
local coords = GetEntityCoords(ped)
|
||||||
local heading = GetEntityHeading(ped)
|
local heading = GetEntityHeading(ped)
|
||||||
local cid = QBCore.Functions.GetPlayerData().citizenid
|
local cid = QBCore.Functions.GetPlayerData().citizenid
|
||||||
|
|
||||||
-- Speicher Ort vor Relog
|
-- Speicher Ort vor Relog
|
||||||
TriggerServerEvent("qb-relogsave:server:saveLocation", cid, {
|
TriggerServerEvent("qb-relogsave:server:saveLocation", cid, {
|
||||||
x = coords.x,
|
x = coords.x,
|
||||||
y = coords.y,
|
y = coords.y,
|
||||||
z = coords.z
|
z = coords.z
|
||||||
}, heading)
|
}, heading)
|
||||||
|
|
||||||
TriggerEvent("qb-multicharacter:client:chooseChar")
|
TriggerEvent("qb-multicharacter:client:chooseChar")
|
||||||
end, false)
|
end, false)
|
||||||
|
|
||||||
RegisterNetEvent("qb-relogsave:client:restoreLocation", function(pos, heading)
|
RegisterNetEvent("qb-relogsave:client:restoreLocation", function(pos, heading)
|
||||||
savedLocation = {
|
savedLocation = {
|
||||||
pos = pos,
|
pos = pos,
|
||||||
heading = heading
|
heading = heading
|
||||||
}
|
}
|
||||||
end)
|
end)
|
||||||
|
|
||||||
RegisterNetEvent("qb-spawn:client:spawned", function()
|
RegisterNetEvent("qb-spawn:client:spawned", function()
|
||||||
if savedLocation then
|
if savedLocation then
|
||||||
DoScreenFadeOut(500)
|
DoScreenFadeOut(500)
|
||||||
Wait(500)
|
Wait(500)
|
||||||
SetEntityCoords(PlayerPedId(), savedLocation.pos.x, savedLocation.pos.y, savedLocation.pos.z)
|
SetEntityCoords(PlayerPedId(), savedLocation.pos.x, savedLocation.pos.y, savedLocation.pos.z)
|
||||||
SetEntityHeading(PlayerPedId(), savedLocation.heading)
|
SetEntityHeading(PlayerPedId(), savedLocation.heading)
|
||||||
Wait(500)
|
Wait(500)
|
||||||
DoScreenFadeIn(500)
|
DoScreenFadeIn(500)
|
||||||
|
|
||||||
savedLocation = nil
|
savedLocation = nil
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
fx_version 'cerulean'
|
fx_version 'cerulean'
|
||||||
game 'gta5'
|
game 'gta5'
|
||||||
|
|
||||||
description 'relog system'
|
description 'relog system'
|
||||||
author 'Duck'
|
author 'Duck'
|
||||||
version '1.0.0'
|
version '1.0.1'
|
||||||
|
|
||||||
client_script 'client.lua'
|
client_script 'client.lua'
|
||||||
server_script 'server.lua'
|
server_script 'server.lua'
|
||||||
|
|
||||||
shared_script '@qb-core/shared/locale.lua'
|
shared_script '@qb-core/shared/locale.lua'
|
||||||
dependency 'qb-core'
|
dependency 'qb-core'
|
||||||
|
dependency 'um-multicharacter'
|
||||||
|
|
|
@ -1,23 +1,34 @@
|
||||||
local savedLocations = {}
|
local savedLocations = {}
|
||||||
|
local QBCore = exports['qb-core']:GetCoreObject()
|
||||||
local QBCore = exports['qb-core']:GetCoreObject()
|
|
||||||
|
RegisterNetEvent("qb-relogsave:server:saveLocation", function(cid, coords, heading)
|
||||||
RegisterNetEvent("qb-relogsave:server:saveLocation", function(cid, coords, heading)
|
if not cid or not coords then return end
|
||||||
savedLocations[cid] = {
|
|
||||||
pos = coords,
|
savedLocations[cid] = {
|
||||||
heading = heading
|
pos = coords,
|
||||||
}
|
heading = heading,
|
||||||
end)
|
timestamp = os.time()
|
||||||
|
}
|
||||||
AddEventHandler('QBCore:Server:PlayerLoaded', function(Player)
|
|
||||||
local cid = Player.PlayerData.citizenid
|
print("Position für " .. cid .. " gespeichert: " .. json.encode(coords))
|
||||||
|
end)
|
||||||
if savedLocations[cid] then
|
|
||||||
local pos = savedLocations[cid].pos
|
AddEventHandler('QBCore:Server:PlayerLoaded', function(Player)
|
||||||
local heading = savedLocations[cid].heading
|
if not Player or not Player.PlayerData then return end
|
||||||
|
|
||||||
TriggerClientEvent("qb-relogsave:client:restoreLocation", Player.PlayerData.source, pos, heading)
|
local cid = Player.PlayerData.citizenid
|
||||||
|
|
||||||
savedLocations[cid] = nil
|
if savedLocations[cid] then
|
||||||
end
|
local pos = savedLocations[cid].pos
|
||||||
end)
|
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)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue