SERVER: Unknown Command
#11

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    //Every command here
    return SendClientMessage(playerid, 0xAFAFAFAA, "Custom unknown command text");
}
That works. But then you must add 'return 1;' after ALL the commands!
pawn Код:
if(!strcmp(cmdtext, "/my_command"))
{
    //Do something
    return 1; //<--
}
Why?
After performing the command, it'll return '1' (or 'true'). If you have the following commands:
/my_command
/help
and if they both have, it will return the value '1'. If you don't perform one of those commands, it won't return the value '1', so it will automatic call the return at the end of onPlayerCommandText. You can compare it with this:
pawn Код:
switch(random(10))
{
    case 0,1,2,3: print("0, 1, 2 or 3 was the random"); //if it is 0, 1, 2 or 3
    default: print("The random was something else"); //if it's something else
}
If you compare it with OnPlayerCommandText, the 'case 0,1,2,3' are the commands, the 'default' is the "unknown command". I hope that that was clear enough
Reply


Messages In This Thread
SERVER: Unknown Command - by Artix - 04.05.2011, 05:56
Re: SERVER: Unknown Command - by [SFA]SpiRRiT - 04.05.2011, 09:26
Re: SERVER: Unknown Command - by System64 - 04.05.2011, 09:31
Re: SERVER: Unknown Command - by iggy1 - 04.05.2011, 09:53
Re: SERVER: Unknown Command - by CrazyBlob - 04.05.2011, 10:00
Re: SERVER: Unknown Command - by [SFA]SpiRRiT - 04.05.2011, 10:00
Re: SERVER: Unknown Command - by alpha500delta - 04.05.2011, 11:24
Re: SERVER: Unknown Command - by [SFA]SpiRRiT - 04.05.2011, 12:07
Re: SERVER: Unknown Command - by iPLEOMAX - 04.05.2011, 14:09
Re: SERVER: Unknown Command - by nuriel8833 - 04.05.2011, 14:12
Re: SERVER: Unknown Command - by Kwarde - 05.05.2011, 11:10

Forum Jump:


Users browsing this thread: 2 Guest(s)