IPlayerInfo
Jump to navigation
Jump to search
IPlayerInfo
is an interface used to access server information about connected users from other libraries. It is accessed through an IPlayerInfoManager
global.

INetChannelInfo
provides some information, but otherwise...Todo: solution?
Example
#include "game/server/iplayerinfo.h"
static IPlayerInfoManager* playerinfomanager; // recommended
bool CMyServerPlugin::Load(CreateInterfaceFn interfaceFactory, CreateInterfaceFn gameServerFactory)
{
playerinfomanager = (IPlayerInfoManager*)gameServerFactory(INTERFACEVERSION_PLAYERINFOMANAGER,NULL);
if (!playerinfomanager)
{
Warning("Could not access IPlayerInfoManager!\n");
return false;
}
IPlayerInfo* info = playerinfomanager->GetPlayerInfo(engine->PEntityOfEntIndex(1)); // first player
if (info)
Msg("Player 1 is %s, with %i health\n",info->GetName(),info->GetHealth());
else
Msg("Player 1 has not spawned\n");
return true;
}