Isigar

Is ped see you?

Aug 31st, 2021
1,258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.73 KB | None | 0 0
  1.  
  2. function hasClearLos(guardPedId, guardCoords, ped, pedCoords)
  3.     local dist = #(guardCoords-pedCoords)
  4.     if dist < Config.NearDistanceAlarm then
  5.         local clearLos = HasEntityClearLosToEntity(guardPedId, ped, 17)
  6.         if clearLos then
  7.             return IsPedFacingPed(guardPedId, ped, 45.0)
  8.         end
  9.         return false
  10.     end
  11.     return false
  12. end
  13.  
  14. function isPlayerNearGuard()
  15.     local ped = PlayerPedId()
  16.     local coords = GetEntityCoords(ped)
  17.     for _, lPedId in pairs(localPeds) do
  18.         local guardCoords = GetEntityCoords(lPedId)
  19.         if not IsPedDeadOrDying(lPedId) and hasClearLos(lPedId, guardCoords, ped, coords) then
  20.             return true, lPedId
  21.         end
  22.     end
  23.  
  24.     return false
  25. end
  26.  
Advertisement
Add Comment
Please, Sign In to add comment