AlliedModders (
-   Coding MM:S Plugins & SM Extensions (
-   -   Solved Get player info from CTFPlayer * (

dietcoke 05-17-2021 17:22

Get player info from CTFPlayer *
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.

kadet.89 05-27-2021 16:28

Re: Get player info from CTFPlayer *
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);

All times are GMT -4. The time now is 19:54.

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