Any Mistake Here? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Any Mistake Here? (
/showthread.php?tid=292208)
Any Mistake Here? -
DragonYancy - 23.10.2011
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
return 0;
}
COMMAND:SetColor(playerid,params[])
{
new stat[20];
if(sscanf(params,"s[20]",stat))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE:/color [ColorName]");
SendClientMessage(playerid, COLOR_YELLOW, "Color - Yellow / Red / Gray / Orange / Indigo / Black / DarkGray");
SendClientMessage(playerid, COLOR_YELLOW, "Color - LightBlue / Purple / Blue / Pink / BrightRed / Green / White");
return 1;
}
if(!strcmp(stat,"Yellow",true))
{
format(String,sizeof(String),"Your color has changed.");
SendClientMessage(playerid,COLOR_YELLOW,String);
SetPlayerColor(playerid,COLOR_YELLOW);
return 1;
}
else
else if(!strcmp(stat,"DarkGrey",true))
{
format(String,sizeof(String),"Your color has changed.");
SendClientMessage(playerid,COLOR_DARKGREY,String);
SetPlayerColor(playerid,COLOR_DARKGREY);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_YELLOW, "Color - Yellow / Red / Gray / Orange / Indigo / Black / DarkGray");
SendClientMessage(playerid, COLOR_YELLOW, "Color - LightBlue / Purple / Blue / Pink / BrightRed / Green / White");
}
return 1;
}
No error or warning but It does not work
Re: Any Mistake Here? -
SmiT - 23.10.2011
pawn Код:
COMMAND:SetColor(playerid,params[])
{
new stat[ 20 ];
if( sscanf( params,"s[20]", stat ) )
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE:/color [ColorName]");
SendClientMessage(playerid, COLOR_YELLOW, "Color - Yellow / Red / Gray / Orange / Indigo / Black / DarkGray");
SendClientMessage(playerid, COLOR_YELLOW, "Color - LightBlue / Purple / Blue / Pink / BrightRed / Green / White");
return true;
}
if( !strcmp( stat,"Yellow",true ) )
{
format(String,sizeof(String),"Your color has changed.");
SendClientMessage(playerid,COLOR_YELLOW,String);
SetPlayerColor(playerid,COLOR_YELLOW);
return true;
}
else if( !strcmp( stat,"DarkGrey",true ) )
{
format(String,sizeof(String),"Your color has changed.");
SendClientMessage(playerid,COLOR_DARKGREY,String);
SetPlayerColor(playerid,COLOR_DARKGREY);
return true;
}
else
{
SendClientMessage(playerid, COLOR_YELLOW, "Color - Yellow / Red / Gray / Orange / Indigo / Black / DarkGray");
SendClientMessage(playerid, COLOR_YELLOW, "Color - LightBlue / Purple / Blue / Pink / BrightRed / Green / White");
}
return true;
}
Re: Any Mistake Here? -
=WoR=Varth - 23.10.2011
You don't have to use sscanf.
?
Re: Any Mistake Here? -
DragonYancy - 23.10.2011
"SmiT" I did what you said... Didn't work, same thing again...
"=WoR=Varth" I just didn't understand what do you mean...
Re: Any Mistake Here? -
SmiT - 23.10.2011
Yeah, as Varth said, no need to use sscanf. Here is an example:
pawn Код:
COMMAND:SetColor(playerid,params[])
{
if( isnull ( params ) )
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE:/color [ColorName]");
SendClientMessage(playerid, COLOR_YELLOW, "Color - Yellow / Red / Gray / Orange / Indigo / Black / DarkGray");
SendClientMessage(playerid, COLOR_YELLOW, "Color - LightBlue / Purple / Blue / Pink / BrightRed / Green / White");
return true;
}
if( !strcmp( params,"Yellow",true ) )
{
format(String,sizeof(String),"Your color has changed.");
SendClientMessage(playerid,COLOR_YELLOW,String);
SetPlayerColor(playerid,COLOR_YELLOW);
return true;
}
else if( !strcmp( params,"DarkGrey",true ) )
{
format(String,sizeof(String),"Your color has changed.");
SendClientMessage(playerid,COLOR_DARKGREY,String);
SetPlayerColor(playerid,COLOR_DARKGREY);
return true;
}
else
{
SendClientMessage(playerid, COLOR_YELLOW, "Color - Yellow / Red / Gray / Orange / Indigo / Black / DarkGray");
SendClientMessage(playerid, COLOR_YELLOW, "Color - LightBlue / Purple / Blue / Pink / BrightRed / Green / White");
}
return true;
}