Blockland Forums > Modification Help
Toggling A Mod
<< < (4/7) > >>
jes00:

--- Quote from: otto-san on September 04, 2011, 07:10:23 PM ----code-

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

--- End quote ---
Still not working

--- Code: ---        $remapDivision[$remapCount] = "Chatbot";
        $remapName[$remapCount] = "Toggle Auto Greeter";
        $remapCmd[$remapCount] = "ToggleGreet";
        $remapCount++;

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.");
}
}

--- End code ---
infiniteLoop:

--- Quote from: jes00 on September 04, 2011, 07:53:51 PM ---Still not working

--- Code: ---        $remapDivision[$remapCount] = "Chatbot";
        $remapName[$remapCount] = "Toggle Auto Greeter";
        $remapCmd[$remapCount] = "ToggleGreet";
        $remapCount++;

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.");
}
}

--- End code ---

--- End quote ---

Jesus, your formatting. Each bracket should have its own line, like so:


function code(%arg)
{
     if(%arg)
     {
          //code
     }
}


Now look at the function you have, togglegreet. It is missing an opening bracket; this isn't Python.
Headcrab Zombie:
If you fixed your damn formatting you'd probably see these mistakes yourself
Aide33:

--- 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()
{
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.");
}
}

--- End code ---
This should work I tested it and ironed out the bugs
Red_Guy:
slightly simpler version.  Also with formatting fixed.


--- Code: ---package AutoGreeter
  {
   function newChatHud_addLine(%text)
     {
      Parent::newChatHud_addLine(%text);

      if ($canGreet)
        {   
         //Called when any line of text is added to the chat box

         //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 = !$canGreet;

   if ($canGreet)
      clientCmdMessageBoxOK("Auto Greeter, by jes00","Auto Greeter is now: Off.");
   else
      clientCmdMessageBoxOK("Auto Greeter, by jes00","Auto Greeter is now: On.");
  }

$canGreet=true;


--- End code ---
Navigation
Message Index
Next page
Previous page

Go to full version