04.07.2014, 01:26
(
Last edited by Timeless; 04/07/2014 at 09:48 AM.
)
I'm gonna show you guys a tutorial on how to turn off or change the "Server Unknown Command" text when using ZCMD
First of all if you're not sure on which command processor is ZCMD then this is ZCMD https://sampforum.blast.hk/showthread.php?tid=91354 thats the processor i'm going to explain
some usage of ZCMD and this feature can work for all of them
Example of some usage:
or
or
normally to change the "Server:Unknown Command" text is using
however thats not needed when using ZCMD this is much faster and easier.
To change the message we have to use a callback called
we will add these lines to our callback
so now it would look like this
now we add our invalid command text to the callback
now if you don't to have "Server:Unknown Command" being spammed everytime you succesfully did a command? we simple locate the return value in the callback and instead of having 0 we change it to 1 and voila!
and thats it your "Server:Unknown Command" is changed
COMMON ERRORS:
i've seen a few statements like this
1.
However this would work but the invalid command text would be spammed everytime you do a command.
2.
that won't work as the pawno compiler will give you a warning like this
and if you try correcting this warning by creating a return value like this it would give you an unreachable code warning
and if you have something like this it won't work either
3.
cause your just basically telling the server to spam "your new unknown command text" every time a command is performed
now if you want to get rid of this text completely without displaying any message? we simply go back to the return value and instead of displaying a message we simply change the "0" to a "1"
like this
so now the no text will be displayed if a player types an invalid command
I hoped you understood the tutorial and i hoped it helped someone out there cause i haven't found any tutorials with this so i just thought i should create one
First of all if you're not sure on which command processor is ZCMD then this is ZCMD https://sampforum.blast.hk/showthread.php?tid=91354 thats the processor i'm going to explain
some usage of ZCMD and this feature can work for all of them
Example of some usage:
PHP Code:
COMMAND:mycommand(playerid, params[]) // or CMD:mycommand(playerid, params[])
{
// Do something
return 1;
}
PHP Code:
command(mycommand, playerid, params[]) // or cmd(mycommand, playerid, params[])
{
// Do something
return 1;
}
PHP Code:
CMD:mycommand(playerid, params[])
{
//Do something
return 1;
}
PHP Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/mycommand", cmdtext, true, 10) == 0)
{
// Do something here
return 1;
}
return 0;
}
To change the message we have to use a callback called
PHP Code:
public OnPlayerCommandPerformed( playerid, cmdtext[ ], success )
PHP Code:
if (!success)
{
//----- your invalid command text to show would go here
}
PHP Code:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
if (!success)
{
/<---- your invalid command text to show would go here
}
return 0;
}
PHP Code:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
if (!success)
{
SendClientMessage(playerid,COLOR_RED,"Hey you enterred a wrong command");
}
return 0;
}
PHP Code:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
if (!success)
{
SendClientMessage(playerid,COLOR_RED,"Hey you enterred a wrong command");
}
return 1;
}
COMMON ERRORS:
i've seen a few statements like this
1.
PHP Code:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
return SendClientMessage(playerid,COLOR_RED,"Hey you typed a wrong command"); // you can change the text to whatever you want to suit your server
2.
PHP Code:
public OnPlayerCommandPerformed( playerid, cmdtext[ ], success )
{
if( success == 0 )
return SendClientMessage( playerid, COLOR, "Your new unknown command text" );
}
PHP Code:
warning 209: function "OnPlayerCommandPerformed" should return a value
PHP Code:
public OnPlayerCommandPerformed( playerid, cmdtext[ ], success )
{
if( success == 0 )
{
}
return SendClientMessage( playerid, COLOR, "Your new unknown command text" );
return 0;
}
3.
PHP Code:
public OnPlayerCommandPerformed( playerid, cmdtext[ ], success )
{
if( success == 0 )
{
}
return SendClientMessage( playerid, COLOR, "Your new unknown command text" );
}
now if you want to get rid of this text completely without displaying any message? we simply go back to the return value and instead of displaying a message we simply change the "0" to a "1"
like this
PHP Code:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
return 1;//If player writes command wrong this will still return it as a true and the message will not be displayed
}
I hoped you understood the tutorial and i hoped it helped someone out there cause i haven't found any tutorials with this so i just thought i should create one