Advertisement
Shark_vil

Untitled

May 6th, 2025
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.30 KB | Gaming | 0 0
  1. -- Three different options for ignoring police players for police NPCs. Use only the one that is most suitable, or modify it for yourself.
  2.  
  3. local _isValid = IsValid
  4. hook.Add('BGN_PreReactionTakeDamage', 'BGN_DarkRPPoliceTeamIgnore', function(attacker, target)
  5.     if not _isValid(attacker) or not attacker:IsPlayer() or not attacker:isCP() then return end
  6.     local actor = bgNPC:GetActor(target)
  7.     if actor and actor:HasTeam('police') then return true end
  8. end)
  9.  
  10. local _isValid = IsValid
  11. hook.Add('BGN_PreReactionTakeDamage', 'BGN_DarkRPPoliceTeamIgnore', function(attacker, target)
  12.     if not _isValid(attacker) or not attacker:IsPlayer() or attacker:Team() ~= TEAM_POLICE then return end
  13.     local actor = bgNPC:GetActor(target)
  14.     if actor and actor:HasTeam('police') then return true end
  15. end)
  16.  
  17. local _isValid = IsValid
  18. local _valid_teams, _table_HasValueBySeq
  19. hook.Add('BGN_PreReactionTakeDamage', 'BGN_DarkRPPoliceTeamIgnore', function(attacker, target)
  20.     if not _isValid(attacker) or not attacker:IsPlayer() then return end
  21.     local actor = bgNPC:GetActor(target)
  22.     if not actor or not actor:HasTeam('police') then return end
  23.     _valid_teams = _valid_teams or { TEAM_POLICE }
  24.     _table_HasValueBySeq = _table_HasValueBySeq or table.HasValueBySeq
  25.     if _table_HasValueBySeq(_valid_teams, attacker:Team()) then return true end
  26. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement