Why does it say unknown command?
#1

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)
Reply
#2

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

Thank you!
*EDIT* Another problem, help please.
Reply
#4

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

Still have any problem?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)