L* R*
HOME FORUM DOWNLOADS
Content
  Links
     Browse SVN
     SVN Commit log
     Documentation (Wiki)
  Developers
     Taskmanager
User
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 02, 2008, 03:08:24 PM

Login with username, password and session length
Search



Advanced search
Support GoPHP5.org
BeBot - An Anarchy Online/Age Of Conan chat automaton > Forum > Modules > Official modules > Topic: modified AlienAttack_GUILD
Pages: [1] 2   Go Down
« previous next »
Print
Author Topic: modified AlienAttack_GUILD  (Read 2388 times)
0 Members and 1 Guest are viewing this topic.
Akarah
BeBot Contributor
Rookie
*******
Offline Offline

Posts: 72


WWW
modified AlienAttack_GUILD
« on: November 28, 2005, 02:57:24 AM »

since i hate doing math so much, i added the "time to change" in the city_blob function.

i also "aliased" !cloak to !city by simply adding the 3 commands array entries.

but mostly, the countdown stuff. it's not well done at all, just expanded what was already there really. i could probably word it differently and get away with only one conditional in the $state assignment.

anyhow, here's my change..

in function city_blob, find the line:
Code:

      $result = $this -> bot -> db -> select("SELECT time, action FROM org_city WHERE action = 'on' OR action = 'off' ORDER BY time DESC LIMIT 0, 1");


add these 2 lines after it:
Code:

      $avilmin = date("i",3600-(time()-$result[0][0]));
      $avilsec = date("s",3600-(time()-$result[0][0]));


and change the following if-else to this:
Code:

      if ($result[0][1] == "on")
      {
        $state = "The cloaking device is <font color=#ffff00>enabled</font>." . " It is currently <font color=#ffff00>" . (($result[0][0] > (time() - 3600)) ? "not " : "") . "possible</font> to disable it. " . (($result[0][0] > (time() - 3600)) ? "Change possible in <font color=#ffff00>" . $avilmin . "</font> minutes and <font color=#ffff00>" . $avilsec . "</font> seconds. " : "");
      }
      else
      {
        $state = "The cloaking device is <font color=#ffff00>disabled</font>. It is currently <font color=#ffff00>" . (($result[0][0] > (time() - 3600)) ? "not " : "") . "possible</font> to enable it. " . (($result[0][0] > (time() - 3600)) ? "Change possible in <font color=#ffff00>" . $avilmin . "</font> minutes and <font color=#ffff00>" . $avilsec . "</font> seconds. " : "");
      }
      return $state . $this -> bot -> make_blob("City History", $city);
    }


yup pretty unreadable.. and yup pretty ugly that i do 2 conditionals per assignment, but it works (and i took out the 60*60 calculation too.. unnecessary Wink )

if someone wants to rewrite it and incorporate the changes into svn, then hooray - i couldn't think of a coherent way of wording the message without making more work for myself Wink

cheers!

/Aka
Logged
Xenixa
BeBot Contributor
Expert
*******
Offline Offline

Posts: 307



modified AlienAttack_GUILD
« Reply #1 on: November 28, 2005, 03:24:47 AM »

Aliased !cloak? The command was always !city ... at least in the copy I have that came with the bot.

Cool idea about Displaying time left before cloak can be raised/lowered however. Smiley
Logged

<<< Hack's in Zend Studio

All my Custom Bebot files may be Found Here <-clicky
Akarah
BeBot Contributor
Rookie
*******
Offline Offline

Posts: 72


WWW
modified AlienAttack_GUILD
« Reply #2 on: November 28, 2005, 04:21:02 AM »

yeah, it is !city but i made it also be !cloak, because thats what my guild was used to before and i wanted to keep the transition as minor as possible (aside from the numerous amazingly good things that changed and are better now Wink )
Logged
Khalem
BeBot Founder
Administrator
Grandmaster
********
Offline Offline

Gender: Male
Posts: 670



WWW
modified AlienAttack_GUILD
« Reply #3 on: November 28, 2005, 02:04:26 PM »

I changed the actual code to:
Code:

      $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);


On a side note, i prefer readability to efficiency in this case, hence the two $ttchange checks instead of doing one. Although it could probably be split over two lines as one.
Logged

BeBot Founder and Fixer Kingpin
Madman coder and destroyer of good code
Akarah
BeBot Contributor
Rookie
*******
Offline Offline

Posts: 72


