CMDetcolor(playerid, params[]) { if (!IsPlayerAdmin(playerid)) { SendClientMessage(playerid, -1, "SERVER: Unknown command."); } else if (IsPlayerAdmin(playerid)) { SetPlayerColor(playerid, COLOR_YELLOW); SendClientMessage(playerid, COLOR_GREEN, "You succesfully changed the player his color."); } return 1; } |
CMD:setcolor(playerid, params[])
{
new id, colour;
if (IsPlayerAdmin(playerid))
SendClientMessage(playerid, -1, "SERVER: Unknown command.");
else if (sscanf(params, "ud", id, colour))
SendClientMessage(playerid, -1, "USAGE: /setcolor [ player id ] [ colour ]");
else if (id == INVALID_PLAYER_ID)
SendClientMessage(playerid, -1, "Requested player was not found!");
else
{
SetPlayerColor(id, colour);
SendClientMessage(playerid, COLOR_GREEN, "You succesfully changed the player's colour.");
}
return 1;
}
CMD:setcolor(playerid, params[]) { if (!IsPlayerAdmin(playerid)) SendClientMessage(playerid, -1, "SERVER: Unknown command."); else if (IsPlayerAdmin(playerid)) { new iTargetID, iColor; //define the variables we want the data from the command going to (written after /setcolor in-game) if(sscanf(params, "ud", iTargetID, iColor)) { SendClientMessage(playerid, -1, "USAGE: /setcolor [playerid] [color]"); //In sscanf, 'u' is a player id and 'd' is an integer SendClientMessage(playerid, -1, "Colors: 1 - Yellow, 2 - White, 3 - Red"); } /* a switch statement is like multiple 'if' and 'else if' statements however compressed to look like this rather than if(iColor == 1) iColor = 0xFFFF0000; if(iColor == 2) iColor = 0xFFFFFF00; if(iColor == 3) iColor = 0xFF0606FF; else iColor = 0xFFFFFF00; Just like if statements, brackets are optional if it is only 1 line. */ if(!IsPlayerConnected(iTargetID)) return SendClientMessage(playerid, -1, "The specified player is not connected."); switch(iColor) { case 1: iColor = 0xFFFF0000; case 2: iColor = 0xFFFFFF00; case 3: iColor = 0xFF0606FF; default: iColor = 0xFFFFFF00; //default will set the color as white if the number isnt 1, 2 or 3. } SetPlayerColor(iTargetID, iColor); SendClientMessage(playerid, COLOR_GREEN, "You succesfully changed the player his color."); } return 1; }