AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Coding MM:S Plugins & SM Extensions (https://forums.alliedmods.net/forumdisplay.php?f=75)
-   -   Solved Get player info from CTFPlayer * (https://forums.alliedmods.net/showthread.php?t=332531)

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 23:45.

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