collapse collapse
* User Info
 
 
Welcome, Guest. Please login or register.
* Search

* Board Stats
  • stats Total Members: 989
  • stats Total Posts: 18366
  • stats Total Topics: 2501
  • stats Total Categories: 7
  • stats Total Boards: 35
  • stats Most Online: 1144

Author Topic: New module - Raid Relics tracker  (Read 38095 times)

0 Members and 1 Guest are viewing this topic.

Offline Xene

  • BeBot Rookie
  • *
  • Posts: 17
  • Karma: +0/-0
New module - Raid Relics tracker
« on: March 20, 2014, 07:10:52 pm »
Hey

This module cant be run a 0.6.9 version of the bot, i run it perfectly on a 0.6.8 version of the bot. Seems that the table construction isnt valid on the first bot mentioned.

Any ideas?

Xene

Since i couldnt make an attachment i have copied the module here:

<?php
/*
* RaidRelics.php  --- RaidRelics
* <Copyright Xene @ Crom Aoc>
*
*
*/
$version = "b1.0.0 - 2014-10-03";
// b1.0.0 First version of the module
/*
* BeBot - An Anarchy Online & Age of Conan Chat Automaton
* Copyright (C) 2004 Jonas Jax
* Copyright (C) 2005-2007 Thomas Juberg Stens?s, ShadowRealm Creations and the BeBot development team.
*
*/
$Relics = new RaidRelics($bot);
$Relics -> version = $version;

class RaidRelics extends BaseActiveModule
{
   var $version;
   /*
   * Defining the arrays needed for the module based on Tier and Location
   */
   var $Tier_relics_rare_name = array ('Rare','Rare','Dragon Tear');
   var $Tier_relics_name = array ('Simple I', 'Simple II', 'Simple III', 'Simple IV', 'Simple IV');
   var $Tier_name_short = array ('T1','T2','T3','T3.5','T4');
   var $Tier_name_long = array ('Tier 1','Tier 2','Tier 3','Tier 3.5', 'Tier 4');
   var $Armor_Location = array ('Head','Chest','Legs','Shoulders','Wrists','Hands','Belt','Boots');
   var $Tier_relics_simple = array ( 0 => array (6,6,6,4,4,4,4,4),
                             1 => array (10,10,10,7,7,7,7,7),
                             2 => array (60,60,60,40,40,40,40,20),
                             3 => array (40,40,40,25,25,25,25,25),
                             4 => array (60,60,60,40,40,40,40,40));
   var $Tier_relics_rare = array (0,0,1,2,1);
   var $Tier_gold = array (2,3,5,5,7);
   
