27.10.2010, 10:19
Hi im looking to make a command that you type /id then the players name and it will come up with there id where is a good place to start with a command like this.
CMD:id(playerid, params[]) { // Command initializer for zcmd
new
_playerID; // Create a variable for sscanf to process
if(sscanf(params, "u", _playerID)) { // Using sscanf to parse the result.
return SendClientMessage(playerid, SOME_COLOR, "Syntax: /id [playerid]"); // Send them a message showing the usage of the command (they didn't use the proper command usage). Define SOME_COLOR or replace it
}
else { // They added the proper usage. Continue with the code.
if(_playerID == INVALID_PLAYER_ID) return SendClientMessage(playerid, SOME_COLOR, "That person is not connected."); // Send them a message, the ID/name is not connected
// If it continues past the code above (^), then the player is connected.
new
_playerMsgFormatSz[50], // Create the variable to format the message we'll send.
_playerNameSz[MAX_PLAYER_NAME]; // Create the variable to retrieve the players name.
GetPlayerName(_playerID, _playerNameSz, MAX_PLAYER_NAME); // Get the players name.
format(_playerMsgFormatSz, sizeof(_playerMsgFormatSz), "%s (%d) is connected.", _playerNameSz, _playerID); // Format the message.
return SendClientMessage(playerid, SOME_COLOR, _playerMsgFormatSz); // Send the message
}
}