Skip to content

Commit

Permalink
fix(resource): check if entity exists before trying to access it
Browse files Browse the repository at this point in the history
This comes from PR #928, but implemented differently.
  • Loading branch information
tabarra committed May 8, 2024
1 parent 4d388f8 commit 173a3b8
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions resource/sv_playerlist.lua
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,18 @@ CreateThread(function()
local yCoord = nil
if onesyncEnabled == true then
local ped = GetPlayerPed(serverID)
health = GetPedHealthPercent(ped)
local veh = GetVehiclePedIsIn(ped)
if veh ~= 0 then
vType = vTypeMap[tostring(GetVehicleType(veh))]
else
vType = vTypeMap["walking"]
if ped and DoesEntityExist(ped) then
health = GetPedHealthPercent(ped)
local veh = GetVehiclePedIsIn(ped)
if veh ~= 0 then
vType = vTypeMap[tostring(GetVehicleType(veh))]
else
vType = vTypeMap["walking"]
end
local coords = GetEntityCoords(ped)
xCoord = math.floor(coords.x)
yCoord = math.floor(coords.y)
end
local coords = GetEntityCoords(ped)
xCoord = math.floor(coords.x)
yCoord = math.floor(coords.y)
end

-- Updating TX_PLAYERLIST
Expand Down

0 comments on commit 173a3b8

Please sign in to comment.