Skip to content

Commit

Permalink
fix(client): add los checks when giving items
Browse files Browse the repository at this point in the history
Unfortunately we can't check for glass with HasEntityClearLosToEntity?
Resolves #1413.
  • Loading branch information
thelindat committed Jul 23, 2023
1 parent 3699009 commit b9e0608
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1638,8 +1638,9 @@ RegisterNUICallback('giveItem', function(data, cb)

for i = 1, #nearbyPlayers do
local option = nearbyPlayers[i]
local entity = Utils.Raycast(1|2|4|8|16, option.coords + vec3(0, 0, 0.5), 0.2)

if IsEntityVisible(option.ped) then
if entity == option.ped and IsEntityVisible(option.ped) then
local playerName = GetPlayerName(option.id)
option.id = GetPlayerServerId(option.id)
option.label = ('[%s] %s'):format(option.id, playerName)
Expand Down Expand Up @@ -1673,7 +1674,7 @@ RegisterNUICallback('giveItem', function(data, cb)
end
end
else
local entity = Utils.Raycast(12)
local entity = Utils.Raycast(1|2|4|8|16, GetOffsetFromEntityInWorldCoords(cache.ped, 0.0, 3.0, 0.5), 0.2)

if entity and IsPedAPlayer(entity) and IsEntityVisible(entity) and #(GetEntityCoords(playerPed, true) - GetEntityCoords(entity, true)) < 3.0 then
target = GetPlayerServerId(NetworkGetPlayerIndexFromPed(entity))
Expand Down

0 comments on commit b9e0608

Please sign in to comment.