Raised This Month: $ Target: $400

Solved Get player info from CTFPlayer *

Post New Thread Reply   
Thread Tools Display Modes
Author Message
Junior Member
Join Date: Jan 2021
Old 05-17-2021 , 18: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 19:16.
dietcoke is offline
Veteran Member
Join Date: Nov 2012
Location: Serbia
Old 05-27-2021 , 17: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 17:34.
kadet.89 is offline
Send a message via Skype™ to kadet.89

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 11:08.

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