Skip to content

Commit

Permalink
refactor(client/spawn): pcall when setting player health
Browse files Browse the repository at this point in the history
  • Loading branch information
thelindat committed Apr 1, 2023
1 parent 4254baf commit 40bc8d1
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion client/spawn.lua
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,14 @@ RegisterNetEvent('ox:loadPlayer', function(spawn, data, health, armour, gender)

health = LocalPlayer.state.dead and 0 or health or GetEntityMaxHealth(cache.ped)

SetEntityHealth(cache.ped, health)
local success, err = pcall(SetEntityHealth, cache.ped, health)

if not success then
-- why does this native continue to randomly and inexplicably throw "native execution errors"
print(err)
print(cache.ped, health, cache.ped == PlayerPedId())
end

SetPedArmour(cache.ped, armour or 0)

SetPlayerData(data)
Expand Down

0 comments on commit 40bc8d1

Please sign in to comment.