Author Topic: Toggling Command  (Read 716 times)

How can you script something so you type /altwarner and it toggles my script on/off?

Code: [Select]
function serverCmdToggleMod(%client)
{
$varThatEnablesDisablesYourMod = !$varThatEnablesDisablesYourMod;
//and any other stuff you need to toggle
}

So I just put that in and it toggles everything?

Here... kinda messy but it works...


Code: [Select]
function serverCmdCOMMANDNAME(%client) {

if(%sentcommand.commandname == "") {
%sentcommand.commandname = 0;
}

if(%sentcommand.commandname == 1) {
//turn off
%sentcommand.commandname = 0;
} else {
//turn on
%sentcommand.commandname = 1;
}
}

hope this is what you needed
« Last Edit: June 14, 2011, 05:47:12 PM by tyler0 »

I tried
Code: [Select]
function serverCmdIPUTMYCOMMANDHERE(%client) {

if(%sentcommand.Iputmycommandhere == 1) {
//turn off
%sentcommand.Iputmycommandhere = 0;
messageClient(%client, '', "\c6jes00s mod had been turned \c5off\c6.");
} else {
//turn on
%sentcommand.Iputmycommandhere = 1;
messageClient(%client, '', "\c6jes00s mod has been turned \c5on\c6.");

}
}
and it did not work.

Code: [Select]
function serverCmdmycmd(%client) {

if(%client.mycmd == 1) {
messageClient(%client, '', "\c6jes00s mod had been turned \c5off\c6.");
//turn off
%client.mycmd = 0;
} else if(%client.mycmd == 0) {
messageClient(%client, '', "\c6jes00s mod has been turned \c5on\c6.");
//turn on
%client.mycmd = 1;
}
}

there you go
« Last Edit: June 14, 2011, 06:28:06 PM by tyler0 »

Code: [Select]
function serverCmdmycmd(%client) {

if(%client.mycmd == 1) {
messageClient(%client, '', "\c6jes00s mod had been turned \c5off\c6.");
//turn off
%client.mycmd = 0;
} else if(%client.mycmd == 0) {
messageClient(%client, '', "\c6jes00s mod has been turned \c5on\c6.");
//turn on
%client.mycmd = 1;
}
}

there you go
Still not working.

You actually need to replace the variable with the variable that controls your mod.

You actually need to replace the variable with the variable that controls your mod.
I replaced all the "mycmd"s.

Simply use this code. Replace $varThatEnablesDisablesYourMod with the actual variable that enables your mod.

Quote
function serverCmdToggleMod(%client)
{
   $varThatEnablesDisablesYourMod = !$varThatEnablesDisablesYourMod;
   //and any other stuff you need to toggle
}
Note the ! before the bolded variable. That makes it the opposite of what the variable was.