Back Reply to topic
Goto page Previous  1, 2, 3  Next
kardson 
(started thread)
Topfight Chicken 
Topics: 6
Posts: 38
Playing:  AOC
Ingame:  kardson
Years registered: * * * * * * * * * * * * * * * * *
Posted: Post 06:49 Mon - Jun 30, 2008

Vrykolas,

Thanks I was looking for something just like this!

Going to test out how well it connects to a remote sql server once the US servers come back online
Reply with quote


kardson 
(started thread)
Topfight Chicken 
Topics: 6
Posts: 38
Playing:  AOC
Ingame:  kardson
Years registered: * * * * * * * * * * * * * * * * *
Posted: Post 08:42 Mon - Jun 30, 2008

When loading the bot with your addon.

I get the following error:

C:\AOC BOTS\Ragebottest>bot.php
PHP Fatal error: Class 'PDO' not found in C:\AOC BOTS\Ragebottest\inc\customize
d\bot_database.php on line 33



So I installed the PDO extension.
Now I get the following error

Error!: Could not find driver
Reply with quote


Vrykolas 
Blue-Ribbon Chicken 
Topics: 0
Posts: 10
Playing:  Age of Conan
Ingame:  Vrykolas
Years registered: * * * * * * * * * * * * * * * * *
Posted: Post 12:31 Tue - Jul 01, 2008

You also need to install the driver for the database - php5-sqlite & php5-sqlite3 for the sqlite database, php5-mysql & php5-mysqli for mysql etc

if you're using Ubuntu the commands are:

sudo apt-get install php5-sqlite
sudo apt-get install php5-sqlite3

sudo apt-get install php5-mysql

etc.

Hope this helps
Reply with quote


kardson 
(started thread)
Topfight Chicken 
Topics: 6
Posts: 38
Playing:  AOC
Ingame:  kardson
Years registered: * * * * * * * * * * * * * * * * *
Posted: Post 02:08 Tue - Jul 01, 2008

Found out I had to quote out the following line in my php.ini as well

extension=php_pdo_sqlite_external.dll
Reply with quote


kardson 
(started thread)
Topfight Chicken 
Topics: 6
Posts: 38
Playing:  AOC
Ingame:  kardson
Years registered: * * * * * * * * * * * * * * * * *
Posted: Post 06:12 Tue - Jul 01, 2008

Everything is working great.


Now im trying to have it update a table in the sql database that shows the people currently online.

It should update about every 5minutes

I've already made the table guildbot_online_toons

this is the code I put into a folder in the 5000ms folder

Code:

<?php

   global $BuddyList,$guildmates,$guildmains;
   if (time()-$guildmates[0]>400) {
   
   $db->exec('DELETE * FROM '.$dbconfig['dbprefix'].'online_toons;');
   say ("Deleted old online list");

   $BuddyClasses=array(); foreach($BuddyList as $buddy) $BuddyClasses[]=$buddy["class"];
   $BuddySorted =$BuddyList;
   array_multisort($BuddyClasses,SORT_ASC,$BuddySorted);
   $BuddyClasses="";
   foreach ($BuddySorted as $buddy) {
      if ( $guildmates[$buddy["name"]] && $buddy["status"]>0 ) {
      $db->exec('INSERT INTO '.$dbconfig['dbprefix'].'online_toons VALUES (".$buddy["name"].", ".$buddy["class"].", ".$buddy["level"].");');
      say ("Added ".$buddy["name"]." ".$buddy["class"]." ".$buddy["level"]." ");
      }
   }
}

?>


it doesn't seem to update though ...
Reply with quote


Vrykolas 
Blue-Ribbon Chicken 
Topics: 0
Posts: 10
Playing:  Age of Conan
Ingame:  Vrykolas
Years registered: * * * * * * * * * * * * * * * * *
Posted: Post 10:26 Tue - Jul 01, 2008

you need to reference $db and $dbconfig as globals

