Command for enable/disable
#1

I need a command to enable/disable other commands, such as the /heal command can be enable/disable by administrator
Reply
#2

new bool:heal;

in your heal command check if the variable is false, if so return.

then make a command that toggles heal between true and false
Reply
#3

Can you do an example command
Reply
#4

pawn Код:
new bool:eheal;
CMD:disableheal(playerid,params[])
{
if(eheal = true)
{
eheal = false;
}
else if(eheal = false)
{
eheal = true;
}
return 1;
}

CMD:heal(playerid,params[])
{
if(eheal=true){
SetPlayerHealth(playerid,100);}
else if(eheal=false) return SendClientMessage(playerid,red,"this command is disabled");
return 1;
}
Reply
#5

This is a fixed version of the command of sasuga.

pawn Код:
CMD:heal(playerid,params[])
{
    if(eheal)
    {
        SetPlayerHealth(playerid,100);
        eheal = false;
    }
    else if(!eheal)
    {
        SendClientMessage(playerid, 0xFFFFFFAA, "this command is disabled");
        eheal = true;
    }
    return 1;
}
I did all this on BlackBerry mobile, so sorry if I was a bit late.
Reply
#6

Код:
new bool:eheal;

CMD:disableheal(playerid,params[])
{
    if(eheal = true)
    {
        eheal = false;
        //Here I want to write "{GetPlayerColor}%s administrator disable command /heal"
    }
    else if(eheal = false)
    {
        eheal = true;
        //Here I want to write "{GetPlayerColor}%s administrator enable command /heal"
    }
    return 1;
}

CMD:heal(playerid,params[])
{
    if(eheal)
    {
        SetPlayerHealth(playerid,100);
        eheal = false;
    }
    else if(!eheal)
    {
        SendClientMessage(playerid, 0xFFFFFFAA, "This command is disabled");
        eheal = true;
    }
    return 1;
}
But can you write that Nick and the administrator who puts it disable
Reply
#7

pawn Код:
new bool:eheal;

CMD:disableheal(playerid,params[])
{
    if(!IsPlayerAdmin(playerid)) return 1;//Rcon admin
    new string[128];
    if(eheal = true)
    {
        eheal = false;
        GetPlayerName(playerid,string,sizeof(string));
        format(string,sizeof(string),"%s administrator disable command /heal",string);
    }
    else if(eheal = false)
    {
        eheal = true;
        GetPlayerName(playerid,string,sizeof(string));
        format(string,sizeof(string),"%s administrator enable command /heal",string);
    }
    SendClientMessageToAll(color,string);
    return 1;
}
Reply
#8

Can "%s" GetPlayerColor him and shows him with his color
{GetPlayerColor}%s
Reply
#9

pawn Код:
CMD:disableheal(playerid,params[])
{
    if(!IsPlayerAdmin(playerid)) return 1;//Rcon admin
    new string[128],name[24];
    if(eheal = true)
    {
        eheal = false;
        GetPlayerName(playerid,name,sizeof(name));
        format(string,sizeof(string),"%x",GetPlayerColor(playerid));
        strmid(string,string,2,7)
        format(string,sizeof(string),"{%s}%s{FFFFFF} administrator disable command /heal",string,name);
    }
    else if(eheal = false)
    {
        eheal = true;
        GetPlayerName(playerid,name,sizeof(name));
        format(string,sizeof(string),"%x",GetPlayerColor(playerid));
        strmid(string,string,2,7)
        format(string,sizeof(string),"{%s}%s{FFFFFF} administrator enable command /heal",string,name);
    }
    SendClientMessageToAll(color,string);
    return 1;
}
EDITED, try new code before posting reply.

EDITED again, forgot to place white color.
Reply
#10

I fixed the errors, but:

D:\Server\gamemodes\drift.pwn(9243) : warning 211: possibly unintended assignment
D:\Server\gamemodes\drift.pwn(9251) : warning 211: possibly unintended assignment
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


2 Warnings.

Line 9243: if(eheal = true)
Line 9251: else if(eheal = false)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)