Why does it say unknown command? - 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: Why does it say unknown command? (
/showthread.php?tid=296451)
Unreachable code, help. -
BigGroter - 11.11.2011
Now I get Untitled.pwn(10

: warning 225: unreachable code, line 108 is the /gotoarea51 one.
pawn Код:
{
if (strcmp("/gotolp", cmdtext, true, 10) == 0)
{
if(IsPlayerAdmin(playerid))
SendClientMessage(playerid,YELLOW, "(INFO) You have been teleported to Las Payasadas!");
SetPlayerPos(playerid,-247.7184,2692.8208,62.6875);
return 1;
}
else
SendClientMessage(playerid,YELLOW, "(INFO) This command is for administrators only!");
{
return 1;
}
if (strcmp("/gotoarea51", cmdtext, true, 10) == 0)
Re: Why does it say unknown command? -
Calgon - 11.11.2011
You need to return 1 inside the command. Return 0 is sent otherwise, and if 0 is sent, SA-MP is told to relay the 'unknown command' message.
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/test", cmdtext, true) == 0) {
if(IsPlayerAdmin(playerid)) {
SendClientMessage(playerid, 0xFF00FFFF, "test1");
}
else
{
SendClientMessage(playerid, 0xFF00FFFF, "test2");
}
return 1;
}
return 0;
}
Re: Why does it say unknown command? -
BigGroter - 11.11.2011
Thank you!
*EDIT* Another problem, help please.
Re: Why does it say unknown command? -
Mean - 11.11.2011
Your code's a mess.
pawn Код:
if (strcmp("/gotolp", cmdtext, true, 10) == 0) {
if(IsPlayerAdmin(playerid)) { // Open bracket that you forgot.
SendClientMessage(playerid,YELLOW, "(INFO) You have been teleported to Las Payasadas!");
SetPlayerPos(playerid,-247.7184,2692.8208,62.6875);
// The "return 1;" was needless since you are calling "return 1;" after the else statement, therefore you're calling the "return" function twice, causing the other return to be unreachable. Returning a true value in OnPlayerCommandText stands for a successfully executed command. Once is enough.
}
else { // You should put an opening bracket here.
SendClientMessage(playerid,YELLOW, "(INFO) This command is for administrators only!");
} // This is a closing bracket, not an opening one.
return 1;
}
Re: Why does it say unknown command? -
Chrillzen - 11.11.2011
Still have any problem?