Unkown Command! +REP - 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: Unkown Command! +REP (
/showthread.php?tid=585788)
Unkown Command! +REP -
YoussefHammad - 16.08.2015
Код:
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 ?
Re: Unkown Command! +REP -
DarkLored - 16.08.2015
You are supposed to return a 0 value instead of a 1 value in strcmp that is why it shows you unknown command.
Re: Unkown Command! +REP -
iTakelot - 16.08.2015
PHP код:
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 0;
}
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 0;
}
Re: Unkown Command! +REP -
YoussefHammad - 16.08.2015
Thanks , +REP for both of u