Raised This Month: $ Target: $400
 0% 

[TF2] How to tell which weapon is causing damage


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Order66
Member
Join Date: May 2008
Old 08-01-2008 , 11:46   [TF2] How to tell which weapon is causing damage
Reply With Quote #1

Hi, how can I identify which class/weapon is causing damage (not which the player was killed by)?

im trying to make a script so that players can only be damaged by soldiers.

thanks
Order66 is offline
DiscoBBQ
Veteran Member
Join Date: Jan 2005
Location: Clemson, South Carolina
Old 08-01-2008 , 15:13   Re: [TF2] How to tell which weapon is causing damage
Reply With Quote #2

See below
__________________
"Every man is guilty of all the good he did not do"

Last edited by DiscoBBQ; 08-01-2008 at 15:14. Reason: Double Post
DiscoBBQ is offline
DiscoBBQ
Veteran Member
Join Date: Jan 2005
Location: Clemson, South Carolina
Old 08-01-2008 , 15:14   Re: [TF2] How to tell which weapon is causing damage
Reply With Quote #3

Code:
//Damage:
public Action:EventDamage(Handle:Event, const String:Name[], bool:Broadcast)
{
 
 //Declare:
 decl Attacker;
 decl String:WeaponName[32];
 
 //Initialize:
 Attacker = GetClientOfUserId(GetEventInt(Event, "attacker"));
 
 //World:
 if(Attacker == 0) return Plugin_Handled;
 
 //Weapon:
 GetClientWeapon(Attacker, WeaponName, 32);
 
 //Rocket:
 if(StrEqual("ROCKETNAMEWHATEVER", WeaponName, false))
 {
 
 //Do Work:
 }
}
 
//Initation:
public OnPluginStart()
{
 
 //Events: 
 HookEvent("player_hurt", EventDamage);
}
__________________
"Every man is guilty of all the good he did not do"
DiscoBBQ is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 08-01-2008 , 15:46   Re: [TF2] How to tell which weapon is causing damage
Reply With Quote #4

This can cause some problems with weapons that have a delayed effect (rockets, grenades, etc) if the attacker changes weapons or dies before the victim takes the damage. Also, it will cause problems if a sentry shoots a player, because it registers as the engineer doing the damage, not the sentry.
bl4nk is offline
Order66
Member
Join Date: May 2008
Old 08-01-2008 , 19:53   Re: [TF2] How to tell which weapon is causing damage
Reply With Quote #5

thanks for the quick reply!

now is it possible to also reverse this if statement so its like:

//immune to knife
if(StrNotEqual("knife", WeaponName, false))
{

//Do Work:
//blahblahblah?

}
Order66 is offline
pRED*
Join Date: Dec 2006
Old 08-01-2008 , 20:01   Re: [TF2] How to tell which weapon is causing damage
Reply With Quote #6

it's !
pRED* is offline
#Barracuda
Junior Member
Join Date: May 2008
Location: Germany
Old 08-02-2008 , 00:09   Re: [TF2] How to tell which weapon is causing damage
Reply With Quote #7

According to ent_info, the player entity got the input SetDamageFilter, perhaps you could also create a filter_class entity with tf_projectile_rocket as class and fire this entity input to all player entities. This should make all players vulnable to rockets only, if I got that right.
#Barracuda is offline
Order66
Member
Join Date: May 2008
Old 08-02-2008 , 08:12   Re: [TF2] How to tell which weapon is causing damage
Reply With Quote #8

excellent, lets see if i can script this properly now

thanks for your help!
Order66 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 11:49.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode