"SERVER: Unknown command" wtf? - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: "SERVER: Unknown command" wtf? (
/showthread.php?tid=245692)
"SERVER: Unknown command" wtf? -
sabreman - 01.04.2011
Hey guys, the server of mine says: Server Unknown command. I don't know why because the code seems to work fine. Here is the code btw:
Код:
else if(strcmp(cmd, "/reported", true) == 0) {
new i,Count;
for(i = 0; i < MAX_PLAYERS; i++) Count++;
if(PlayerInfo[i][activereport] == 0) SendClientMessage(playerid, COLOR_GREEN, "No active reports available right now");
else if(PlayerInfo[i][activereport] == 1) {
new string[256], name[256];
GetPlayerName(i, name, 256);
format(string, 256, "%s", name);
SendClientMessage(playerid, COLOR_GREEN, string);
}
return 1;
}
Help would be hell appreciated.
Re: "SERVER: Unknown command" wtf? -
Mmartin - 01.04.2011
1) Don't use elseif in OnPlayerCommandText
2) change return 1 to return 0, and add behind SCM "return 1;"
Re: "SERVER: Unknown command" wtf? -
necrobg3 - 01.04.2011
Yea Mmartin tell to you :dont use elseif at OnPlayerCommandText :P
AW: "SERVER: Unknown command" wtf? -
Meta - 01.04.2011
yep, no elseif but else if :P
you can use else if but you have to pay attention that this won't cause wrong results
your code is wrong indeed (for sets i always to MAX_PLAYERS), but i'll try to help you
it could be:
... i see, you use strtok method, so it could be that you forgot do define "cmd"
... else if results a wrong code because of a previous true statement
... i can't see a mistake
xD
Re: "SERVER: Unknown command" wtf? -
Joe Staff - 01.04.2011
pawn Код:
else if(strcmp(cmd, "/reported", true) == 0)
{
new i,Count;
for(i = 0; i < MAX_PLAYERS; i++)
{ //Missing bracket
Count++;
if(PlayerInfo[i][activereport])
{
new string[256], name[256];
GetPlayerName(i, name, 256);
format(string, 256, "%s", name);
SendClientMessage(playerid, COLOR_GREEN, string);
}
}//Another missing bracket
if(!Count)SendClientMessage(playerid, COLOR_GREEN, "No active reports available right now");
return 1;
}