WWW
modified AlienAttack_GUILD
« Reply #4 on: November 28, 2005, 02:15:41 PM »

see.. i knew someone could make it look better Smiley

good one! thanks! updating mine now Smiley
Logged
Khalem
BeBot Founder
Administrator
Grandmaster
********
Offline Offline

Gender: Male
Posts: 670



WWW
modified AlienAttack_GUILD
« Reply #5 on: November 28, 2005, 06:02:41 PM »

Whoops. Updated update with an update.

Been doing too much Ruby as of late and forgot curly braces.
Also made a small cosmetical fix.
Logged

BeBot Founder and Fixer Kingpin
Madman coder and destroyer of good code
Xenixa
BeBot Contributor
Expert
*******
Offline Offline

Posts: 307



modified AlienAttack_GUILD
« Reply #6 on: November 28, 2005, 06:16:34 PM »

Heheh I was gunna post something about the curly braces.
Zend Studio tosses ya Syntax errors so when I paste stuff like that I just automatically add whats missing. *shrug*

Looks good though. Made quite a few org members happy that they no long have to watch the clock or look for the bot to say it can be switched.
Logged

<<< Hack's in Zend Studio

All my Custom Bebot files may be Found Here <-clicky
Akarah
BeBot Contributor
Rookie
*******
Offline Offline

Posts: 72


WWW
modified AlienAttack_GUILD
« Reply #7 on: November 28, 2005, 08:15:44 PM »

yeah coming from primarily a perl background, i habitually use curly brackets in php even when it is apparently not necessary (like when an if (condition) only has one action) like:

Code:

if ($stuff) do_stuff();


i'd write like this:
Code:

if ($stuff) { do_stuff(); }


or even more likely:
Code:

if ($stuff)
{
  do_stuff();
}


hehe
Logged
Khalem
BeBot Founder
Administrator
Grandmaster
********
Offline Offline

Gender: Male
Posts: 670



WWW
modified AlienAttack_GUILD
« Reply #8 on: November 28, 2005, 08:31:38 PM »

Same actually Akarah, aside from i come from C, not Perl.

I favour overuse of brackets even on one line if's for the sake of readability (and less typing later if more needs to be added to the conditional check)
Logged

BeBot Founder and Fixer Kingpin
Madman coder and destroyer of good code
mookie
Rookie
**
Offline Offline

Posts: 27


modified AlienAttack_GUILD
« Reply #9 on: November 29, 2005, 05:34:58 AM »

Have a console error when using this patch. I am using the 1171 aochat, and the suggested modified Bot.php with PHP 4.41.

Here is the error in the console:

Code:

[2005-11-29 09:54:55]   [TELL]  [INC]   Darkztrader: !city

Warning: Invalid argument supplied for foreach() in H:\bebot\modules\
_GUILD.php on line 100

Warning: date(): Windows does not support dates prior to midnight (00
nuary 1, 1970 in H:\bebot\modules\AlienAttack_GUILD.php on line 120

Warning: date(): Windows does not support dates prior to midnight (00
nuary 1, 1970 in H:\bebot\modules\AlienAttack_GUILD.php on line 121



Here is the code for error in line 100
Code:

Line 95]     function city_blob()
Line 96]     {
Line 97]     $city = "<font color=CCInfoHeadline>::::: Recent City activity :::::</font><font color=CCInfoText>\n\n";
Line 98]
Line 99]     $result = $this -> bot -> db -> select("SELECT time, action, player FROM org_city ORDER BY time DESC LIMIT 0, 12");
Line 100]   foreach ($result as $res)
Line 101]   {
Line 102]   $city .= "<font color=CCInfoHeader>Time:</font> <font color=CCCCHeaderColor>" . gmdate("M j, Y, G:i", $res[0]) . " GMT</font>\n";


Here is the lines for 120 and 121:
Code:

Line 120]     $avilmin = date("i",3600-(time()-$result[0][0]));
Line 121]     $avilsec = date("s",3600-(time()-$result[0][0]));


I checked placement of the { }'s and tried changing date variables. This error happens with tell, pg and Gc.
Logged
Akarah
BeBot Contributor
Rookie
*******
Offline Offline

Posts: 72


WWW
modified AlienAttack_GUILD
« Reply #10 on: November 29, 2005, 06:08:35 AM »

has your bot ever tracked a city controller change enable or disable? i can see if it were getting a null value for that it would be formatting based on 0 or something..

