C4 Engine
C4 Engine API Documentation

class Player

Defined in:  C4Messages.h
Represents a machine connected to a multiplayer game.
Definition

class Player : public MapElement<Player>, public LinkTarget<Player>, public Completable<Player>

Member Functions
Player::GetPlayerKey Returns the key associated with a player.
Player::GetPlayerName Returns the name of a player.
Player::SetPlayerName Sets the name of a player.
Player::GetNetworkPing Returns the most recent ping between the local machine and the machine associated with a player.
 
Player::SendMessage Sends a message to a specific player in a multiplayer game.
Player::RequestFile Attempts to initiate a file transfer from a player.
Player::SendingFile Returns a boolean value indicating whether a file is currently being sent to a player.
Player::ReceivingFile Returns a boolean value indicating whether a file is currently being received from a player.
Player::GetFileChunkSize Returns the maximum size of each packet sent during a file transfer.
Player::GetFileChunkCount Returns the number of packets sent at one time during a file transfer.
Player::SetFileChunkParams Returns the number of packets sent at one time during a file transfer.
Player::GetReceiveFileSize Returns the size of the file being received from a player.
Player::GetReceiveFilePosition Returns the current position in the file being received from a player.
Player::GetFileTransferResult Returns the result of the most recent file transfer from a player.
 
Player::GetChatSoundGroup Returns the sound group to which a player's voice chat belongs.
Player::SetChatSoundGroup Sets the sound group to which a player's voice chat belongs.
Player::GetChatVolume Returns the volume for a particular player's voice chat.
Player::SetChatVolume Sets the volume for a particular player's voice chat.
Constructor

explicit Player(PlayerKey key);

Parameters
key The unique player ID assigned to the player. The server always uses the special key kPlayerServer.
Description
Player objects represent machines in a multiplayer game.
NOTE. It is not necessary to explicitly construct Player objects. The Message Manager creates new player objects automatically for itself and new clients as they join a game.
The Message Manager maintains a list of players that can be accessed by calling the MessageMgr::GetFirstPlayer function or MessageMgr::GetPlayer function.

Messages can be sent to a player by calling the Player::SendMessage function. It is also possible to send messages by calling the MessageMgr::SendMessage function, specifying the player key corresponding to the intended recipient.
Base Classes
MapElement<Player> All Player objects area stored in a map maintained by the Message Manager.
LinkTarget<Player> Used internally by the Message Manager.
Completable<Player> Used for file transfers. The completion callback function is invoked when a file transfer completes or results in an error.
See Also

MessageMgr

MessageMgr::SetPlayerCreator