I'm going to assume that you've created the table (add the line below to the bottom of bot_database.php (so that it's only called when the bot starts) or immediately below the globals statement (though this is not really advised as it will run every 5 seconds))

Code:
$db->exec("CREATE TABLE IF NOT EXISTS ".$dbconfig['dbprefix']."online_toons (toon_name varchar(255) NOT NULL DEFAULT '', class varchar(255) NOT NULL DEFAULT '', toon_level INTEGER UNSIGNED NOT NULL DEFAULT '1', PRIMARY KEY (toon_name));");


Try this code in your 5000ms folder

Code:

<?php

   global $BuddyList,$guildmates,$guildmains,$db,$dbconfig;
   if (time()-$guildmates[0]>300)
   {
   
      $db->exec('DELETE * FROM '.$dbconfig['dbprefix'].'online_toons;');
      say ("Deleted old online list");
      
      $BuddyClasses=array(); foreach($BuddyList as $buddy) $BuddyClasses[]=$buddy["class"];
      $BuddySorted =$BuddyList;
      array_multisort($BuddyClasses,SORT_ASC,$BuddySorted);
      $BuddyClasses="";
   
      $toon_name = '';
      $class = '';
      $level = '';
      $sql = 'INSERT INTO '.$dbconfig['dbprefix'].'online_toons VALUES (:toon_name, :class, :level);';
      $stmt = $db->prepare($sql);
      $stmt->bindParam(':toon_name', $toon_name);
      $stmt->bindParam(':class', $class);
      $stmt->bindParam(':level', $level);

      foreach ($BuddySorted as $buddy)
      {
         if ( $guildmates[$buddy["name"]] && $buddy["status"]>0 )
         {
            $toon_name = $buddy["name"];
            $class = $buddy["class"];
            $level = $buddy["level"];
            $stmt->execute();
            say ("Added ".$buddy["name"]." ".$buddy["class"]." ".$buddy["level"]." ");
         }
      }
   }

?>


Hope this helps
Reply with quote


Snibbeldibbel 
Blue-Ribbon Chicken 
Topics: 3
Posts: 17
 
 
Years registered: * * * * * * * * * * * * * * * * *
Posted: Post 11:43 Tue - Jul 01, 2008

just a question,
do i see this right, when i get this bot to run by my webhoster, that i can add the other "plugins" to them to, that it will works there too? or is this bot only to show the onlinemembers to an HP?
Reply with quote


Vrykolas 
Blue-Ribbon Chicken 
Topics: 0
Posts: 10
Playing:  Age of Conan
Ingame:  Vrykolas
Years registered: * * * * * * * * * * * * * * * * *
Posted: Post 11:58 Tue - Jul 01, 2008

Snibbeldibbel wrote:
just a question,
do i see this right, when i get this bot to run by my webhoster, that i can add the other "plugins" to them to, that it will works there too? or is this bot only to show the onlinemembers to an HP?


the database plugin/modification will run as long as the PDO extension for PHP and the PDO drivers for your chosen database are installed.
Reply with quote


Vrykolas 
Blue-Ribbon Chicken 
Topics: 0
Posts: 10
Playing:  Age of Conan
Ingame:  Vrykolas
Years registered: * * * * * * * * * * * * * * * * *
Posted: Post 12:38 Tue - Jul 01, 2008

To further clarify

The plugins cannot be guaranteed to run on the webserver.

We do our best to ensure that they will run without forther configuration of the server, but sometimes we either code for something specific (for example the PDO part of my SQL plugin) or the code has to rely on a specific component (for example bcmath in the case of the core aocchat.php file).

In that case it is down to the hosting company/person who looks after the server to say whether or not the needed components will be installed.

As a general rule, make a backup of your files before you add something new, that way if something goes wrong you can always restore your old version.

Hope this helps
Reply with quote


kardson 
(started thread)
Topfight Chicken 
Topics: 6
Posts: 38
Playing:  AOC
Ingame:  kardson
Years registered: * * * * * * * * * * * * * * * * *
Posted: Post 01:32 Tue - Jul 01, 2008

Vrykolas,

Thanks. I already had the CREATE TABLE IF NOT EXISTS lachen

Using the code you provided. Its a little earlier in the morning here in Michigan, USA to test it... (8:30am) No one is online yet.

I will let you know how it runs.



Also, Your code connects beautifully to a remote SQL database lachen
Rather than running the bot on my webhost, I have it running on a old PC at my house. And I use your code to upload the databases.

We'll see how much bandwidth I use after a couple days, though I can't imagine much.
Reply with quote


kardson 
(started thread)
Topfight Chicken 
Topics: 6
Posts: 38
Playing:  AOC
Ingame:  kardson
Years registered: * * * * * * * * * * * * * * * * *
Posted: Post 09:29 Tue - Jul 01, 2008

Vrykolas,

The code provided does not seem work either.
2 issues:

1. with the default time of 5minutes
if (time()-$guildmates[0]>300)
the bot never runs the function

with a default time of 2minutes
if (time()-$guildmates[0]>120)
The bot runs the function every couple seconds.
I see in the debug window it stating each person it is adding per the say command added
say("Added ".$buddy["name"]." ".$buddy["class"]." ".$buddy["level"]." ",1);


2. Even when the bot is running that command every couple seconds, it doesn't seem to upload any info to the database. I have even went as far as to commend out the
$db->exec('DELETE * FROM '.$dbconfig['dbprefix'].'online_toons;');
line
Reply with quote


Vrykolas 
Blue-Ribbon Chicken 
Topics: 0
Posts: 10
Playing:  Age of Conan
Ingame:  Vrykolas
Years registered: * * * * * * * * * * * * * * * * *
Posted: Post 12:35 Wed - Jul 02, 2008

it's having timing problems because

$guildmates[0] is being reset by another plugin -

maybe replace:
Code:

   global $BuddyList,$guildmates,$guildmains,$db,$dbconfig;
   if (time()-$guildmates[0]>300)
   {


with
Code:

   global $BuddyList,$guildmates,$guildmains,$db,$dbconfig,$buddyTimer;
   if (!isset($buddyTimer) || time()-$buddyTimer>300)
   {
      $buddyTimer = time();


as for the SQL, try replacing
Code:

$stmt->execute();

with
Code:

if(false === $stmt->execute())
   say ("There has been a problem executing the SQL: ".print_r($stmt->errorInfo(), true));
else
   say ("Added ".$buddy["name"]." ".$buddy["class"]." ".$buddy["level"]." ");

and checking the log

I haven't tested these and won't get a chance to until tomorrow evening, but I may be able to figure stuff out if you pm me the log

Vry
Reply with quote


Goto page Previous  1, 2, 3  Next
Back Reply to topic