Raised This Month: $51 Target: $400
 12% 

[TF2] Detecting damage under specific situations


Post New Thread Reply   
 
Thread Tools Display Modes
Leonardo
Veteran Member
Join Date: Feb 2010
Location: 90's
Old 11-11-2013 , 15:33   Re: [TF2] Detecting damage under specific situations
Reply With Quote #11

and nobody even told me that I missed a part where it gets client index from event

Last edited by Leonardo; 11-11-2013 at 15:37.
Leonardo is offline
Chdata
Veteran Member
Join Date: Aug 2012
Location: Computer Chair, Illinois
Old 11-11-2013 , 17:57   Re: [TF2] Detecting damage under specific situations
Reply With Quote #12

Ah that's very interesting. Thanks for the explanation, it helps a lot. Maybe I'll even be able to make my own first plugin soon.
__________________
Chdata is offline
11530
Veteran Member
Join Date: Sep 2011
Location: Underworld
Old 11-11-2013 , 18:22   Re: [TF2] Detecting damage under specific situations
Reply With Quote #13

Quote:
Originally Posted by Leonardo View Post
and nobody even told me that I missed a part where it gets client index from event
Haha, I didn't notice that.

@Chdata Glad we could help. As Leonardo says, replace iClient in OnHookedEvent with GetEventInt(hEvent, "userid") This will get the clientid of the player who died/jumped/landed.

PHP Code:
//Edited
public OnHookedEventHandle:hEvent, const String:strEventName[], bool:bHidden 
    
SetRJFlag(GetClientOfUserId(GetEventInt(hEvent"userid")), StrEqual(strEventName"rocket_jump"false)); 
If I was writing it, I'd just keep the jumping and landing/dying events separate, to avoid having to compare strings at all. Good luck!
__________________

Last edited by 11530; 11-11-2013 at 22:02.
11530 is offline
MasterOfTheXP
Veteran Member
Join Date: Aug 2011
Location: Cloudbank
Old 11-11-2013 , 19:57   Re: [TF2] Detecting damage under specific situations
Reply With Quote #14

Shouldn't it be GetClientOfUserId(GetEventInt(hEvent, "userid"))? (Nevermind; Leonardo already fixed post 2)

And yeah, having one callback for all three event hooks is kinda neat, but will ultimately just end up being marginally slower at run-time.
__________________
Plugins / My Steam / TF2 Sandbox (plugin beta testing!)

Last edited by MasterOfTheXP; 11-11-2013 at 19:59.
MasterOfTheXP is offline
11530
Veteran Member
Join Date: Sep 2011
Location: Underworld
Old 11-11-2013 , 22:01   Re: [TF2] Detecting damage under specific situations
Reply With Quote #15

Whoops, I need to stop editing so much. But yea, though I was thinking only two events, since you can handle landing/dying with the same one.
__________________
11530 is offline
Chdata
Veteran Member
Join Date: Aug 2012
Location: Computer Chair, Illinois
Old 11-13-2013 , 04:32   Re: [TF2] Detecting damage under specific situations
Reply With Quote #16

Alright, two things:

What does the notation g_ signify?

And

Is there any reason, if g_bClientRJFlag[] is a global array, for me to just GetRJFlag(client) instead of just using the array.

Like,

if g_bClientRJFlag[client]

instead of

if GetRJFlag(client)

Also I suppose you meant OnClientPutInServer( iClient ) instead of OnClientConnect() which has 3 arguments anyway.

Edit: In any case, this seems to have worked perfectly for me (with getrjflag).

Thanks a ton!


Edit: While I'm add it, so I don't need to make a whole new thread:

Code:
                EmitSoundToClient(client, "player/spy_shield_break.wav", _, _, SNDLEVEL_TRAFFIC, SND_NOFLAGS, 0.7, 100, _, Pos, NULL_VECTOR, false, 0.0);
                EmitSoundToClient(client, "player/spy_shield_break.wav", _, _, SNDLEVEL_TRAFFIC, SND_NOFLAGS, 0.7, 100, _, Pos, NULL_VECTOR, false, 0.0);
                EmitSoundToClient(attacker, "player/spy_shield_break.wav", _, _, SNDLEVEL_TRAFFIC, SND_NOFLAGS, 0.7, 100, _, Pos, NULL_VECTOR, false, 0.0);
                EmitSoundToClient(attacker, "player/spy_shield_break.wav", _, _, SNDLEVEL_TRAFFIC, SND_NOFLAGS, 0.7, 100, _, Pos, NULL_VECTOR, false, 0.0);
