Merge pull request #30 from BerkieBb/main

Fix coords not saving with last spawn location
This commit is contained in:
BerkieBb
2021-06-21 14:16:10 +02:00
committed by GitHub
3 changed files with 20 additions and 8 deletions
+2 -5
View File
@@ -105,15 +105,12 @@ end)
RegisterNetEvent('QBCore:Player:UpdatePlayerData')
AddEventHandler('QBCore:Player:UpdatePlayerData', function()
local data = {}
data.position = QBCore.Functions.GetCoords(PlayerPedId())
TriggerServerEvent('QBCore:UpdatePlayer', data)
TriggerServerEvent('QBCore:UpdatePlayer')
end)
RegisterNetEvent('QBCore:Player:UpdatePlayerPosition')
AddEventHandler('QBCore:Player:UpdatePlayerPosition', function()
local position = QBCore.Functions.GetCoords(PlayerPedId())
TriggerServerEvent('QBCore:UpdatePlayerPosition', position)
TriggerServerEvent('QBCore:UpdatePlayerPosition')
end)
RegisterNetEvent('QBCore:Client:LocalOutOfCharacter')
+7 -3
View File
@@ -87,12 +87,14 @@ AddEventHandler('QBCore:server:OpenServer', function()
end)
RegisterServerEvent("QBCore:UpdatePlayer")
AddEventHandler('QBCore:UpdatePlayer', function(data)
AddEventHandler('QBCore:UpdatePlayer', function()
local src = source
local entity = GetPlayerPed(src)
local position = QBCore.Functions.GetEntityCoords(entity)
local Player = QBCore.Functions.GetPlayer(src)
if Player ~= nil then
Player.PlayerData.position = data.position
Player.PlayerData.position = position
local newHunger = Player.PlayerData.metadata["hunger"] - 4.2
local newThirst = Player.PlayerData.metadata["thirst"] - 3.8
@@ -108,8 +110,10 @@ AddEventHandler('QBCore:UpdatePlayer', function(data)
end)
RegisterServerEvent("QBCore:UpdatePlayerPosition")
AddEventHandler("QBCore:UpdatePlayerPosition", function(position)
AddEventHandler("QBCore:UpdatePlayerPosition", function()
local src = source
local entity = GetPlayerPed(src)
local position = QBCore.Functions.GetEntityCoords(entity)
local Player = QBCore.Functions.GetPlayer(src)
if Player ~= nil then
Player.PlayerData.position = position
+11
View File
@@ -21,6 +21,17 @@ QBCore.Functions.ExecuteSql = function(wait, query, cb)
return rtndata
end
QBCore.Functions.GetEntityCoords = function(entity)
local coords = GetEntityCoords(entity, false)
local heading = GetEntityHeading(entity)
return {
x = coords.x,
y = coords.y,
z = coords.z,
a = heading
}
end
QBCore.Functions.GetIdentifier = function(source, idtype)
local idtype = idtype ~=nil and idtype or QBConfig.IdentifierType
for _, identifier in pairs(GetPlayerIdentifiers(source)) do