Author Topic: Chatbot Help  (Read 2410 times)

Blockland wont load this because of syntax errors. I don't know the problem, but it said it was on line 6. Please help.

//Josheua & §gt. ßµïlÐêx's code
package JoshBot {
function clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg) {
parent::clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg)
 
     if (%msg $= "JoshBot") {
commandToServer('messageSent',"JoshBot: What?");
}
     if (%msg $= "no") {
commandToServer('messageSent',"JoshBot: Yes.");
}
     if (%msg $= "yes") {
commandToServer('messageSent',"JoshBot: No.");
}
    if (%msg $= "hi") {
        commandToServer('messageSent',"JoshBot: Sup.");  
     }
    if (%msg $= "sup") {
        commandToServer('messageSent',"JoshBot: Hey.");
}
if (%msg $= "Dog") {
    commandToServer('messageSent',"JoshBot: WOOF! BARK!");
 }
 if (%msg $= "jk") {
    commandToServer('messageSent',"JoshBot: yo mumma is a joke!");
  }
  
  }
}

if (!$JoshBotBindings)
{
 $remapDivision[$remapCount] = "JoshBot";
 $remapName[$remapCount] = "Activate/Deacticate";
 $remapCmd[$remapCount] = "JoshBotToggle";
 $remapCount++;
 $JoshBotBindings=true;
}

$JoshBotFlag=0;
function JoshBotToggle(%notdepressed)
{
 if (!%notdepressed) return;
 if($JoshBotFlag==0)
 {
  $JoshBotFlag=1;
  deactivatePackage(JoshBot);
 } else
 if($JoshBotFlag==1)
 {
  activatePackage(JoshBot);
  $JoshBotFlag=0;
  exec("Add-ons/Client_JoshBot/Client.cs");
 }
}
« Last Edit: June 09, 2013, 06:48:19 PM by killer2003 »

Fix
Blockland wont load this because of syntax errors. I don't know the problem, but it said it was on line 6. Please help.

//Josheua & §gt. ßµïlÐêx's code
package JoshBot {
function clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg) {
parent::clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg);
 
     if (%msg $= "JoshBot") {
commandToServer('messageSent',"JoshBot: What?");
}
     else if (%msg $= "no") {
commandToServer('messageSent',"JoshBot: Yes.");
}
     else if (%msg $= "yes") {
commandToServer('messageSent',"JoshBot: No.");
}
    else if (%msg $= "hi") {
        commandToServer('messageSent',"JoshBot: Sup.");  
     }
    else if (%msg $= "sup") {
        commandToServer('messageSent',"JoshBot: Hey.");
}
else if (%msg $= "Dog") {
    commandToServer('messageSent',"JoshBot: WOOF! BARK!");
 }
 else if (%msg $= "jk") {
    commandToServer('messageSent',"JoshBot: yo mumma is a joke!");
  }
  
  }
}

if (!$JoshBotBindings)
{
 $remapDivision[$remapCount] = "JoshBot";
 $remapName[$remapCount] = "Activate/Deacticate";
 $remapCmd[$remapCount] = "JoshBotToggle";
 $remapCount++;
 $JoshBotBindings=true;
}

$JoshBotFlag=0;
function JoshBotToggle(%notdepressed)
{
 if (!%notdepressed) return;
 if($JoshBotFlag==0)
 {
  $JoshBotFlag=1;
  deactivatePackage(JoshBot);
 } else
 if($JoshBotFlag==1)
 {
  activatePackage(JoshBot);
  $JoshBotFlag=0;
  exec("Add-ons/Client_JoshBot/Client.cs");
 }
}

The indentation is really horrible, so you might also want to fix that.
« Last Edit: June 09, 2013, 07:26:52 PM by Honorabl3 »


FixThe indentation is really horrible, so you might also want to fix that.
syntax error at line 31!

EDIT: Try to replace it with this script, see what happens.

Alternatively, you could do something like this:
//Josheua & §gt. ßµïlÐêx's code
package JoshBot
{
   function clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg)
   {
      parent::clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg);
      
      switch$(%msg)
      {
         case "JoshBot":
            commandToServer('messageSent',"JoshBot: What?");
         case "no":
            commandToServer('messageSent',"JoshBot: Yes.");
         case "yes":
            commandToServer('messageSent',"JoshBot: No.");
         case "hi":
            commandToServer('messageSent',"JoshBot: Sup.");
         case "sup":
            commandToServer('messageSent',"JoshBot: Hey.");
         case "Dog":
            commandToServer('messageSent',"JoshBot: WOOF! BARK!");
         case "jk":
            commandToServer('messageSent',"JoshBot: yo mumma is a joke!");
      }
   }
}

if (!$JoshBotBindings)
{
   $remapDivision[$remapCount] = "JoshBot";
   $remapName[$remapCount] = "Activate/Deacticate";
   $remapCmd[$remapCount] = "JoshBotToggle";
   $remapCount++;
   $JoshBotBindings=true;
}

$JoshBotFlag = 0;

function JoshBotToggle(%notdepressed)
{
   if (!%notdepressed)
      return;
   
   if($JoshBotFlag==0)
   {
      $JoshBotFlag=1;
      deactivatePackage(JoshBot);
   }
   
   else if($JoshBotFlag == 1)
   {
      activatePackage(JoshBot);
      $JoshBotFlag = 0;
      exec("Add-ons/Client_JoshBot/Client.cs");
   }
}

« Last Edit: June 09, 2013, 07:43:47 PM by Honorabl3 »


syntax error at line 21/22

Fixed, copy it again from above.

now its not even loading in the console

There is no way I can understand what that means unless I see the consoles response.

it did not show the addon Client_JoshBot executing in the console.
want to go on TitanPad to fix this?


Change the closing bracket for the JoshBot package to "};"?

Sometimes you have to get the file to be discovered and then execute it.

Most scripts I make I have a code like this:

Code: [Select]
function FixFile()
{
discoverfile("add-ons/Script_File.zip");
exec("add-ons/Script_File/client.cs");
}


Here is your fixed version of your bot. You were missing some things. I have also modified a few functions to make it a little clean.
Code: [Select]
//Josheua & §gt. ßµïlÐêx's code
package JoshBot
{
   function clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg)
   {
      parent::clientCmdChatMessage(%a,%b,%c,%fmsg,%cp,%name,%cs,%msg);
      if($JoshBotFlag)
   return;
 
      switch$(%msg)
      {
         case "JoshBot":
            commandToServer('messageSent',"JoshBot: What?");
         case "no":
            commandToServer('messageSent',"JoshBot: Yes.");
         case "yes":
            commandToServer('messageSent',"JoshBot: No.");
         case "hi":
            commandToServer('messageSent',"JoshBot: Sup.");
         case "sup":
            commandToServer('messageSent',"JoshBot: Hey.");
         case "Dog":
            commandToServer('messageSent',"JoshBot: WOOF! BARK!");
         case "jk":
            commandToServer('messageSent',"JoshBot: yo mumma is a joke!");
      }
   }
};
activatepackage(JoshBot);

if (!$JoshBotBindings)
{
   $remapDivision[$remapCount] = "JoshBot";
   $remapName[$remapCount] = "Activate/Deacticate";
   $remapCmd[$remapCount] = "JoshBotToggle";
   $remapCount++;
   $JoshBotBindings=true;
}

$JoshBotFlag = 0;

function JoshBotToggle()
{
$JoshBotFlag = !$JoshBotFlag;
echo($JoshBotFlag);
}
« Last Edit: June 10, 2013, 04:33:37 AM by Visolator »

Ok, ill try it. Thanks.