Skip to content

Commit

Permalink
fix: save medical & health properly
Browse files Browse the repository at this point in the history
  • Loading branch information
Manason authored Oct 22, 2023
1 parent 63897bb commit a4f2c04
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 4 additions & 0 deletions client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,7 @@ exports('GetLocations', GetLocations)
AddStateBagChangeHandler('isLoggedIn', ('player:%s'):format(cache.serverId), function(_, _, value)
QBX.IsLoggedIn = value
end)

lib.callback.register('qbx_core:client:setHealth', function(health)
SetEntityHealth(cache.ped, health)
end)
9 changes: 6 additions & 3 deletions server/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ function LoginV2(source, citizenid, newData)
TriggerEvent('qb-log:server:CreateLog', 'anticheat', 'Anti-Cheat', 'white', ('%s Has Been Dropped For Character Joining Exploit'):format(GetPlayerName(source)), false)
end
else
return CheckPlayerData(source, newData)
local player = CheckPlayerData(source, newData)
player.Functions.Save()
return player
end
end

Expand Down Expand Up @@ -452,8 +454,9 @@ function CreatePlayer(playerData, Offline)

if not self.Offline then
QBX.Players[self.PlayerData.source] = self
Save(self.PlayerData.source)

local ped = GetPlayerPed(self.PlayerData.source)
lib.callback.await('qbx_core:client:setHealth', self.PlayerData.source, self.PlayerData.metadata.health)
SetPedArmour(ped, self.PlayerData.metadata.armor)
-- At this point we are safe to emit new instance to third party resource for load handling
GlobalState.PlayerCount += 1
self.Functions.UpdatePlayerData()
Expand Down

0 comments on commit a4f2c04

Please sign in to comment.