PDA

View Full Version : Command for enable/disable


Join7
30/08/2011, 08:30 PM
I need a command to enable/disable other commands, such as the /heal command can be enable/disable by administrator

PrawkC
30/08/2011, 08:49 PM
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

Join7
30/08/2011, 08:51 PM
Can you do an example command

sasuga
30/08/2011, 08:56 PM
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;
}

Improvement™
30/08/2011, 09:40 PM
This is a fixed version of the command of sasuga.

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.

Join7
31/08/2011, 10:13 AM
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

=WoR=Varth
31/08/2011, 10:23 AM
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;
}

Join7
31/08/2011, 10:26 AM
Can "%s" GetPlayerColor him and shows him with his color
{GetPlayerColor}%s

=WoR=Varth
31/08/2011, 10:50 AM
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.

Join7
31/08/2011, 11:19 AM
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 (c) 1997-2006, ITB CompuPhase


2 Warnings.

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

=WoR=Varth
31/08/2011, 11:28 AM
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;
}

Join7
31/08/2011, 11:34 AM
Compiles, but typing /dheal

Color me written as: "{AA33A}"

And write /heal first wrote that was disable the second I write /heal is allowed

=WoR=Varth
31/08/2011, 11:48 AM
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,8);
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,8);
format(string,sizeof(string),"{%s}%s{FFFFFF} administrator enable command /heal",string,name);
}
SendClientMessageToAll(color,string);
return 1;
}

Show me your /heal command.

Join7
31/08/2011, 11:54 AM
if(strcmp(cmd,"/heal",true)==0)
{
if(PlayerInfo[playerid][pVIP] >= 1)
{
if(eheal)
{
if(PlayerInfo[playerid][pHeal] <= 0)
{
SetPlayerHealth(playerid, 100);
SetPlayerArmour(playerid, 100);
SendClientMessage(playerid, COLOR_GREEN, "100 hp and 100 armor!");
PlayerInfo[playerid][pHealme] = 2*90;
}
else
{
SendClientMessage(playerid, COLOR_RED, "Time ...");
}
eheal = false;
}
else if(!eheal)
{
SendClientMessage(playerid, COLOR_RED, "Command is disable by administrator!");
eheal = true;
}
}
return 1;
}

=WoR=Varth
31/08/2011, 11:57 AM
i if(strcmp(cmd,"/heal",true)==0)
{
if(PlayerInfo[playerid][pVIP] >= 1)
{
if(eheal)
{
if(PlayerInfo[playerid][pHeal] <= 0)
{
SetPlayerHealth(playerid, 100);
SetPlayerArmour(playerid, 100);
SendClientMessage(playerid, COLOR_GREEN, "100 hp and 100 armor!");
PlayerInfo[playerid][pHealme] = 2*90;
}
else SendClientMessage(playerid, COLOR_RED, "Time ...");
}
else SendClientMessage(playerid, COLOR_RED, "Command is disable by administrator!");
}
return 1;
}

Join7
31/08/2011, 12:02 PM
Let's now working perfectly, only that when you type /dheal, my name appears in another color, not that I am

EDIT: The color is wrong

Join7
31/08/2011, 12:17 PM
The color is wrong

=WoR=Varth
31/08/2011, 12:23 PM
Do not double posting. Got it?
What do you mean by wrong color?

Join7
31/08/2011, 12:36 PM
And good!
I mean that when you write /dheal my name written in some purple colors, and I'm green color

EDIT: See the picture http://prikachi.com/images/272/3761272o.png

=WoR=Varth
31/08/2011, 12:58 PM
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,8);printf("%x %s",GetPlayerColor(playerid),string);
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,8);printf("%x %s",GetPlayerColor(playerid),string);
format(string,sizeof(string),"{%s}%s{FFFFFF} administrator enable command /heal",string,name);
}
SendClientMessageToAll(color,string);
return 1;
}

You know debug, right?
Show me your server log after typed this command.

Join7
31/08/2011, 01:08 PM
[16:07:02] [cmd][Join7]: /dheal
[16:07:02] 33AA33AA AA33AA

