SA-MP Forums Archive
Command Disabling - 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: Command Disabling (/showthread.php?tid=614807)



Command Disabling - BurnZ - 13.08.2016

Is there any way to stop a player from using ALL server commands?

If so, how?

Would be thankful if anyone provides me a code or teach me how.


Re: Command Disabling - WildWave - 13.08.2016

You using strtok or zcmd ?


Re: Command Disabling - Logic_ - 13.08.2016

PHP код:
public OnPlayerCommandPerformed(playeridcmdtext[], success
this should be used, if you are using ZCMD.


Re: Command Disabling - Shinja - 13.08.2016

Quote:
Originally Posted by ALiScripter
Посмотреть сообщение
PHP код:
public OnPlayerCommandPerformed(playeridcmdtext[], success
this should be used, if you are using ZCMD.
This callback is called when command is executed, so won't prevent from executing commands

First you have to declare a global variable, ex:
PHP код:
new bool:AllowCmds
and make true by default OnGameModeInit
And make your command to toggle it

And to prevent executing the commands, If you are uzing zcmd:
PHP код:
public OnPlayerCommandReceived(playeridcmdtext[])
{
    if(
AllowCmds == false)
    {
        
SendClientMessage(playerid,-1,"Commands are disabled by an admin!");
        return 
0;
    }
    return 
1;




Re: Command Disabling - BurnZ - 13.08.2016

Quote:
Originally Posted by Shinja
Посмотреть сообщение
This callback is called when command is executed, so won't prevent from executing commands

First you have to declare a global variable, ex:
PHP код:
new bool:AllowCmds
and make true by default OnGameModeInit
And make your command to toggle it

And to prevent executing the commands, If you are uzing zcmd:
PHP код:
public OnPlayerCommandReceived(playeridcmdtext[])
{
    if(
AllowCmds == false)
    {
        
SendClientMessage(playerid,-1,"Commands are disabled by an admin!");
        return 
0;
    }
    return 
1;

A full code? With the cmd /ripcmd as the command.


Re: Command Disabling - justice96 - 13.08.2016

Quote:
Originally Posted by BurnZ
Посмотреть сообщение
A full code? With the cmd /ripcmd as the command.
You can add the variable inside of them


Re: Command Disabling - Shinja - 13.08.2016

You use zcmd or strcmp?


Re: Command Disabling - SickAttack - 13.08.2016

pawn Код:
#include <sscanf2>
#include <zcmd>

new bool:pCMDsDisabled[MAX_PLAYERS] = false;

public OnPlayerCommandReceived(playerid, cmdtext[])
{
    if(pCMDsDisabled[playerid])
    {
        SendClientMessage(playerid, -1, "You aren't allowed to use any commands.");
        return 0;
    }
    return 1;
}

CMD:ripcmd(playerid, params[])
{
    new lookupid;
    if(sscanf(params, "u", lookupid))
    {
        SendClientMessage(playerid, -1, "Usage: /ripcmd (id/name)");
    }
    else if(!IsPlayerConnected(lookupid))
    {
        SendClientMessage(playerid, -1, "Player isn't connected.");
    }
    else
    {
        pCMDsDisabled[lookupid] = ((pCMDsDisabled[lookupid]) ? (false) : (true));
    }
    return 1;
}
If you're going to use it on a CNRSF server, please don't. The abuse is already so real there.


Re: Command Disabling - BurnZ - 14.08.2016

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
pawn Код:
#include <sscanf2>
#include <zcmd>

new bool:pCMDsDisabled[MAX_PLAYERS] = false;

public OnPlayerCommandReceived(playerid, cmdtext[])
{
    if(pCMDsDisabled[playerid])
    {
        SendClientMessage(playerid, -1, "You aren't allowed to use any commands.");
        return 0;
    }
    return 1;
}

CMD:ripcmd(playerid, params[])
{
    new lookupid;
    if(sscanf(params, "u", lookupid))
    {
        SendClientMessage(playerid, -1, "Usage: /ripcmd (id/name)");
    }
    else if(!IsPlayerConnected(lookupid))
    {
        SendClientMessage(playerid, -1, "Player isn't connected.");
    }
    else
    {
        pCMDsDisabled[lookupid] = ((pCMDsDisabled[lookupid]) ? (false) : (true));
    }
    return 1;
}
If you're going to use it on a CNRSF server, please don't. The abuse is already so real there.
Just wanted to learn as I have always tried to disable cmds while failing.