Command Callback Helpers: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
mNo edit summary
 
m (→‎top: clean up, added orphan tag)
 
Line 1: Line 1:
{{Orphan|date=January 2024}}
;CBasePlayer *UTIL_PlayerByIndex( int playerIndex ):This is a function that returns a [[CBasePlayer]] pointer to a player by index. It only returns if the player is spawned and connected, otherwise it returns NULL.
;CBasePlayer *UTIL_PlayerByIndex( int playerIndex ):This is a function that returns a [[CBasePlayer]] pointer to a player by index. It only returns if the player is spawned and connected, otherwise it returns NULL.
;CBasePlayer* UTIL_PlayerByName( const char *name ):This is a function that returns a [[CBasePlayer]] pointer to a player by name. It only returns if the player is spawned and connected, otherwise it returns NULL.
;CBasePlayer* UTIL_PlayerByName( const char *name ):This is a function that returns a [[CBasePlayer]] pointer to a player by name. It only returns if the player is spawned and connected, otherwise it returns NULL.
;CBasePlayer* UTIL_PlayerByUserId( int userID ):This is a function that returns a [[CBasePlayer]] pointer to a player by user ID. It only returns if the player is spawned and connected, otherwise it returns NULL.
;CBasePlayer* UTIL_PlayerByUserId( int userID ):This is a function that returns a [[CBasePlayer]] pointer to a player by user ID. It only returns if the player is spawned and connected, otherwise it returns NULL.


;bool UTIL_IsCommandIssuedByServerAdmin( void ):This is a function that takes no parameters and returns true if the current command is issued by an admin.  This function returns true when a command is issued by a dedicated server console or a listen server host.
;bool UTIL_IsCommandIssuedByServerAdmin( void ):This is a function that takes no parameters and returns true if the current command is issued by an admin.  This function returns true when a command is issued by a dedicated server console or a listen server host.
;int UTIL_GetCommandClientIndex( void ):This is a function that returns the client index of the current command.  This function returns 0 when the command is issued by a dedicated server console; Otherwise, it returns an integer [1, maxplayers] for the player.
;int UTIL_GetCommandClientIndex( void ):This is a function that returns the client index of the current command.  This function returns 0 when the command is issued by a dedicated server console; Otherwise, it returns an integer [1, maxplayers] for the player.
;CBasePlayer *UTIL_GetCommandClient( void ):This is a function that retrieves the client index and gets the player by the returned index for you.  It returns a [[CBasePlayer]] pointer; the returned value is null if the command is issued by a dedicated server console.
;CBasePlayer *UTIL_GetCommandClient( void ):This is a function that retrieves the client index and gets the player by the returned index for you.  It returns a [[CBasePlayer]] pointer; the returned value is null if the command is issued by a dedicated server console.
[[Category:Helpers]]
[[Category:Helpers]]

Latest revision as of 22:38, 21 January 2024

CBasePlayer *UTIL_PlayerByIndex( int playerIndex )
This is a function that returns a CBasePlayer pointer to a player by index. It only returns if the player is spawned and connected, otherwise it returns NULL.
CBasePlayer* UTIL_PlayerByName( const char *name )
This is a function that returns a CBasePlayer pointer to a player by name. It only returns if the player is spawned and connected, otherwise it returns NULL.
CBasePlayer* UTIL_PlayerByUserId( int userID )
This is a function that returns a CBasePlayer pointer to a player by user ID. It only returns if the player is spawned and connected, otherwise it returns NULL.
bool UTIL_IsCommandIssuedByServerAdmin( void )
This is a function that takes no parameters and returns true if the current command is issued by an admin. This function returns true when a command is issued by a dedicated server console or a listen server host.
int UTIL_GetCommandClientIndex( void )
This is a function that returns the client index of the current command. This function returns 0 when the command is issued by a dedicated server console; Otherwise, it returns an integer [1, maxplayers] for the player.
CBasePlayer *UTIL_GetCommandClient( void )
This is a function that retrieves the client index and gets the player by the returned index for you. It returns a CBasePlayer pointer; the returned value is null if the command is issued by a dedicated server console.