Any Mistake Here?
#1

Код:
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
Reply
#2

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;
}
Reply
#3

You don't have to use sscanf.
pawn Код:
else
    else if
?
Reply
#4

"SmiT" I did what you said... Didn't work, same thing again...

"=WoR=Varth" I just didn't understand what do you mean...
Reply
#5

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;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)