Unkown Command! +REP
#1

Код:
new cmd[256], idx;
	cmd = strtok(cmdtext, idx);

	if (strcmp("/answer", cmd, true) == 0)
	{
		new tmp[256], cmdid, string[256], pname[MAX_PLAYER_NAME];
		tmp = strtok(cmdtext, idx);
		if(!strlen(tmp)) return SendClientMessage(playerid,COL_RED, "USAGE: /Answer [answer]");
		cmdid = strval(tmp);

		if(cmdid < answer || cmdid > answer)
		{
			SendClientMessage(playerid,COL_RED, "Wrong answer!");
		}

		if(cmdid == answer && answered == 0)
		{
			GetPlayerName(playerid, pname, sizeof(pname));

			format(string, sizeof(string), "%s has won %d score for answering the math question '%d'!", pname, score, cmdid);
			SendClientMessageToAll(COL_GREEN, string);
			GivePlayerMoney(playerid, 10000);

			answered = 1;
			SetPlayerScore(playerid, GetPlayerScore(playerid) + score);
			score = 0;
			return 1;
		}
		else if(cmdid == answer && answered == 1)
		{
			SendClientMessage(playerid,COL_RED, "To late!");
		}
		return 1;
	}
	if (strcmp("/stopmaths", cmd, true) == 0)
	{
		if(IsPlayerAdmin(playerid) == 0) return SendClientMessage(playerid,COL_RED, "You are not an RCON admin");

		KillTimer(timer);
		SendClientMessage(playerid,COLOR_YELLOW, "Maths stopped");
		return 1;
	}
those commands are for the math test , when i do them in-game it shows (Unknown Command)

any ideas ?
Reply
#2

You are supposed to return a 0 value instead of a 1 value in strcmp that is why it shows you unknown command.
Reply
#3

PHP код:
new cmd[256], idx;
    
cmd strtok(cmdtextidx);
    if (
strcmp("/answer"cmdtrue) == 0)
    {
        new 
tmp[256], cmdidstring[256], pname[MAX_PLAYER_NAME];
        
tmp strtok(cmdtextidx);
        if(!
strlen(tmp)) return SendClientMessage(playerid,COL_RED"USAGE: /Answer [answer]");
        
cmdid strval(tmp);
        if(
cmdid answer || cmdid answer)
        {
            
SendClientMessage(playerid,COL_RED"Wrong answer!");
        }
        if(
cmdid == answer && answered == 0)
        {
            
GetPlayerName(playeridpnamesizeof(pname));
            
format(stringsizeof(string), "%s has won %d score for answering the math question '%d'!"pnamescorecmdid);
            
SendClientMessageToAll(COL_GREENstring);
            
GivePlayerMoney(playerid10000);
            
answered 1;
            
SetPlayerScore(playeridGetPlayerScore(playerid) + score);
            
score 0;
            return 
1;
        }
        else if(
cmdid == answer && answered == 1)
        {
            
SendClientMessage(playerid,COL_RED"To late!");
        }
        return 
0;
    }
    if (
strcmp("/stopmaths"cmdtrue) == 0)
    {
        if(
IsPlayerAdmin(playerid) == 0) return SendClientMessage(playerid,COL_RED"You are not an RCON admin");
        
KillTimer(timer);
        
SendClientMessage(playerid,COLOR_YELLOW"Maths stopped");
        return 
0;
    } 
Reply
#4

Thanks , +REP for both of u
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)