Command Disabling
#1

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.
Reply
#2

You using strtok or zcmd ?
Reply
#3

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

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;

Reply
#5

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.
Reply
#6

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

You use zcmd or strcmp?
Reply
#8

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.
Reply
#9

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)