fix(server/events/player): Position

Position was not updating on player dropped but was on player save event.
This commit is contained in:
GhzGarage
2021-09-25 18:31:28 -05:00
parent 5555cd6662
commit 34c574daf2
3 changed files with 4 additions and 4 deletions
+1 -1
View File
@@ -135,7 +135,7 @@ function QBCore.Functions.GetPlayersFromCoords(coords, distance)
local targetCoords = GetEntityCoords(target)
local targetdistance = #(targetCoords - coords)
if targetdistance <= distance then
closePlayers[#closePlayers+1] = player
closePlayers[#closePlayers+1] = player
end
end
return closePlayers
-2
View File
@@ -122,10 +122,8 @@ end)
RegisterNetEvent('QBCore:UpdatePlayer', function()
local src = source
local ped = GetPlayerPed(src)
local Player = QBCore.Functions.GetPlayer(src)
if Player then
Player.PlayerData.position = GetEntityCoords(ped)
local newHunger = Player.PlayerData.metadata['hunger'] - QBCore.Config.Player.HungerRate
local newThirst = Player.PlayerData.metadata['thirst'] - QBCore.Config.Player.ThirstRate
if newHunger <= 0 then newHunger = 0 end
+3 -1
View File
@@ -454,6 +454,8 @@ end
function QBCore.Player.Save(source)
local src = source
local ped = GetPlayerPed(src)
local pcoords = GetEntityCoords(ped)
local PlayerData = QBCore.Players[src].PlayerData
if PlayerData then
exports.oxmysql:insert('INSERT INTO players (citizenid, cid, license, name, money, charinfo, job, gang, position, metadata) VALUES (:citizenid, :cid, :license, :name, :money, :charinfo, :job, :gang, :position, :metadata) ON DUPLICATE KEY UPDATE cid = :cid, name = :name, money = :money, charinfo = :charinfo, job = :job, gang = :gang, position = :position, metadata = :metadata', {
@@ -465,7 +467,7 @@ function QBCore.Player.Save(source)
charinfo = json.encode(PlayerData.charinfo),
job = json.encode(PlayerData.job),
gang = json.encode(PlayerData.gang),
position = json.encode(PlayerData.position),
position = json.encode(pcoords),
metadata = json.encode(PlayerData.metadata)
})
QBCore.Player.SaveInventory(src)