BeBot - An Anarchy Online and Age Of Conan chat automaton
Archive => Anarchy Online Archive => BeBot 0.2 support => Topic started by: Dabaron on May 20, 2006, 10:51:26 pm
-
I have recently installed BeBot v0.2.4 and got it all working and everything. One problem I'm having that I can't seem to resolve is if I use the !city or !cloak commands the bot crashes. I've looked through all the files and tried finding something about it on here but dont' see anything.
Anyone shed a little light on it for me?
-
well drop cloak once and then it should work,
thats what i happend also i think, not sure.
-
Ok, have now ran a raid so cloak has been off and then back on and stil crashes bot. Noticed that it didn't create the org_city table in mysql for some reason so manually added that and same thing.
Any other ideas?
-
the cmd window that the bot runs on should show you an error. What does it say?
Rather than us trying to guess what the problem is, an exact error would be much more helpful.
BTW, you can turn on error logging in PHP.
Place this in the php.ini file that is local to the bot(I.E. the ini in the folder you installed Bebot too)
; Error handling and logging ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
display_errors = On
display_startup_errors = On
log_errors = On
log_errors_max_len = 4096
error_log = ./log/php_errors.txt
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
I havent had the time to look into this yet, but an exact error would make my job easier when the time comes.
-
It pops 2 errors and then bot restarts.
Warning: Invalid argument supplied for foreach() in C:\BeBot\BeBot_v0.2.4\BeBot_v0.2.4\BeBot-php_v5.1.4\modules\AlienAttack_GUILD.php on line 98
Fatal error: Cannot use string offset as an array in C:\BeBot\BeBot_v0.2.4\BeBot_v0.2.4\BeBot-php_v5.1.4\modules\AlienAttack_GUILD.php on line 118.
-
Decided to test and see if it just didn't like php5.x so rolled back to PHP4. Same error right off but haven't triggered another raid yet to see if that will make a difference. I'm also noticing one other strange thing happening that prompted me to try this. The !battle command works great, but the !victory command dosen't. Well, it does sort of. The window comes up but never any data in it.
Will let you know if it makes any difference
-
The bug is pretty clear. If there have been no city events, there will be an empty result from the database. The module does not take this possibility into account and assumes there will always be something in the database.
Try the following fix. Open modules/AlienAttack_GUILD.php
Find the following code:
function city_blob()
{
$city = "<font color=CCInfoHeadline>::::: Recent City Attacks :::::</font><font color=CCInfoText>\n\n";
$result = $this -> bot -> db -> select("SELECT time, action, player FROM org_city ORDER BY time DESC LIMIT 0, 12");
foreach ($result as $res)
{
$city .= "<font color=CCInfoHeader>Time:</font> <font color=CCCCHeaderColor>" . gmdate("M j, Y, G:i", $res[0]) . " GMT</font>\n";
if ($res[1] == "attack")
$city .= "City was attacked.\n";
else if ($res[1] == "on")
$city .= $res[2] . " turned cloaking <font color=CCCCTextColor>on</font>.\n";
else if ($res[1] == "off")
$city .= $res[2] . " turned cloaking <font color=CCCCTextColor>off</font>.\n";
else if ($res[1] == "hq")
$city .= $res[2] . " destroyed the <font color=CCCCTextColor>HQ</font>.\n";
else if ($res[1] == "house")
$city .= $res[2] . " destroyed a <font color=CCCCTextColor>building</font>.\n";
$city .= "\n";
}
$result = $this -> bot -> db -> select("SELECT time, action FROM org_city WHERE action = 'on' OR action = 'off' ORDER BY time DESC LIMIT 0, 1");
$avilmin = date("i",3600-(time()-$result[0][0]));
$avilsec = date("s",3600-(time()-$result[0][0]));
if ($result[0][1] == "on")
{
$status = "enable";
$status2 = "disable";
}
else
{
$status = "disable";
$status2 = "enable";
}
if($result[0][0] > (time() - 3600))
$ttchange = true;
else
$ttchange = false;
$state = "The cloaking device is <font color=#ffff00>" . $status . "d</font>.";
$state .= $ttchange ? "" : " It is now possible to <font color=#ffff00>" . $status2 . "</font> it. ";
$state .= $ttchange ? " It will be possible to <font color=#ffff00>" . $status2 . "</font> it in " . $avilmin . "</font> minutes and <font color=#ffff00>" . $avilsec . "</font> seconds. " : "";
return $state . $this -> bot -> make_blob("City History", $city);
}
Replace it with the following:
function city_blob()
{
$result = $this -> bot -> db -> select("SELECT time, action, player FROM org_city ORDER BY time DESC LIMIT 0, 12");
if (!$result)
{
return "No city events found in database.";
}
else
{
$city = "<font color=CCInfoHeadline>::::: Recent City Attacks :::::</font><font color=CCInfoText>\n\n";
foreach ($result as $res)
{
$city .= "<font color=CCInfoHeader>Time:</font> <font color=CCCCHeaderColor>" . gmdate("M j, Y, G:i", $res[0]) . " GMT</font>\n";
if ($res[1] == "attack")
$city .= "City was attacked.\n";
else if ($res[1] == "on")
$city .= $res[2] . " turned cloaking <font color=CCCCTextColor>on</font>.\n";
else if ($res[1] == "off")
$city .= $res[2] . " turned cloaking <font color=CCCCTextColor>off</font>.\n";
else if ($res[1] == "hq")
$city .= $res[2] . " destroyed the <font color=CCCCTextColor>HQ</font>.\n";
else if ($res[1] == "house")
$city .= $res[2] . " destroyed a <font color=CCCCTextColor>building</font>.\n";
$city .= "\n";
}
$result = $this -> bot -> db -> select("SELECT time, action FROM org_city WHERE action = 'on' OR action = 'off' ORDER BY time DESC LIMIT 0, 1");
$avilmin = date("i",3600-(time()-$result[0][0]));
$avilsec = date("s",3600-(time()-$result[0][0]));
if ($result[0][1] == "on")
{
$status = "enable";
$status2 = "disable";
}
else
{
$status = "disable";
$status2 = "enable";
}
if($result[0][0] > (time() - 3600))
$ttchange = true;
else
$ttchange = false;
$state = "The cloaking device is <font color=#ffff00>" . $status . "d</font>.";
$state .= $ttchange ? "" : " It is now possible to <font color=#ffff00>" . $status2 . "</font> it. ";
$state .= $ttchange ? " It will be possible to <font color=#ffff00>" . $status2 . "</font> it in " . $avilmin . "</font> minutes and <font color=#ffff00>" . $avilsec . "</font> seconds. " : "";
return $state . $this -> bot -> make_blob("City History", $city);
}
}
-
Made that change and it really hates it. Now whenever anyone talks at all in org chat the bot crashes.
Maybe if I give you full setup I have it will help...
Runing Windows Server 2k3, IIS 6, and now running php 4.4.2. Using Bebot 0.2.4 (also put the BeBot-php_v5.1.4 stuff in). I was using php5 but due to issues came back to php4 to see if it made a difference, but hasn't at all.
Mostly everything works... few issues.
Current issues:
The !city and !cloak commands as stated above.
The !victory command is always blank but I haven't had much of a chance to look at that one yet since I've been working on this.
Anything I could be missing here?
-
Did you set $guild_name = ""; in conf/bot.conf ?
-
Which version of the AlienAttack_GUILD.php are you using? Is it the one packaged with 0.2.4 or from another version?
If you are running AOChat.php v1.19 with the AOKEX extension try this version here:
http://bebot.link/index.php/topic,210.msg2244.html#msg2244
-
Its the one that came packaged in it. I screwed with it a little bit and got it working without crashing the bot now but its got one other flaw now. I ran a raid and it worked flawlessly for that. After I re-enabled cloak I did the !city and !cloak commands without crashing and it brought up a link for city history. The history was blank and it said the cloak was disabled even though it was enabled.
[B.E.E.R. (TnA)] Beerraid: Dabsma turned the cloaking device in our city back on!
[B.E.E.R. (TnA)] Dabsma: -city
[B.E.E.R. (TnA)] Beerraid: The cloaking device is disabled. It is now possible to enable it. City History
[B.E.E.R. (TnA)] Dabsma: -cloak
[B.E.E.R. (TnA)] Beerraid: The cloaking device is disabled. It is now possible to enable it. City History
If I delete the table I built it dosen't crash but it also dosen't work as I stated above (looking at the php module it should have auto-created it if it didn't exist) but it gives a bunch (and I do mean bunch) of mysql errors. If I have a table in there that I manually create using the colums and types listed in the module it still crashes. Any other ideas?
Edit:
I manually added info into the table to see if that would work and now I just get:
Fatal error: Cannot use string offset as array in C:\BeBot\BeBot_v0.2.4\BeBot_v0.2.4\modules\AlienAttack_GUILD.php on line 118
Line 118 is:
$city .= $res[2] . " destroyed the <font color=CCCCTextColor>HQ</font>.\n";
Ok, I manually added an entry in the table and it seems to work (displays the data and everything). I'll have to test it tomorrow if it actually adds data in when I trigger a raid now. Thanks for your help so far guys. Its much appreciated!!
-
Your really not giving me much to work with here.
First of all, the code changes should in no possible way crash the bot on any given text since its a specific function which is only called on the commands city and cloak.
Second, "It really hates it" and "Throws a bunch of errors" gives me no information about what the problem is, which means i have no way of helping you, because you just told me there was a problem, not what the problem was.
Im particularly interested in knowing what errors your getting when the script is trying to crate the database table if it doesnt exsist, as this seems to be the underlying problem.
If this table isnt created correctly with all the correct fields, the module will never work as intended.
The Victory command sounds like it could be suffering from the same problem, database table missing or not containing the expected fields.
-
Sorry I wasn't more specific. I said a lot because there were like 10 messages and trying to write them all down would have been a pain when I knew that the other way there was only 1 real message (and an extra for no data in the table). I have now completely resolved the issue with data in the table. For some reason it dosen't like split line sql entries so putting that all on one line fixed most of the issue.
In the tower attack module it was a similar thing. Split line sql it didn't like. Also ran into one other issue on that module... it was listing the winning orgs name as the losers faction so had to make a minor change.
Changed
$this -> bot -> db -> query("INSERT INTO tower_result (time, win_guild, win_side, lose_guild, lose_side) VALUES ('" . time() . "', '" . $info[3] . "', '" . $info[2] . "', '" . $info[5] . "', '" . $info[3] . "')");
To
$this -> bot -> db -> query("INSERT INTO tower_result (time, win_guild, win_side, lose_guild, lose_side) VALUES ('" . time() . "', '" . $info[3] . "', '" . $info[2] . "', '" . $info[5] . "', '" . $info[4] . "')");
Here is how it did look:
May 22, 2006, 12:36 GMT
Winner: Neutralizers (Neutral)
Looser: New Order (Neutralizers)
And now:
May 22, 2006, 15:06 GMT
Winner: Orbitek (Omni)
Looser: ~~ Athalantes ~~ (Clan)
Not sure if its just my sql install that hates those split lines or what, but that seemed to pretty much fix it.
-
Copy and Paste is your best friend :)
Split SQL lines shouldnt really be an issue unless they are split in bad places. But the stock files that are shipped with BeBot should not have any splitting issues like that.
As for the Victory logging, i could have sworn i already fixed that, but it seems it never made it into SVN. Thanx for pointing it out.
-
I tried copy/paste but over a vnc connection it didn't like copying out of a command window (dead monitor on that computer).
Everything is working great now that I've made those changes. Thanks again for all the help guys :)