Raised This Month: $67 Target: $400
 16% 

Solved Get player info from CTFPlayer *


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
dietcoke
Junior Member
Join Date: Jan 2021
Old 05-17-2021 , 17:22   Get player info from CTFPlayer *
Reply With Quote #1

I am writing an extension and am hooking a function that is only passed a CTFPlayer * as a parameter. Does anyone know how to get player info from it, such as steam id / ip address / userid, etc?

And conversely, is there a way to get the CTFPlayer * from a player's userid? Thanks.

Last edited by dietcoke; 05-19-2021 at 18:16.
dietcoke is offline
kadet.89
Veteran Member
Join Date: Nov 2012
Old 05-27-2021 , 16:28   Re: Get player info from CTFPlayer *
Reply With Quote #2

In case somebody needs it. The pointer can be cast to IServerEntity. This interface has a method to get the entity index:
(IServerEntity -> IServerUnknown -> IHandleEntity -> GetRefEHandle)
const CBaseHandle& baseHandle = baseEntity_->GetRefEHandle();
int index = baseHandle.GetEntryIndex();

Then the info can be received this way:
IGamePlayer * player = playerhelpers->GetGamePlayer(index);

Last edited by kadet.89; 05-27-2021 at 16:34.
kadet.89 is offline
Send a message via Skype™ to kadet.89
Reply


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

Forum Jump


All times are GMT -4. The time now is 17:59.


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