Help with command
#1

How i can make two commands.First command to diable all commands of the server
The second command to enable to can use all of commands again
Reply
#2

What command Processor you use ?
Reply
#3

if(strcmp(cmd, "/makeadmin", true) == 0)
Reply
#4

I recommend you change to ZCMD, as this is much better and less laggy.

Put this on top.
pawn Код:
new CMDS;
Here is the command

pawn Код:
cmd(commandson, playerid, params[])
{
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "You cannot use this command");
    if(CMDS == 0)
    {
        CMDS = 1;
        SendClientMessageToAll(-1, "All commands are disabled");
    }
    else
    {
        CMDS = 0;
        SendClientMessageToAll(-1, "All commands are enabled");
    }
    return 1;
}
And on top of every command do this.

pawn Код:
if(CMDS == 0) return SendClientMessage(playerid, -1, "Commands are disabled");
Don't want to use ZCMD? Then I guess you have to turn this into strcmp. :P
Reply
#5

Using Bools?
there is an example below.
pawn Код:
new bool:CommandsOff;
if(strcmp(cmd, "/makeadmin", true) == 0)
{
if(CommandsOff == true) return SendClientMessage(playerid,-1,"Commands Are Disabled By An Administrator);
} else {
everything else..
Correct me if thats not what you said p
Reply
#6

Ok, strcmp so...
  • At the top of your script, out of any Callback:
    pawn Код:
    new bool:BlockCommands;
  • Block Command:
    pawn Код:
    if( !strcmp( cmdtext, "/blockcommands", true ) )
    {
        BlockCommands = true;
        SendClientMessage( playerid, -1, "You have blocked commands to all players." );
        SendClientMessage( playerid, -1, "Use {C0C0C0}/unblockcommands {FFFFFF}to unblock them." );

        return 1;
    }
  • Unblock Command:
    pawn Код:
    if( !strcmp( cmdtext, "/unblockcommands", true ) )
    {
        BlockCommands = false;
        SendClientMessage( playerid, -1, "You have unblocked commands to all players." );
        SendClientMessage( playerid, -1, "Use {C0C0C0}/blockcommands {FFFFFF}to block them." );

        return 1;
    }
  • Put at the top of the OnPlayerCommandText Callback:
    pawn Код:
    if( BlockCommands && !IsPlayerAdmin( playerid ) ) return SendClientMessage( playerid, -1, "You can't use commands because an Admin disabled them." );
PS: You must change IsPlayerAdmin with your Admin Variable and add to the commands too...
Reply
#7

Quote:
Originally Posted by Littlehelper[MDZ]
Посмотреть сообщение
Using Bools?
there is an example below.
[CODE]
new bool:CommandsOff;
if(strcmp(cmd, "/makeadmin", true) == 0)
{
if(CommandsOff == true) return SendClientMessage(playerid,-1,"Commands Are Disabled By An Administrator);
} else {
everything else..[/PAWN]
Correct me if thats not what you said p
He wanted a command where you disable the commands, not to make an admin.
Reply
#8

aRoach

i have this error
C:\Users\User\Desktop\servera last !!!!\servera last !!!!\gamemodes\1.pwn(6344) : error 001: expected token: ")", but found "return"
Line error
PHP код:
if( BlockCommands && (PlayerInfo[playerid][pAdmin] >= 3) return SendClientMessageplayerid, -1"You can't use commands because an Admin disabled them." ); 
Reply
#9

Quote:
Originally Posted by JhnzRep
Посмотреть сообщение
He wanted a command where you disable the commands, not to make an admin.
It Was An Example......
Read his second post.....
Reply
#10

Quote:
Originally Posted by aRoach
Посмотреть сообщение
Ok, strcmp so...
  • At the top of your script, out of any Callback:
    pawn Код:
    new bool:BlockCommands;
  • Block Command:
    pawn Код:
    if( !strcmp( cmdtext, "/blockcommands", true ) )
    {
        BlockCommands = true;
        SendClientMessage( playerid, -1, "You have blocked commands to all players." );
        SendClientMessage( playerid, -1, "Use {C0C0C0}/unblockcommands {FFFFFF}to unblock them." );

        return 1;
    }
  • Unblock Command:
    pawn Код:
    if( !strcmp( cmdtext, "/unblockcommands", true ) )
    {
        BlockCommands = false;
        SendClientMessage( playerid, -1, "You have unblocked commands to all players." );
        SendClientMessage( playerid, -1, "Use {C0C0C0}/blockcommands {FFFFFF}to block them." );

        return 1;
    }
  • Put at the top of the OnPlayerCommandText Callback:
    pawn Код:
    if( BlockCommands && !IsPlayerAdmin( playerid ) ) return SendClientMessage( playerid, -1, "You can't use commands because an Admin disabled them." );
PS: You must change IsPlayerAdmin with your Admin Variable and add to the commands too...
yes this it work's but when i disable the commands i can't unblock them to can work again it's giving me this "You can't use commands because an Admin disabled them." when i write /unblockcommands how we can fix it
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)