G.IsEnemyEntityName

From GMod Wiki

Jump to: navigation, search
Function
Syntax IsEnemyEntityName( victimtype )
Where is this used?
Description:
Tests is an NPC hostile to the player.
Returns: Boolean
Part of Library: Global Functions
Realm: NewerShared.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=G.IsEnemyEntityName]G.IsEnemyEntityName [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]


Examples

DescriptionGives or takes 1 frag from the player depending on hostility of the killed NPC.
Used onNewerShared.png
Code
 
hook.Add("OnNPCKilled","RewardOrPunish",function(npc,ply)
 if IsEnemyEntityName(npc:GetClass()) then
  ply:AddFrags(1)
 elseif IsFriendEntityName(npc:GetClass()) then
  ply:AddFrags(-1)
 end
end)
 
OutputN/A

Additional Notes

npc_antlionnpc_antlion_workernpc_antlionguard
npc_breennpc_combine_snpc_cscanner
npc_fastzombienpc_fastzombie_torsonpc_gman
npc_headcrabnpc_headcrab_fastnpc_headcrab_poison
npc_hunternpc_manhacknpc_poisonzombie
npc_zombienpc_zombie_torsonpc_zombine
Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox