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

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

Author Topic: modified AlienAttack_GUILD  (Read 13269 times)

0 Members and 1 Guest are viewing this topic.

Offline Akarah

  • Contributor
  • *******
  • Posts: 72
  • Karma: +0/-0
    • http://synergyfactor.net/
modified AlienAttack_GUILD
« on: November 28, 2005, 08: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: [Select]

      $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: [Select]

      $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: [Select]

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

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

cheers!

/Aka

Offline Xenixa

  • Contributor
  • *******
  • Posts: 307
  • Karma: +0/-0
modified AlienAttack_GUILD
« Reply #1 on: November 28, 2005, 09: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. :)
<<< Hack's in Zend Studio

All my Custom Bebot files may be Found Here <-clicky

Offline Akarah

  • Contributor
  • *******
  • Posts: 72
  • Karma: +0/-0
    • http://synergyfactor.net/
modified AlienAttack_GUILD
« Reply #2 on: November 28, 2005, 10: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 ;) )

Offline Khalem

  • BeBot Founder
  • Administrator
  • ********
  • Posts: 1169
  • Karma: +0/-0
    • http://www.ancarim.com
modified AlienAttack_GUILD
« Reply #3 on: November 28, 2005, 08:04:26 pm »
I changed the actual code to:
Code: [Select]

      $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.
BeBot Founder and Fixer Kingpin

Offline Akarah

  • Contributor
  • *******
  • Posts: 72
  • Karma: +0/-0
    • http://synergyfactor.net/
modified AlienAttack_GUILD
« Reply #4 on: November 28, 2005, 08:15:41 pm »
see.. i knew someone could make it look better :)

good one! thanks! updating mine now :)

Offline Khalem

  • BeBot Founder
  • Administrator
  • ********
  • Posts: 1169
  • Karma: +0/-0
    • http://www.ancarim.com
modified AlienAttack_GUILD
« Reply #5 on: November 29, 2005, 12:02:41 am »
Whoops. Updated update with an update.

Been doing too much Ruby as of late and forgot curly braces.
Also made a small cosmetical fix.
BeBot Founder and Fixer Kingpin

Offline Xenixa

  • Contributor
  • *******
  • Posts: 307
  • Karma: +0/-0
modified AlienAttack_GUILD
« Reply #6 on: November 29, 2005, 12:16:34 am »
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.
<<< Hack's in Zend Studio

All my Custom Bebot files may be Found Here <-clicky

Offline Akarah

  • Contributor
  • *******
  • Posts: 72
  • Karma: +0/-0
    • http://synergyfactor.net/
modified AlienAttack_GUILD
« Reply #7 on: November 29, 2005, 02:15:44 am »
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: [Select]

if ($stuff) do_stuff();


i'd write like this:
Code: [Select]

if ($stuff) { do_stuff(); }


or even more likely:
Code: [Select]

if ($stuff)
{
  do_stuff();
}


hehe

Offline Khalem

  • BeBot Founder
  • Administrator
  • ********
  • Posts: 1169
  • Karma: +0/-0
    • http://www.ancarim.com
modified AlienAttack_GUILD
« Reply #8 on: November 29, 2005, 02:31:38 am »
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)
BeBot Founder and Fixer Kingpin

Offline mookie

  • BeBot User
  • **
  • Posts: 27
  • Karma: +0/-0
modified AlienAttack_GUILD
« Reply #9 on: November 29, 2005, 11: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: [Select]

[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: [Select]

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: [Select]

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.

Offline Akarah

  • Contributor
  • *******
  • Posts: 72
  • Karma: +0/-0
    • http://synergyfactor.net/
modified AlienAttack_GUILD
« Reply #10 on: November 29, 2005, 12:08:35 pm »
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..

Offline Xenixa

  • Contributor
  • *******
  • Posts: 307
  • Karma: +0/-0
modified AlienAttack_GUILD
« Reply #11 on: November 29, 2005, 12:16:17 pm »
Easy enough to explain Mookie .. no Data in org_city Table. :)

Run this line as a Script in your fav MySQL Query tool:
Code: [Select]
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: [Select]
$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.
<<< Hack's in Zend Studio

All my Custom Bebot files may be Found Here <-clicky

Offline mookie

  • BeBot User
  • **
  • Posts: 27
  • Karma: +0/-0
modified AlienAttack_GUILD
« Reply #12 on: November 29, 2005, 04:07:42 pm »
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 :)

thanks !!

Offline Xenixa

  • Contributor
  • *******
  • Posts: 307
  • Karma: +0/-0
Re: modified AlienAttack_GUILD
« Reply #13 on: April 25, 2006, 05:30:03 am »
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, 09:17:13 am by Xenixa »
<<< Hack's in Zend Studio

All my Custom Bebot files may be Found Here <-clicky

Offline tonyuh

  • BeBot User
  • **
  • Posts: 48
  • Karma: +0/-0
Re: modified AlienAttack_GUILD
« Reply #14 on: April 17, 2007, 02:46:44 am »
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

 

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


0.8.x updates for AoC by bitnykk
[January 30, 2024, 11:16:08 pm]


0.8.x updates for AO by bitnykk
[January 30, 2024, 11:15:37 pm]


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


Bebot and Rasberry by bitnykk
[November 29, 2023, 11:04:14 pm]

* Who's Online
  • Dot Guests: 495
  • 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