Author Topic: Toggling A Mod  (Read 3731 times)

Could someone help me to toggle this mod with a console command?
Code: [Select]
package AutoGreeter
{
function newChatHud_addLine(%text)
if(%canGreet == 1)
{
{   
//Called when any line of text is added to the chat box
Parent::newChatHud_addLine(%text);
//This will turn the "jes00 connected." into "jes00"
%nameToGreet = strReplace(%text," connected.","");
//If the %nameToGreet variable is different to the original line greet them,
//otherwise it's something else
if(%nameToGreet !$= %text)
{
   //Send a chat message saying hi to the player who joined (%nameToGreet)
commandtoserver('messagesent',"Hi, " @ %nameToGreet);
        }
}
}
};
activatePackage(AutoGreeter);

function autogreetOn(%canGreet);
%canGreet = 1;
commandToClient(%a,'messageBoxOk',"Auto Greeter, by jes00","Auto Greeter is now: On.");

function autogreetOff(%canGreet);
%canGreet = 0;
commandToClient(%a,'messageBoxOk',"Auto Greeter, by jes00","Auto Greeter is now: Off.");

didn't you already put one at the bottom

jesus your formatting is horrible. and did you actually make this mod or was it from a tutorial? I see your name in there, but the function to turn it off (although it looks broken) is clearly right there in front of you, yet you still ask how to turn it on/off..

« Last Edit: September 02, 2011, 09:26:30 PM by Sulfate »

but the function to turn it off (although it looks broken) is clearly right there in front of you, yet you still ask how to turn it on/off..
I'm asking cause my attempt is not working.

I am not going to help until you fix the indentation sorry. If I liked looking through crap, I'd be studying to become a crapologist.

Code: [Select]
//Make all of your %canGreet's to $canGreet for this to actually work.
//If you want this to start out in on, make the script have a $canGreet = 1.
function togglegreet() {
if($canGreet == 1) {
$cangreet = 0;
} else if($canGreet == 0) {
$cangreet = 1;
}
}
Make sure you know what your doing and read the //'s.

Warning - while you were typing a new reply has been posted. You may wish to review your post.
Warning - while you were typing a new reply has been posted. You may wish to review your post.

no fu

I am not going to help until you fix the indentation sorry. If I liked looking through crap, I'd be studying to become a crapologist.

I actually was trying to fix his indenting but apparently my tab button doesn't want to work today ..

Code: [Select]
//Make all of your %canGreet's to $canGreet for this to actually work.
//If you want this to start out in on, make the script have a $canGreet = 1.
function togglegreet() {
if($canGreet == 1) {
$cangreet = 0;
} else if($canGreet == 0) {
$cangreet = 1;
}
}
Make sure you know what your doing and read the //'s.

Warning - while you were typing a new reply has been posted. You may wish to review your post.
Warning - while you were typing a new reply has been posted. You may wish to review your post.

no fu

there's no reason to make it a global variable, just put the function in the package .. also canGreet was never defined anywhere

(do you need to define it? been so long since I worked with torque :/ )

I actually was trying to fix his indenting but apparently my tab button doesn't want to work today ..

there's no reason to make it a global variable, just put the function in the package .. also canGreet was never defined anywhere

(do you need to define it? been so long since I worked with torque :/ )
There is a need to make it a global variable i believe. Or else it will not work with the other codes, just itself. And you do not need to define that, any made up variable is automaticly a 0. Scratch that, it makes absolutely nothing but a blank space.

Well then you need to define it's global variable as a 1 or 0. Im not going to do everything.

'nother edit: I tested it, didnt define $canGreet. Worked perfectly.
« Last Edit: September 02, 2011, 09:40:31 PM by Uxie »

