Go Back   Steam Users' Forums > Steam Tool Discussions > Source Coding

Reply
 
Thread Tools Display Modes
Old 06-05-2008, 06:49 AM   #1
Azaral
 
 
 
Guest
Posts: n/a
How to get info from another specific player at any time?

In my mod, players will select a target and shoot at it instead of aiming and shooting. I need to be able to save what who/what this target is and be able to draw info about the target at anytime. What is the best way to go about this? I thought about saving the target as a whole copy but I think that would only save the data at that moment and would not update. I think ehandle might be the right way to go, but I don't know how those work at all really. Any help is greatly appreciated.
 
Reply With Quote
Old 06-05-2008, 06:55 AM   #2
z33ky
 
Join Date: May 2008
Reputation: 169
Posts: 5,362
I think the UserID would be a good way to go.
But to be honest, I don't know if that's the best one.
z33ky is offline   Reply With Quote
Old 06-05-2008, 07:08 AM   #3
Varsity
 
Join Date: Jun 2004
Reputation: 489
Posts: 17,360
Code:
CBasePlayer* m_pCurTarget = MyGetTargetFunc()
That stores a pointer to the entity. You can then use "->" (instead of ".") to access its components.

You could use an EHandle too, but that makes things a bit more complex without helping you in this situation.
Varsity is offline   Reply With Quote
Old 06-05-2008, 08:40 AM   #4
Tony Sergi
 
Tony Sergi's Avatar
 
Join Date: Mar 2008
Reputation: 46
Posts: 646
ehandles are not complex varsity, and they're safe.
Tony Sergi is offline   Reply With Quote
Old 06-05-2008, 11:26 AM   #5
Azaral
 
 
 
Guest
Posts: n/a
I've read about EHANDLES on the wiki site, but I'm still not entirely sure how to use them.

The way a target is selected is by the player "shooting" but if no target is selected it will attempt to select whatever is under the crosshair via a traceline. Would I then just do something like

EHANDLE pTarget = tr.m_pent; (once it is determined the object hit is another player ofcourse)

And to access stuff would just be pTarget->GetPositionFunction() and it would be able to access that player's current position so I can use it for other things?
  Reply With Quote
Old 06-05-2008, 12:55 PM   #6
Tony Sergi
 
Tony Sergi's Avatar
 
Join Date: Mar 2008
Reputation: 46
Posts: 646
Yeah, and you can cast the ehandle to an actual player class to access stuff other than just cbaseentity.

ie: ToSDKPlayer(m_Ehandle.Get())->SomePlayerOnlyFunction();
Tony Sergi is offline   Reply With Quote
Old 06-05-2008, 04:30 PM   #7
Azaral
 
 
 
Guest
Posts: n/a
OK, great this helps a lot.
  Reply With Quote
Reply

Go Back   Steam Users' Forums > Steam Tool Discussions > Source Coding


Thread Tools
Display Modes

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



All times are GMT -7. The time now is 07:41 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
Site Content Copyright Valve Corporation 1998-2012, All Rights Reserved.