OnPlayerCommandText RETURN MESSAGE [HELP]
#1

THANKS ALL FOR HELPING PROBLEM IS NOW SOLVED
Reply
#2

That is done automaticaly if the command doesn't exist.
Reply
#3

If you want custom error messages when the command doesn't exist use this example:

Instead of returning 0 at OnplayerCommandText, use SendClientMessage and your own custom message.

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp(cmdtext, "/test", true))
    {
        // Do something here
        return true;
    }
    return SendClientMessage(playerid, 0xFFFFFF, "CUSTOM: Unknown COMMAND");
}
Reply
#4

i KNOW
But it only sas
SERVER:UNKNOWN COMMAND
I want it to be displayed by GameTextForPlayer and to display what ever they typed wrong
Reply
#5

Then use format with GameTextForPlayer instead of SendClientMessage, also be carefull with those extra parameters.

EDIT: fast example:

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new
        string[128];
       
    if(!strcmp(cmdtext, "/test", true))
    {
        // Do something here
        return true;
    }
    format(string, sizeof(string), "%s", cmdtext);
    return GameTextForPlayer(playerid, string, xxx, x);
}
Reply
#6

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp(cmdtext, "/test", true))
    {
        // Do something here
        return true;
    }
    new str[ 128 ];
    format( str, sizeof( str ), "~w~Unknown command: ~r~\"%s\"", cmdtext[ 0 ] );
    return GameTextForPlayer( playerid, str, 5000, 6 );
}
Reply
#7

Here it is.

pawn Код:
new str[ 50 ];
format( str,sizeof( str ), "~w~ %s is an ~r~UNKNOWN COMMAND!",cmdtext );
GameTextForPlayer( playerid, str, 3000,3 );
OMG larzI, we made it identical! xD Almost..
Reply
#8

Offtopic: LOL, we all made it indentical,,

well the problem is solved, topic can be locked, or something
Reply
#9

Thans to all for HELPING
But MOST THANKS TO LarzI & Zh3r0 Because That's what i was looking for
Reply
#10

No problem ^^
BTW: Virtual1ty made the same thing, he just didn't fill out all the parameters ^^
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)