Help disabling commands on occasions.
#9

Here's some code you can use to disable individual commands:
PHP код:
#include <sscanf>
#include <zcmd>
public OnPlayerCommandReceived(playeridcmdtext[])
{
    new 
cmd[29], null;
    
sscanf(cmdtext"s[29]i"cmdnull);
    if(
GetPVarInt(playeridcmd))
    {
        
SendClientMessage(playerid0xFF0000FF"That command is disabled for you!");
        return 
0;
    }
    return 
1;
}
CMD:disable(playeridparams[])
{
    if(
isnull(params))
    {
        
SendClientMessage(playerid0xFF0000FF"Usage: /disable (/command)");
    }
    else if(!
IsValidCommand(params))
    {
        
SendClientMessage(playerid0xFF0000FF"Please enter a valid command!");
    }
    else
    {
        
SetPVarInt(playeridparams1);
        
SendClientMessage(playerid0xFFF000FF"You have disabled a command for yourself!");
    }
    return 
1;
}
CMD:enable(playeridparams[])
{
    if(
isnull(params))
    {
        
SendClientMessage(playerid0xFF0000FF"Usage: /enable (/command)");
    }
    else if(!
IsValidCommand(params))
    {
        
SendClientMessage(playerid0xFF0000FF"Please enter a valid command!");
    }
    else
    {
        
DeletePVar(playeridparams); // can also be SetPVarInt(playerid, params, 0); but not recommended as PVars are limited
        
SendClientMessage(playerid0xFFF000FF"You have enabled a command for yourself!");
    }
    return 
1;
}
CMD:cmd1(playeridparams[])
{
    
SendClientMessage(playerid0xFFF000FF"You have used /cmd1!");
    return 
1;
}
CMD:cmd2(playeridparams[])
{
    
SendClientMessage(playerid0xFFF000FF"You have used /cmd2!");
    return 
1;
}
IsValidCommand(const command[])
{
    if(
command[0] == EOS || command[0] != '/' || strlen(command) > 28 || strfind(command" "true) != -1)
    {
        return 
false;
    }
    return 
true;

Reply


Messages In This Thread
Help disabling commands on occasions. - by TahaMhr - 01.09.2017, 17:17
Re: Help disabling commands on occasions. - by mongi - 01.09.2017, 17:30
Re: Help disabling commands on occasions. - by TahaMhr - 01.09.2017, 18:56
Re: Help disabling commands on occasions. - by FuNkYTheGreat - 01.09.2017, 19:11
Re: Help disabling commands on occasions. - by TahaMhr - 01.09.2017, 19:44
Re: Help disabling commands on occasions. - by FuNkYTheGreat - 01.09.2017, 19:56
Re: Help disabling commands on occasions. - by TahaMhr - 01.09.2017, 20:32
Re: Help disabling commands on occasions. - by mongi - 02.09.2017, 22:54
Re: Help disabling commands on occasions. - by Paulice - 03.09.2017, 04:55
Re: Help disabling commands on occasions. - by TahaMhr - 03.09.2017, 12:36

Forum Jump:


Users browsing this thread: 1 Guest(s)