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

[TF2] Who is a player spectating?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
NIGathan
Senior Member
Join Date: Aug 2011
Location: /dev/null
Old 09-01-2011 , 15:47   [TF2] Who is a player spectating?
Reply With Quote #1

Im trying to print text to a client based on who they are spectating.

PHP Code:
for (new 1<= MaxClientsi++)
{
    if (!
IsValidEntity(i) || !IsClientInGame(i)) continue;
    if ((
GetClientTeam(i) == 1) && (GetEntPropEnt(iProp_Send"m_hObserverTarget") == client))
    {
        
PrintCenterText(i,"%i%"RoundFloat((PlayerSpeed/speedPercentage) * (speedPercentage == 1.0 100)));
    }

It simply doesn't work.

I believe the problem lies in this line: if ((GetClientTeam(i) == 1) && (GetEntPropEnt(i, Prop_Send, "m_hObserverTarget") == client))

Is the value returned by GetEntPropEnt() in the client index format?
If not, how would I convert it to the index, or convert the index to the entity?

Thanks.
NIGathan is offline
Antithasys
Moderator
Join Date: Apr 2008
Old 09-01-2011 , 16:01   Re: [TF2] Who is a player spectating?
Reply With Quote #2

PHP Code:
new iTarget GetEntPropEnt(clientProp_Send"m_hObserverTarget"); 
Returns the enity index of whatever the player is spectating. Does not have to be a player; it could be a sentry gun or whatever.

Also, be careful with the mode.
PHP Code:
#define SPECMODE_NONE                0
#define SPECMODE_FIRSTPERSON        4
#define SPECMODE_3RDPERSON            5
#define SPECMODE_FREELOOK             6

new iSpecMode GetEntProp(clientProp_Send"m_iObserverMode"); 
If it's not 1st, or 3rd, person, then the entity index would be invalid i think.
__________________
[my plugins]

When you think about asking a question... consider what have you tried?
Antithasys is offline
NIGathan
Senior Member
Join Date: Aug 2011
Location: /dev/null
Old 09-01-2011 , 16:10   Re: [TF2] Who is a player spectating?
Reply With Quote #3

So you're saying, if I'm 'myself' spectating 'client' in first or third person then..
GetEntPropEnt(myself, Prop_Send, "m_hObserverTarget") == client
?

Last edited by NIGathan; 09-01-2011 at 16:13.
NIGathan is offline
Antithasys
Moderator
Join Date: Apr 2008
Old 09-01-2011 , 16:13   Re: [TF2] Who is a player spectating?
Reply With Quote #4

Correct.

Edit:

While an older plugin with a few small bugs... this plugin should help you with code examples.

Edit Edit:

This is bad...
PHP Code:
GetClientTeam(i) == 
Use: IsClientObserver()
__________________
[my plugins]

When you think about asking a question... consider what have you tried?

Last edited by Antithasys; 09-01-2011 at 16:17.
Antithasys is offline
NIGathan
Senior Member
Join Date: Aug 2011
Location: /dev/null
Old 09-01-2011 , 16:18   Re: [TF2] Who is a player spectating?
Reply With Quote #5

Awesome, thanks a lot!
NIGathan 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 23:09.


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