It turns this color {AA33AA}

Color on my gang is: 0x33AA33AA

This gang color is: 0x408080FF, but then it appears as 8080FF

EDIT: I fixed it, but COLOR_PURPLE 0xC2A2DAAA
out as
-#+#.++* -#+#.+

This COLOR: 0xF5BE1880
out as !!+* !!+*

=WoR=Varth
31/08/2011, 01:19 PM
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,0,6);printf("%x %s",GetPlayerColor(playerid),string);
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,0,6);printf("%x %s",GetPlayerColor(playerid),string);
format(string,sizeof(string),"{%s}%s{FFFFFF} administrator enable command /heal",string,name);
}
SendClientMessageToAll(color,string);
return 1;
}

Join7
31/08/2011, 01:24 PM
Yes, but some colors as:

COLOR_PURPLE 0xC2A2DAAA
out as server.log
-#+#.++* -#+#.+
In game: {-#+#.+}Join7 ...

COLOR_VAGOS: 0xF5BE1880
out as
!!+* !!+*
In game: {!!+*}Join7 ...

COLOR: 0x00000090
out as: 90 90
In game: {90}Join7

COLOR: 0x00009999
out as in server.log: 9999 9999
in game: {9999}Join7

=WoR=Varth
31/08/2011, 01:37 PM
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),"{%06x}%s{FFFFFF} administrator disable command /heal",GetPlayerColor(playerid) >>> 8,string);
}
else if(eheal == false)
{
eheal = true;
GetPlayerName(playerid,string,sizeof(string));
format(string,sizeof(string),"{%06x}%s{FFFFFF} administrator disable command /heal",GetPlayerColor(playerid) >>> 8,string);
}
SendClientMessageToAll(color,string);
return 1;
}

Join7
31/08/2011, 01:46 PM
Thanks a lot bro

Join7
31/08/2011, 02:01 PM
Sorry for the double post, but spread it with a question.
When I start the server by typing /heal me write that command is disabled, can you do when you go and write /heal is permitted and forbidden to write once /dheal then be banned, not then be allowed

=WoR=Varth
31/08/2011, 02:06 PM
What do you mean? I don't get it.

Join7
31/08/2011, 02:11 PM
As I start the server by typing /heal me shows that the command is disabled. Can not run as a server to be enabled, not disabled. To disable to write /dheal

=WoR=Varth
31/08/2011, 02:14 PM
Your english is.........worst than mine.
You mean you want to allow everyone to use /dheal?

Join7
31/08/2011, 02:19 PM
After starting the server command /heal is to Enable, and not Disable

HyperZ
31/08/2011, 02:21 PM
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),"{%06x}%s{FFFFFF} administrator disable command /heal",GetPlayerColor(playerid) >>> 8,string);
}
else if(eheal == false)
{
eheal = true;
GetPlayerName(playerid,string,sizeof(string));
format(string,sizeof(string),"{%06x}%s{FFFFFF} administrator disable command /heal",GetPlayerColor(playerid) >>> 8,string);
}
SendClientMessageToAll(color,string);
return 1;
}
if(!IsPlayerAdmin(playerid)) return 0; // For rcon admin it should be 'return 0' not 1.

=WoR=Varth
31/08/2011, 02:28 PM
if(!IsPlayerAdmin(playerid)) return 0; // For rcon admin it should be 'return 0' not 1.

There's nothing to do with it. It just give error message for 0.

After starting the server command /heal is to Enable, and not Disable

aheal = true;//OnGameModeInit

Join7
31/08/2011, 02:32 PM
I do not mean RCON admin.
After starting the server by typing /heal command is Disable, and then I want to start the server by typing /heal command is Enable, because when I start the server, command is Disable, it write to me "Command is disabled."
As I start the server by typing /heal me and give HP ARMOR, and not written to me "command is disabled.". "The command is disabled" it appears to me when I wrote /dheal

=WoR=Varth
31/08/2011, 02:36 PM
aheal = true;//OnGameModeInit