I noticed in Hale that the same thing here is repeated, but for what reason? Does it make it louder? More likely to play? ???
__________________

Last edited by Chdata; 11-13-2013 at 11:55.
Chdata is offline
Leonardo
Veteran Member
Join Date: Feb 2010
Location: 90's
Old 11-13-2013 , 12:56   Re: [TF2] Detecting damage under specific situations
Reply With Quote #17

Quote:
Originally Posted by Chdata View Post
Alright, two things:

What does the notation g_ signify?

And

Is there any reason, if g_bClientRJFlag[] is a global array, for me to just GetRJFlag(client) instead of just using the array.

Like,

if g_bClientRJFlag[client]

instead of

if GetRJFlag(client)

Also I suppose you meant OnClientPutInServer( iClient ) instead of OnClientConnect() which has 3 arguments anyway.

Edit: In any case, this seems to have worked perfectly for me (with getrjflag).

Thanks a ton!
g_ means global, but hat isn't important, rename it as you wish.

GetRJFlag also checks if passed clientid is real so you never get Array out of bounds EГГOГ.

C++ example

Last edited by Leonardo; 11-13-2013 at 12:57.
Leonardo is offline
Chdata
Veteran Member
Join Date: Aug 2012
Location: Computer Chair, Illinois
Old 11-13-2013 , 20:45   Re: [TF2] Detecting damage under specific situations
Reply With Quote #18

Alright. I tried making my own version that detects airblasts and such.

PHP Code:
#pragma semicolon 1
#include <sourcemod>

new bool:g_bClientAirblastFlag[MAXPLAYERS+1] = { false, ... };
new 
g_iDeflector[MAXPLAYERS+1] = { 0, ... };

public 
OnPluginStart()
{
    
HookEvent"object_deflected"OnHookedEvent );
    
HookEvent"player_death"OnHookedEvent );
}

public 
OnClientConnectiClient )
    
SetAirblastFlag0iClientfalse );

public 
OnClientDisconnectiClient )
    
SetAirblastFlag0iClientfalse );

public 
OnHookedEventHandle:hEvent, const String:strEventName[], bool:bHidden )
{
    new 
iDeflector GetClientOfUserId(GetEventInt(event"userid"));
    new 
iOwner GetClientOfUserId(GetEventInt(event"ownerid"));
    new 
iWeaponid GetEventInt(event"weaponid");
    
//new iPos = GetEntityFlags(iOwner);
    
new bool:bBlast = ( StrEqualstrEventName"object_deflected"false weaponid == ) ? true false;

    
SetAirBlastFlagiDeflectoriOwnerbBlast );
}

stock GetAirblastFlagiClient )
    return ( 
iClient <= MaxClients && IsClientInGameiClient ) && IsPlayerAliveiClient ) ? g_bClientAirblastedFlag[iClient] : false );

stick GetAirblasteriDeflector //Aka iAttacker
    
return ( iDeflector <= MaxClients && IsClientInGameiDeflector ) && IsPlayerAliveiDeflector ) ? g_iDeflector[iDeflector] : );

stock SetAirblastFlagiDeflectoriClientbool:bState )
{
    
g_iDeflector[iDeflector] = ( iDeflector <= MaxClients ) ? iDeflector 0;
    if( 
iClient <= MaxClients )
        
g_bClientAirblastFlag[iClient] = bState;

It's not finished though. I need to add the following:

PHP Code:
                    new iPos GetEntityFlags(client);
                    new 
bool:bPos = ( (iPos FL_ONGROUND) || (iPos FL_INWATER) ) ? false true;
                    if (!
bPos)
                    {
                        
SetAirBlastFlag(attackerclientfalse); //I could also just set it to bPos since it'll always by false at this point
                    

Also what is m_ /what is this notation called ;?
__________________

Last edited by Chdata; 11-16-2013 at 05:31.
Chdata is offline
VoiDeD
AlliedModders Donor
Join Date: Mar 2009
Location: Illinois, USA
Old 11-14-2013 , 01:40   Re: [TF2] Detecting damage under specific situations
Reply With Quote #19

Quote:
Originally Posted by Chdata View Post
Also what is m_ /what is this notation called ;?
m_ implies "member", for member variables of structs or classes.

Just a small part of the madness that is Hungarian notation.
__________________

Last edited by VoiDeD; 11-14-2013 at 01:41.
VoiDeD 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 20:45.


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