   function __construct (&$bot)
   {
      /* Constructor: Hands over a ref to the "Bot" class. */
      // Initialize the base module
      parent::__construct(&$bot, get_class($this));
      $this -> bot -> db -> query("CREATE TABLE IF NOT EXISTS " .
         $this -> bot -> db -> define_tablename("RaidRelics", "True") . "(
         `RaidRelics_id` int(11) NOT NULL AUTO_INCREMENT,
         `RaidRelics_username` varchar(255) DEFAULT NULL,
         `RaidRelics_tier` varchar(10) DEFAULT NULL,
         `RaidRelics_item` varchar(100) DEFAULT NULL,
         `RaidRelics_rare` int(11) DEFAULT NULL,
         `RaidRelics_relics` int(11) DEFAULT NULL,
         `RaidRelics_gold`int(11) DEFAULT NULL,
         PRIMARY KEY (`RaidRelics_id`))");
      
                  
      $this -> register_command('all', 'relics', 'MEMBER');
      $this -> help['description'] = "This module helps you keep track of relics won in raids.";
      $this -> help['command']['relics '] = "Show which items you have and how many relics you need to complete the tier";
      $this -> help['command']['relics show <another char>'] = "Shows the relics for other chars that is registered.";
      $this -> help['command']['relics add <Tier> <Body part>'] = "Adds a new item to your list. \n <Body part> = Head, Chest, Legs, Shoulders, Wrists, Hands, Belt, Boots";
      $this -> help['notes'] = " (C) Module by Xene@Crom\n";
   }
   function command_handler($name, $msg, $origin)
   {
      /* Unified message handler
            $name: The origin player
            $msg: the actual message, including command prefix and all
            $origin: the channel the message arrived from. This can be either "tell" or "gc"
      */
      $com = $this -> parse_com($msg);
      switch($com['com'])
      {
         case 'relics':
            return($this->sub_handler($name,$com,1));
         break;
         default:
            return "Error 1";
         break;
      }
   }
   function sub_handler($name,$com,$type)
   {
      switch($com['sub'])
      {
         case 'add':
            return($this -> relics_add($name, $com['args']));
         break;
         case 'show':
            return($this -> relics_show($name, $com['args']));
         break;
         default:
            return($this -> relics_show($name, $com['args']));
         break;
      }
   }
   function relics_add($name,$args)
   {
      $arr = explode(" ", $args);
      $firstspace = strpos($args, ' ');
      $i = -1;
      $n = -1;
      $num = 0;
      empty($result);
      $armor_exist = FALSE;
      $higher_tier_not_exist = FALSE;
      $armor_is_in_list = FALSE;
      
      for ($i=0;$i<=4;$i++)
      {
         if ($this->Tier_name_short[$i]==$arr[0])
         {
            $tier_found = $i;
         }
      }
      for ($n=0;$n<=7;$n++)
      {
         if ($this->Armor_Location[$n]==$arr[1])
         {
            $armor_is_in_list = TRUE;
            $armor_found = $n;
         }
      }
      if (!$armor_is_in_list)
      {
         Return "Wrong item name!";
      }
      
      $RaidRelics_username = mysql_real_escape_string($name);
      $RaidRelics_tier = $arr[0];
      $RaidRelics_item = $this -> Armor_Location[$armor_found];
      $RaidRelics_gold = $this -> Tier_gold[$tier_found];
      $RaidRelics_relics = $this -> Tier_relics_simple[$tier_found][$armor_found];
      $RaidRelics_rare = $this -> Tier_relics_rare[$tier_found];
      
      // Check if the item is already in the list for this char
      
      $sql = "SELECT * FROM #___RaidRelics WHERE RaidRelics_username = '$name'";
      $result = $this -> bot -> db -> select($sql);
      
      
      if (!empty($result))
      {
         foreach ($result as $val)
         {
            $rr_tier[$num] = $val[2];
            $rr_item[$num] = $val[3];
            $rr_rare[$num] = $val[4];
            $rr_simple[$num] = $val[5];
            $rr_gold[$num] = $val[6];
            $num++;
         }
         
         $armor_exist = FALSE;
         $higher_tier_exist = TRUE;
         for ($z=0;$z<=$num-1;$z++)
         {
            if ($rr_item[$z] == $this->Armor_Location[$armor_found])
            {
               for ($x=0;$x<=4;$x++)
               {
                  if ($this->Tier_name_short[$x]==$rr_tier[$z])
                  {
                     $tier_in_database = $x;
                  }
               }
               if ($tier_in_database < $tier_found)
               {
                  $higher_tier_exist = FALSE;
               }
               $armor_exist = TRUE;
            }
         }
         if ($armor_exist)
         {
            if (!$higher_tier_exist)
            {
               $sql = "UPDATE #___RaidRelics SET RaidRelics_tier='$RaidRelics_tier',
               RaidRelics_rare='$RaidRelics_rare',RaidRelics_relics='$RaidRelics_relics',
               RaidRelics_gold='$RaidRelics_gold' WHERE RaidRelics_username='$name' AND RaidRelics_item='$arr[1]'";
            }
            else
            {
               return "Higher tier is already in the database!";
            }
         }
         else
         {
            $sql = "INSERT INTO #___RaidRelics (RaidRelics_username,RaidRelics_tier,RaidRelics_item,RaidRelics_rare,RaidRelics_relics,RaidRelics_gold)
                  VALUES ('$RaidRelics_username','$RaidRelics_tier','$RaidRelics_item','$RaidRelics_rare','$RaidRelics_relics','$RaidRelics_gold')";   
         }
         $this -> bot -> db ->  query($sql);
         
      }
      else
      {
         $sql = "INSERT INTO #___RaidRelics (RaidRelics_username,RaidRelics_tier,RaidRelics_item,RaidRelics_rare,RaidRelics_relics,RaidRelics_gold)
               VALUES ('$RaidRelics_username','$RaidRelics_tier','$RaidRelics_item','$RaidRelics_rare','$RaidRelics_relics','$RaidRelics_gold')";
         $this -> bot -> db ->  query($sql);
      }
      return $this->relics_show($name,null);
      
   }
   function relics_show($name,$args)
   {
      if (!empty($args))
      {
          $name = mysql_real_escape_string($args);
        }

      $num = 0;
      empty($result);
      
      $guide = "Raid armor for " . $name . "\n \n \n";
      $guide = $this->bot->core("colors")->colorize("fuchsia", $guide);

      $sql = "SELECT * FROM #___RaidRelics WHERE RaidRelics_username = '" . $name ."'";
      $result = $this -> bot -> db -> select($sql);
      
      if (!empty($result))
      {
         // Fetches the data from base and puts into arrays for counting
         foreach ($result as $val)
         {
            $rr_tier[$num] = $val[2];
            $rr_item[$num] = $val[3];
            $rr_rare[$num] = $val[4];
            $rr_simple[$num] = $val[5];
            $rr_gold[$num] = $val[6];
            $num++;
         }
         $guide .= $this -> bot -> core("colors")->colorize("lightfuchsia","Armor items: \n");
         
         // Adds up collected relics from items
         
         for ($z=0;$z<=$num;$z++)
         {
            for ($i=0;$i<=4;$i++)
            {
               if ($rr_tier[$z] == $this -> Tier_name_short[$i])
               {
                  for ($n=0;$n<=7;$n++)
                  {
                     if ($rr_item[$z] == $this -> Armor_Location[$n])
                     {
                        $colrare[$i] = $colrare[$i] + $this->Tier_relics_rare[$i];
                        $colsim[$i] = $colsim[$i] + $this->Tier_relics_simple[$i][$n];
                        $colgold[$i] = $colgold[$i] + $this->Tier_gold[$i];
                        if ($i>0)
                        {
                           for ($x=0;$x<$i;$x++)
                           {
                              $colrare[$x] = $colrare[$x] + $this->Tier_relics_rare[$x];
                              $colsim[$x] = $colsim[$x] + $this->Tier_relics_simple[$x][$n];
                              $colgold[$x] = $colgold[$x] + $this->Tier_gold[$x];
                           }
                        }
                     }
                  }
               }
            }
         }
         
         // Build up the report
         
         for ($n=0;$n<=7;$n++)
         {
            for ($z=0;$z<=$num;$z++)
            {
               if ($rr_item[$z] == $this -> Armor_Location[$n])
               {
                  for ($i=0;$i<=4;$i++)
                  {
                     if ($rr_tier[$z] == $this -> Tier_name_short[$i])
                     {
                        $guide .= $this -> bot -> core("colors")->colorize("bluesilver",$this -> Armor_Location[$n] . " : " . $this -> Tier_name_long[$i] . "\n");
                        $note = TRUE;
                     }
                     
                  }
               }
               
            }
            if (!$note)
            {
               $guide .= $this -> bot -> core("colors")->colorize("bluesilver", $this -> Armor_Location[$n] . " : " . "none \n");
            }
            $note = FALSE;
         }
         $guide .= $this -> bot -> core("colors")->colorize("lightfuchsia","Relics needed: \n");
         for ($n=0;$n<=4;$n++)
         {
            $i = 0;
            for ($i=0;$i<=7;$i++)
            {
               if ($i<=2)
               {
                  $simrare[$n] = $simrare[$n] + $this->Tier_relics_rare[$n];
               }
               $simrel[$n] = $simrel[$n] + $this->Tier_relics_simple[$n][$i];
               $simgold[$n] = $simgold[$n] + $this->Tier_gold[$n];
            }
            $simrare[$n] = $simrare[$n] - $colrare[$n];
            $simrel[$n] = $simrel[$n] - $colsim[$n];
            $simgold[$n] = $simgold[$n] - $colgold[$n];
            $guide .= $this->bot->core("colors")->colorize("green", $this->Tier_name_long[$n] . ": ");
            if ($simrare[$n]>0)
            {
               $guide .= $this->bot->core("colors")->colorize("lime", $simrare[$n] . " " . $this->Tier_relics_rare_name[$n-2] ." , ");
            }
            $guide .= $this->bot->core("colors")->colorize("lightteal", $simrel[$n] ." ". $this->Tier_relics_name[$n]);
            $guide .= $this->bot->core("colors")->colorize("green"," and " );
            $guide .= $this->bot->core("colors")->colorize("gold", $simgold[$n] . " gold! \n");
            $simrel[$n+1] = 0;
            $simgold[$n+1] = 0;
            $simrare[$n+1] = 0;
         }   
         empty($result);
      }
      else
      {
         $guide .= $this->bot->core("colors")->colorize("red","No items gathered! \n");
         $rarname = "";
         for ($n=0;$n<=4;$n++)
         {
            $i = 0;
            for ($i=0;$i<=7;$i++)
            {
               if ($i<=2)
               {
                  $simrare = $simrare + $this->Tier_relics_rare[$n];
               }
               $simrel = $simrel + $this->Tier_relics_simple[$n][$i];
               $simgold = $simgold + $this->Tier_gold[$n];
            }
            $guide .= $this->bot->core("colors")->colorize("green", $this->Tier_name_long[$n] . ": ");
            if ($simrare>0)
            {
               $guide .= $this->bot->core("colors")->colorize("lime", $simrare . " " . $this->Tier_relics_rare_name[$n-2] ." , ");
            }
            $guide .= $this->bot->core("colors")->colorize("lightteal", $simrel ." ". $this->Tier_relics_name[$n]);
            $guide .= $this->bot->core("colors")->colorize("green"," and " );
            $guide .= $this->bot->core("colors")->colorize("gold", $simgold . " gold! \n");
            $simrel = 0;
            $simgold = 0;
            $simrare = 0;
         }   
      }
      
      return $this -> bot -> core("tools") -> make_blob("Relics",$guide);
   }

}
?>
« Last Edit: March 23, 2014, 01:32:14 pm by Xene »

