• SWEP, Detecting bullet hit target, perform action based on targets role
    1 replies, posted
This is for TTT, I have a SWEP I've been working on but I'm having trouble figuring out how to detect a hit against the target and evaluate what role they are, "IE: traitor, detective, etc", I want this to only occur if the bullet has reached and hit the end target, I don't want to detect anything in between. The whole weapon is written, aside from this core logic, can someone please provide me with a "best practice" example of how this is generally achieved? Thank you.
What you want to do is call the EntityTakeDamage hook and then use the target parameter to see what role the person who got hit is. Next you need to check that the weapon that the person was hit with is the SWEP that you want to do that action with, in this case use the dmginfo parameter with dmginfo:GetInflictor() and then run a check to see if the weapon used was the SWEP. Here is the EntityTakeDamage hook [URL="http://gmodwiki.net/Lua/Classes/CTakeDamageInfo/GetInflictor"]http://gmodwiki.net/Lua/Classes/CTakeDamageInfo/GetInflictor[/URL]
Sorry, you need to Log In to post a reply to this thread.