Posts: 10,066
Threads: 38
Joined: Sep 2007
Reputation:
0
u for user, h or x for a hexadecimal number. Although requesting raw hex colors isn't very user friendly. I would recommend letting the user choose from a list or preparing a pallet of swatches to choose from. Perhaps still keeping the raw input as a fallback.
Posts: 3,324
Threads: 96
Joined: Sep 2013
Код:
SSCANF:color(string[])
{
static ColorName[6][] =
{
{"Red"}, {"Orange"}, {"Yellow"}, {"Green"}, {"Blue"}, {"Purple"}
};
new ret = -1;
for(new i = 0; i < 5; i++) if(strfind(ColorName[i], string, true) != -1)
{
ret = i;
break;
}
switch (ret)
{
case 0: return COLOR_RED;
case 1: return COLOR_ORANGE;
case 2: return COLOR_YELLOW;
case 3: return COLOR_GREEN;
case 4: return COLOR_BLUE;
case 5: return COLOR_PURPLE;
default: return -1;
}
}
CMD:setcolor(playerid, params[])
{
if(!IsPlayerAdmin(playerid))
return 0;
new Target, Color;
if(sscanf(params, "uk<color>", Target, Color))
return SendClientMessage(playerid, -1, "Error: /setcolor [ID] [COLOR]");
else if(Color == -1)
return SendClientMessage(playerid, -1, "Error: Color must be Red, Orange, Yellow, Green, Blue, or Purple.");
else
{
SetPlayerColor(Target, Color);
SendClientMessage(playerid, COLOR_LIME, "You have a player's color.");
SendClientMessage(Target, COLOR_LIME, "An admin set your color.");
}
return 1;
}
Posts: 1,147
Threads: 109
Joined: Jul 2013
Reputation:
0
Ok appreciated guys, although I do not really understand what you meant Vince.
OFF: Eey je bent belgisch ehhe, ik nederlands, geef je skype dan.
Posts: 3,324
Threads: 96
Joined: Sep 2013
Quote:
Originally Posted by saffierr
Ok appreciated guys, although I do not really understand what you meant Vince.
OFF: Eey je bent belgisch ehhe, ik nederlands, geef je skype dan.
|
I update my code, it now uses an SSCANF (k)custom specifier. You can add more colors to the list if you like.
Posts: 1,147
Threads: 109
Joined: Jul 2013
Reputation:
0
Yo Crayder it's really really high appreciated bro, I just get the Last part, I don't get the SSCANF part. I hope you could explain me that, through PM.
Thanks!!!
Posts: 1,147
Threads: 109
Joined: Jul 2013
Reputation:
0
Yeah I read that, but I just don't understand how to use it.