Blockland Forums > Modification Help
Toggling A Mod
Sulfate:
--- Quote from: infiniteLoop on September 02, 2011, 09:26:54 PM ---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.
--- End quote ---
I actually was trying to fix his indenting but apparently my tab button doesn't want to work today ..
--- Quote from: Uxie on September 02, 2011, 09:27:50 PM ---
--- Code: ---//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;
}
}
--- End code ---
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
--- End quote ---
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 :/ )
Uxie:
--- Quote from: Sulfate on September 02, 2011, 09:29:15 PM ---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 :/ )
--- End quote ---
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.
jes00:
When I put togglegreet in the console it does nothing.
--- Code: ---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.");
}
}
--- End code ---
mp7964:
--- Quote from: jes00 on September 03, 2011, 10:43:40 AM ---When I put togglegreet in the console it does nothing.
--- Code: ---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.");
}
}
--- End code ---
--- End quote ---
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.
Headcrab Zombie:
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.