Created 1 year ago2022-12-04 22:35:55 UTC by JacksBestGaming
void PrintPlayerName()
{
if (CMD_ARGC() < 1)
{
g_engfuncs.pfnServerPrint("Usage: print_player_name <player_index>\n");
return;
}
const int index = atoi(CMD_ARGV(1));
CBaseEntity* player = UTIL_PlayerByIndex(index);
if (!player)
{
return;
}
g_engfuncs.pfnServerPrint(UTIL_VarArgs("Player name: %s\n"), STRING(player->pev->netname));
}
// Somewhere in startup code.
g_engfuncs.pfnAddServerCommand("print_player_name", &PrintPlayerName);
This command prints the name of the player at the given index, or nothing if the player slot isn't in use.