I want to make a plugin to detect whether player is in my range when I using Taser. Is there are any ways to make it come true? (Sorry for my bad english, its not my main language)
Yes, something like this is possible with a SourceMod plugin. There are SDKHooks that will allow you to know when a player has the taser equipped; I would try SDKHook_WeaponSwitchPost and you may need to look at the classname of the weapon to see if it's the taser or not.
Once you know the taser is the active weapon then you'll need to script a way to detect whether the enemy player is in range or not. There are several options available there - one would be to loop through all clients and get the distance between the player with the taser and the enemy players and if at least one is within range then provide that indication to the player with the taser. You may also consider using TraceRay to see if you're actively looking at an enemy player and then check if the distance is within a certain amount to that particular enemy player.
here is something... wierd content
- When ever you hold taser, 1 sec timer will run repeatly.
- Print in chat player count and names what are in range.
- Some wierd angle check, look players front of you 80 degree wide area wher you aim or something like that.
Yes, something like this is possible with a SourceMod plugin. There are SDKHooks that will allow you to know when a player has the taser equipped; I would try SDKHook_WeaponSwitchPost and you may need to look at the classname of the weapon to see if it's the taser or not.
Once you know the taser is the active weapon then you'll need to script a way to detect whether the enemy player is in range or not. There are several options available there - one would be to loop through all clients and get the distance between the player with the taser and the enemy players and if at least one is within range then provide that indication to the player with the taser. You may also consider using TraceRay to see if you're actively looking at an enemy player and then check if the distance is within a certain amount to that particular enemy player.
Thanks to answer, but I have another question, can I detect the taser's damage to player? as far as I know, the Taser has damage attenuation when player is out-of-range and I don't know how many damage attenuation per hammer units
here is something... wierd content
- When ever you hold taser, 1 sec timer will run repeatly.
- Print in chat player count and names what are in range.
- Some wierd angle check, look players front of you 80 degree wide area wher you aim or something like that.
Thanks to answer, but I have another question, can I detect the taser's damage to player? as far as I know, the Taser has damage attenuation when player is out-of-range and I don't know how many damage attenuation per hammer units
If you need to modify the taser damage then use SDKHook_OnTakeDamage; for example, use that SDKHook if you want to remove the damage attentuation for the taser and cause it to kill anyone within range.