When I put togglegreet in the console it does nothing.
Code: [Select]
package AutoGreeter
{
function newChatHud_addLine(%text)
if($canGreet == 1)
{
{   
//Called when any line of text is added to the chat box
Parent::newChatHud_addLine(%text);
//This will turn the "jes00 connected." into "jes00"
%nameToGreet = strReplace(%text," connected.","");
//If the %nameToGreet variable is different to the original line greet them,
//otherwise it's something else
if(%nameToGreet !$= %text)
{
   //Send a chat message saying hi to the player who joined (%nameToGreet)
commandtoserver('messagesent',"Hi, " @ %nameToGreet);
        }
}
}
};
activatePackage(AutoGreeter);

function ToggleGreet(%canGreet);
if($canGreet == 1) {
$canGreet = 0;
commandToClient(%a,'messageBoxOk',"Auto Greeter, by jes00","Auto Greeter is now: Off.");

} else if($canGreet == 0) {
$cangreet = 1;
commandToClient(%a,'messageBoxOk',"Auto Greeter, by jes00","Auto Greeter is now: On.");
}
}

When I put togglegreet in the console it does nothing.
Code: [Select]
package AutoGreeter
{
function newChatHud_addLine(%text)
if($canGreet == 1)
{
{   
//Called when any line of text is added to the chat box
Parent::newChatHud_addLine(%text);
//This will turn the "jes00 connected." into "jes00"
%nameToGreet = strReplace(%text," connected.","");
//If the %nameToGreet variable is different to the original line greet them,
//otherwise it's something else
if(%nameToGreet !$= %text)
{
   //Send a chat message saying hi to the player who joined (%nameToGreet)
commandtoserver('messagesent',"Hi, " @ %nameToGreet);
        }
}
}
};
activatePackage(AutoGreeter);

function ToggleGreet(%canGreet);
if($canGreet == 1) {
$canGreet = 0;
commandToClient(%a,'messageBoxOk',"Auto Greeter, by jes00","Auto Greeter is now: Off.");

} else if($canGreet == 0) {
$cangreet = 1;
commandToClient(%a,'messageBoxOk',"Auto Greeter, by jes00","Auto Greeter is now: On.");
}
}

Try to make it a clientcmd for easier use when it's fixed. Also, why using a messageBoxOk, you could just use a client chat message.

First off, I can't read your stuffty formatting. It's the most horrible formatting I've seen in a long time.
Second, I can tell you that the if($canGreet == 1) needs to be after the first bracket, not before
Third, check your console when something doesn't work. This would have given a syntax error report and you should at least make an attempt to figure out what's wrong.
« Last Edit: September 03, 2011, 01:50:26 PM by Headcrab Zombie »

Can't find anything wrong with it : /

You forgot the opening brace for the package.
Whenever there is a syntax error, look backwards in the code and you may find it there.

You forgot the opening brace for the package.
Whenever there is a syntax error, look backwards in the code and you may find it there.
If I do that then it says that is the problem.

If I do that then it says that is the problem.

Just post all of your code and let someone who knows what they are looking at fix it.

Code: [Select]
package AutoGreeter
{
function newChatHud_addLine(%text)
{
if($canGreet == 1)
{  
//Called when any line of text is added to the chat box
Parent::newChatHud_addLine(%text);
//This will turn the "jes00 connected." into "jes00"
%nameToGreet = strReplace(%text," connected.","");
//If the %nameToGreet variable is different to the original line greet them,
//otherwise it's something else
if(%nameToGreet !$= %text)
{
   //Send a chat message saying hi to the player who joined (%nameToGreet)
commandtoserver('messagesent',"Hi, " @ %nameToGreet);
        }
}
}
};
activatePackage(AutoGreeter);

function ToggleGreet()
if($canGreet == 1) {
$canGreet = 0;
clientCmdMessageBoxOK("Auto Greeter, by jes00","Auto Greeter is now: Off.");

} else if($canGreet == 0) {
$cangreet = 1;
clientCmdMessageBoxOK("Auto Greeter, by jes00","Auto Greeter is now: On.");
}
}

logic errors, misplaced brackets, unnecessary semicolons. see if it works.