09.06.2012, 10:49
(
Последний раз редактировалось Neil.; 04.02.2013 в 17:44.
)
fixed
CMD:ken(playerid, params[]) {
new
szPlayerName[MAX_PLAYER_NAME],
iKen = INVALID_PLAYER_ID; // We'll assign "INVALID_PLAYER_ID" to this, we know Ken isn't online if INVALID_PLAYER_ID is the value of 'iKen' at the end, otherwise it will change to the actual player ID of Ken while he's online.
for(new i = 0; i < MAX_PLAYERS; i++) { // Looping through every player online
if(IsPlayerConnected(i)) { // Confirming they're connected
GetPlayerName(i, szPlayerName, MAX_PLAYER_NAME); // Getting their name and storing it in a variable so we can reference it against "Ken"
if(!strcmp(szPlayerName, "Ken", true)) { // Referencing the name against "Ken". Is it Ken?
iKen = i; // If it's Ken, we're getting his player ID here.
}
}
}
if(iKen != INVALID_PLAYER_ID) { // Is Ken online? If 'iKen' is not INVALID_PLAYER_ID then it would appear he is!
new
szMessage[128]; // Let's create a string so we can format a message for him
// Ken is online. Here's a message for Ken!
GetPlayerName(playerid, szPlayerName, MAX_PLAYER_NAME);
format(szMessage, sizeof(szMessage), "%s sent you a message: %s", szPlayerName, params);
SendClientMessage(iKen, 0xFFFFFFFF, szMessage);
SendClientMessage(playerid, 0xFFFFFFFF, "Your message has been sent to Ken.");
} else SendClientMessage(playerid, 0xFFFFFFFF, "Ken is not online at the moment"); // Unfortunately, he's not online. We'll tell the command executer that.
return 1;
}
if(!strcmp(szPlayerName, "Neil", true))