SA-MP Forums Archive
How to change the returning "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: How to change the returning "Unknown Command" (/showthread.php?tid=411673)



How to change the returning "Unknown Command" - RiChArD_A - 30.01.2013

How to change the returning "Unknown Command" for ZCMD?


Re: How to change the returning "Unknown Command" - Roach_ - 30.01.2013

This should help you:
pawn Код:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
    if(!success) return SendMessage(playerid, 0xE86633FF, "ERROR: {FFFFFF}Non-existent command.");
    return 1;
}



Respuesta: Re: How to change the returning "Unknown Command" - RiChArD_A - 30.01.2013

Quote:
Originally Posted by Roach_
Посмотреть сообщение
This should help you:
pawn Код:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
    if(!success) return SendMessage(playerid, 0xE86633FF, "ERROR: {FFFFFF}Non-existent command.");
    return 1;
}
I don't have that call back on GM. I have to add it?


Re: How to change the returning "Unknown Command" - Roach_ - 30.01.2013

Yes.. You have to Add it, and this too: OnPlayerCommandReceived(playerid, cmdtext[])
pawn Код:
public OnPlayerCommandReceived(playerid, cmdtext[ ])
{
    return 1;
}
You will use it later..


Re: How to change the returning "Unknown Command" - Threshold - 30.01.2013

Or OnPlayerCommandText if you're using strcmp.

If you're using strcmp...
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmdtext, "/mycommand", true) == 0)
    {
        //My stuff here
        return 1; //Make sure your commands are all returning a value of 1
    }
    return SendClientMessage(playerid, 0xFF0000FF, "This command does not exist in this server!");
}
For ZCMD:
pawn Код:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
    if(!success) return SendClientMessage(playerid, 0xFF0000FF, "This command does not exist on this server!");
    //if the command was unsuccessful/does not exist
    return 1;
}
Quote:
Originally Posted by Roach
Or by using OnPlayerCommandReceived
pawn Код:
public OnPlayerCommandReceived(playerid, cmdtext[])
{
    if(strcmp(cmdtext, "/mycommand", true) == 0)
    {
        //My stuff here
        return 1;
    } //Basically the same as OnPlayerCommandText
    return SendClientMessage(playerid, 0xFF0000FF, "This command does not exist in this server!");
}
(NOTE: Roach, it's OnPlayerCommandPerformed, not received, because the performed uses a 'success' parameter which tells us whether the command was executed or not. Unless of course, you were referring to using this as a 'strcmp' method.)

EDIT #2: Also didn't see your first post on OnPlayerCommandPerformed, my bad


Re: How to change the returning "Unknown Command" - Roach_ - 30.01.2013

Quote:
Originally Posted by BenzoAMG
Посмотреть сообщение
Or OnPlayerCommandText if you're using strcmp.

If you're using strcmp...
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmdtext, "/mycommand", true) == 0)
    {
        //My stuff here
        return 1; //Make sure your commands are all returning a value of 1
    }
    return SendClientMessage(playerid, 0xFF0000FF, "This command does not exist in this server!");
}
For ZCMD:
pawn Код:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
    if(!success) return SendClientMessage(playerid, 0xFF0000FF, "This command does not exist on this server!");
    //if the command was unsuccessful/does not exist
    return 1;
}
(NOTE: Roach, it's OnPlayerCommandPerformed, not received, because the performed uses a 'success' parameter which tells us whether the command was executed or not. Unless of course, you were referring to using this as a 'strcmp' method.)
I said that if he want he can add that too, he will use it later...
OPTIONAL, do you understand ?


Re: How to change the returning "Unknown Command" - martin3644 - 30.01.2013

Quote:
Originally Posted by Roach_
Посмотреть сообщение
I said that if he want he can add that too, he will use it later...
OPTIONAL, do you understand ?
Yea I understand
But this works too with ZCMD, not only with strcmp


Respuesta: Re: How to change the returning "Unknown Command" - RiChArD_A - 30.01.2013

Quote:
Originally Posted by Roach_
Посмотреть сообщение
Yes.. You have to Add it, and this too: OnPlayerCommandReceived(playerid, cmdtext[])
pawn Код:
public OnPlayerCommandReceived(playerid, cmdtext[ ])
{
    return 1;
}
You will use it later..
Thank you Roach_... Again haha . And thanks to everyone how answer.


Respuesta: Re: How to change the returning "Unknown Command" - RiChArD_A - 30.01.2013

Quote:
Originally Posted by martin3644
Посмотреть сообщение
Yea I understand
But this works too with ZCMD, not only with strcmp
He didn't said it to you men.


Re: Respuesta: Re: How to change the returning "Unknown Command" - martin3644 - 30.01.2013

Quote:
Originally Posted by Lauder
Посмотреть сообщение
He didn't said it to you men.
My Bad. Everybody makes mistakes.