mirror of
https://github.com/qbcore-fivem/qb-core.git
synced 2026-08-29 01:08:57 +00:00
Merge pull request #30 from BerkieBb/main
Fix coords not saving with last spawn location
This commit is contained in:
+2
-5
@@ -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
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user