13.09.2011, 22:05
I need some help with cases.
So here is my command.
I want it so that you have to type
/color orange or /use blue
Not /use 1 or /use 2
So here is my command.
pawn Код:
CMD:color(playerid,params[])
{
new id,color,string[128];
if(sscanf(params,"ud",id,color))return SendClientMessage(playerid,COLOR_RED,"Usage:/SetColor [ID][Color]"),SendClientMessage(playerid,COLOR_ORANGE,"Type /Colors For Available Name Colors");
if (id == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOR_RED, "System: Invalid ID");
else
{
switch(color)
{
case 1:
{
SetPlayerColor(id,COLOR_ORANGE);
new name[MAX_PLAYER_NAME];
GetPlayerName(id, name, sizeof(name));
format(string, sizeof(string), "Admin %s Has Set Your Color To Orange",name);
SendClientMessage(id,COLOR_ORANGE,string);
}
case 2:
{
SetPlayerColor(id,COLOR_YELLOW);
new name[MAX_PLAYER_NAME];
GetPlayerName(id, name, sizeof(name));
format(string, sizeof(string), "Admin %s Has Set Your Color To Yellow",name);
SendClientMessage(id,COLOR_YELLOW,string);
}
case 3:
{
SetPlayerColor(id,COLOR_BLUE);
new name[MAX_PLAYER_NAME];
GetPlayerName(id, name, sizeof(name));
format(string, sizeof(string), "Admin %s Has Set Your Color To Blue",name);
SendClientMessage(id,COLOR_YELLOW,string);
}
case 4:
{
SetPlayerColor(id,COLOR_BLUE);
new name[MAX_PLAYER_NAME];
GetPlayerName(id, name, sizeof(name));
format(string, sizeof(string), "Admin %s Has Set Your Color To Red",name);
SendClientMessage(id,COLOR_RED,string);
}
case 5:
{
SetPlayerColor(id,COLOR_BLUE);
new name[MAX_PLAYER_NAME];
GetPlayerName(id, name, sizeof(name));
format(string, sizeof(string), "Admin %s Has Set Your Color To Light Blue",name);
SendClientMessage(id,COLOR_LIGHTBLUE,string);
}
}
}
return 1;
}
/color orange or /use blue
Not /use 1 or /use 2