Raised This Month: $ Target: $400
 0% 

[TF2] Getting attacker


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Michalplyoutube
Veteran Member
Join Date: Jan 2013
Location: Tank Carrier in Mannhatt
Old 12-04-2014 , 06:18   [TF2] Getting attacker
Reply With Quote #1

So how do i detect attacker (red spy)
I have tried

Code:
        new TFClassType:iClass = TF2_GetPlayerClass(client);
        new attacker = iClass == TFClass_Spy && GetClientTeam(client) == _:TFTeam_Red;
and it didn't worked
__________________
The plugin developer of TF2BWR Reborn
And a TF2 Player
Michalplyoutube is offline
Wliu
Veteran Member
Join Date: Apr 2013
Old 12-04-2014 , 14:10   Re: [TF2] Getting attacker
Reply With Quote #2

It would be nice seeing what context 'client' has. If this is in OnTakeDamage/player_hurt (which I suspect it is), you should be using the 'attacker' value...
__________________
~Wliu
Wliu is offline
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 12-04-2014 , 14:23   Re: [TF2] Getting attacker
Reply With Quote #3

PHP Code:
new attacker iClass == TFClass_Spy && GetClientTeam(client) == _:TFTeam_Red
What is this line even supposed to do? Why do you have multiple = and == in there? And why the && if you're assigning a integer value to attacker?

Please, before you go any further, look up some programming/scripting basics.
__________________
ddhoward is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 12-04-2014 , 14:35   Re: [TF2] Getting attacker
Reply With Quote #4

Quote:
Originally Posted by ddhoward View Post
PHP Code:
new attacker iClass == TFClass_Spy && GetClientTeam(client) == _:TFTeam_Red
What is this line even supposed to do? Why do you have multiple = and == in there? And why the && if you're assigning a integer value to attacker?

Please, before you go any further, look up some programming/scripting basics.
Due to operator precedence, it *should* be valid code for saving a boolean value into a variable due to order precedence. In this case, it's saving true if the player is a red spy. However, what's NOT explained is why he expects this to return the attacker. (also, the variable should be tagged as bool)

(also, it wouldn't be valid if #include <tf2> isn't present above it to define the TFTeam enum)
__________________
Not currently working on SourceMod plugin development.
Powerlord 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 02:09.


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