it appears $result isn't getting set right, due to something missing from the database..
Logged
Xenixa
BeBot Contributor
Expert
*******
Offline Offline

Posts: 307



modified AlienAttack_GUILD
« Reply #11 on: November 29, 2005, 06:16:17 AM »

Easy enough to explain Mookie .. no Data in org_city Table. Smiley

Run this line as a Script in your fav MySQL Query tool:
Code:
INSERT INTO org_city (id, time, action, player) VALUES (1, 1133256000, 'on', 'Initialized');


EDIT:
Or you can add this Line just under the Query that Creates the Table:
Code:
$db->query("INSERT INTO org_city (id, time, action, player) VALUES (1, " . time() . ", 'on', 'Initialized')");

Just don't forget to Remove or Remark that line out after you run it the first time.
Logged

<<< Hack's in Zend Studio

All my Custom Bebot files may be Found Here <-clicky
mookie
Rookie
**
Offline Offline

Posts: 27


modified AlienAttack_GUILD
« Reply #12 on: November 29, 2005, 10:07:42 AM »

Wow .. bingo

Well I drop the table and inserted that line Xenixa and its working. Must have had corrupt data in the table. Bot kept saying the Unknown problem statement for raids as well, but not anymore Smiley

thanks !!
Logged
Xenixa
BeBot Contributor
Expert
*******
Offline Offline

Posts: 307



Re: modified AlienAttack_GUILD
« Reply #13 on: April 24, 2006, 10:30:03 PM »

Updated:
AlienAttack_GUILD.php

This version is for Bebot versions 0.3.x and higher using PHP5 and AOChat v1.19
Includes all changes in this thread plus adds additional awareness to other city message types.

Enjoy

Edit: Fixed a typo, no biggie, just annoying.
« Last Edit: May 22, 2006, 02:17:13 AM by Xenixa » Logged

<<< Hack's in Zend Studio

All my Custom Bebot files may be Found Here <-clicky
tonyuh
Rookie
**
Offline Offline

Posts: 48


Re: modified AlienAttack_GUILD
« Reply #14 on: April 16, 2007, 07:46:44 PM »

Sorry for necro.. but I don't know why the cron job on this module is not working for me. The text doesn't show up after one hour of turning the cloaking on/off. Also i think theres something missing in this:

else if ($this -> type != "repeat")
    {
        $this -> bot -> send_gc("Cloaking device was disabled one hour ago. It is now possible to enable it again.");
   $this -> time = time() + (60 * 60);

Shouldn't there be $this -> type = "repeat"; at the end there?

Thanks,
Tony
Logged
Pages: [1] 2   Go Up
Print
BeBot - An Anarchy Online/Age Of Conan chat automaton > Forum > Modules > Official modules > Topic: modified AlienAttack_GUILD
« previous next »
 
Jump to:  

Recent
Log playtime from buddys ...
by IKShadow
[Today at 06:48:12 AM]

[request] Raid timers
by Elesar1
[December 01, 2008, 04:41:09 PM]

Shared DB online list
by Temar
[December 01, 2008, 01:55:47 AM]

relay colors
by Temar
[December 01, 2008, 01:54:56 AM]

BeBot v0.6.0 released
by Alreadythere
[November 30, 2008, 05:32:00 PM]

Change to Bid.php
by Temar
[November 30, 2008, 11:41:44 AM]

OnlineOrg
by Jiheld
[November 29, 2008, 12:44:27 PM]

Silly Newbie Question.
by Temar
[November 29, 2008, 12:00:02 PM]

massive_pvp_time_table 1
by gerborg
[November 29, 2008, 06:55:35 AM]

Bot not see Guild Chat
by Delvar
[November 28, 2008, 08:30:34 AM]
Stats
Members
Total Members: 1244
Latest: Armonkens
Stats
Total Posts: 11145
Total Topics: 1505
Online Today: 25
Online Ever: 168
(July 01, 2007, 09:30:02 PM)
Users Online
Users: 3
Guests: 16
Total: 19
Stealth
Kentarii
Ifris

Powered by SMF 1.1.7 | SMF © 2006-2008, Simple Machines LLC
TinyPortal v0.9.8 © Bloc | NewDef design by Bloc
Page created in 0.505 seconds with 29 queries. (Pretty URLs adds 0.034s, 4q)
Loading...