Offline Getrix

  • Contributor
  • *******
  • Posts: 509
  • Karma: +0/-0
Re: New module - Raid Relics tracker
« Reply #1 on: March 23, 2014, 10:17:05 pm »
Are you using the same database or seperate for each bot version?

Is there any error output in console, when starting up or typing the commando in guild chat/msg?
Success is not final, failure is not fatal: it is the courage to continue that counts.
- Sorry, i dont have time to reply question on PM. Make a topic.

Offline Xene

  • BeBot Rookie
  • *
  • Posts: 17
  • Karma: +0/-0
Re: New module - Raid Relics tracker
« Reply #2 on: March 24, 2014, 03:25:02 pm »
Two different databases on two seperated machines. On the machine with the 0.6.9 version it will not initialize even. I get this msg:

Fatal Error: Call-time pass-by-referance has been removed in "Referance to this module" in line 42.

When i rename it to: _module.php the bot starts fine and works fine

Offline Getrix

  • Contributor
  • *******
  • Posts: 509
  • Karma: +0/-0
Re: New module - Raid Relics tracker
« Reply #3 on: March 25, 2014, 08:21:56 am »
Is the filename "modules.php"? Make sure to rename it to RaidRelics.php and keep it in Botpath\custom\modules

Whats on your line nr 42 in the file?

I tried the file with 0.6.9-snapshot and it did not crash.

Success is not final, failure is not fatal: it is the courage to continue that counts.
- Sorry, i dont have time to reply question on PM. Make a topic.

Offline Xene

  • BeBot Rookie
  • *
  • Posts: 17
  • Karma: +0/-0
Re: New module - Raid Relics tracker
« Reply #4 on: March 25, 2014, 04:07:27 pm »
Line 42:   parent::__construct(&$bot, get_class($this));

Even with the suggested changes same error.

Offline Getrix

  • Contributor
  • *******
  • Posts: 509
  • Karma: +0/-0
Re: New module - Raid Relics tracker
« Reply #5 on: March 25, 2014, 09:07:18 pm »
Could you copy/past everything you get on output, or take a screenshot of as much output as possible before the error.
Success is not final, failure is not fatal: it is the courage to continue that counts.
- Sorry, i dont have time to reply question on PM. Make a topic.

Offline Xene

  • BeBot Rookie
  • *
  • Posts: 17
  • Karma: +0/-0
Re: New module - Raid Relics tracker
« Reply #6 on: March 25, 2014, 09:54:24 pm »
Here you go, Getrix.

Any ideas whats wrong?
« Last Edit: March 28, 2014, 11:33:43 pm by Xene »

Offline Xene

  • BeBot Rookie
  • *
  • Posts: 17
  • Karma: +0/-0
Re: New module - Raid Relics tracker
« Reply #7 on: March 30, 2014, 09:52:14 am »
Anyone else trying this module out?

Any troubles getting it to run with the 0.6.9 version?

Offline Getrix

  • Contributor
  • *******
  • Posts: 509
  • Karma: +0/-0
Re: New module - Raid Relics tracker
« Reply #8 on: March 30, 2014, 06:06:40 pm »
You could try to remove (rename or move to another folder) all other custom script you have.
It could be that you have same referance in another script that causing the crash..
Success is not final, failure is not fatal: it is the courage to continue that counts.
- Sorry, i dont have time to reply question on PM. Make a topic.

Offline Tyrence

  • BeBot User
  • **
  • Posts: 41
  • Karma: +0/-0
Re: New module - Raid Relics tracker
« Reply #9 on: April 18, 2014, 09:38:51 am »
This is similar to to another post I just replied to but basically you are running PHP 5.4 which doesn't like some of the code in that module.  You can either go back to a previous version of PHP on your server (5.3, 5.2, 5.1 maybe), or update the code to work in 5.4.  If you want to update the code, you can do a google search for "call time pass by reference" to see how to fix it.

 

* Recent Posts
Com bot module by bitnykk
[November 25, 2024, 05:36:11 pm ]


0.8.x updates for AO by bitnykk
[June 23, 2024, 03:19:47 pm ]


0.8.x updates for AoC by bitnykk
[June 23, 2024, 03:19:44 pm ]


[AoC] special char for items module by bitnykk
[February 09, 2024, 09:41:18 pm ]


BeBot still alive & kicking ! by bitnykk
[December 17, 2023, 12:58:44 am ]

* Who's Online
  • Dot Guests: 117
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.
* Forum Staff
bitnykk admin bitnykk
Administrator
Khalem admin Khalem
Administrator
WeZoN gmod WeZoN
Global Moderator
SimplePortal 2.3.7 © 2008-2024, SimplePortal