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: Alien Playfield Module - Keep track of alien PF  (Read 32279 times)

0 Members and 1 Guest are viewing this topic.

Offline Wanuarmi

  • Contributor
  • *******
  • Posts: 121
  • Karma: +0/-0
Alien Playfield Module - Keep track of alien PF
« Reply #45 on: December 02, 2005, 01:50:16 am »
im using debian linux... not sure about the timezone set in the box, gonna mess with that later. I always try to match the time with campalot, using /campalot !apf, maybe Glara's bot isnt always synchronized with her timestamp.

Offline Wanuarmi

  • Contributor
  • *******
  • Posts: 121
  • Karma: +0/-0
Alien Playfield Module - Keep track of alien PF
« Reply #46 on: December 07, 2005, 08:40:27 am »
Quote from: "Xenixa"
Thats wierd I had to put intval() on $result[1] to get it to work at all. *shrug*

Removing it totaly f*** up my bot.


I think I finally sort this out... shouldnt it be $result[0][1]?

Offline Wanuarmi

  • Contributor
  • *******
  • Posts: 121
  • Karma: +0/-0
Re: Alien Playfield Module - Keep track of alien PF
« Reply #47 on: December 19, 2005, 10:16:25 pm »
updated this a bit, added 2 hours alert, changed alert color to green (looks better on raidbots) and made it automatically update cache on midnight

if you want to change the alert color just change the $this -> alert_color = "#00F700"; variable


modules/Playfield.php
Code: [Select]
<?php
 
/*
  * Playfield Module for BE Bot <http://bebot.fieses.net>
  * Module coded by Craized <http://www.craized.net>
  * Originally modified by Derroylo
  *
  * Modified to use Time Stamp From Glarawyn's site by Xenixa (RK1)
  * Now uses settings table
  */

  /*
  Add a "_" at the beginning of the file (_Playfield.php) if you do not want it to be loaded.
  */

// Commented Line below is intedended to set an initial value and was used for testing.
//$db -> query("REPLACE INTO settings (setting, value) VALUES ('apf_timer', '1130355492')");
               

$playfield = new Playfield($bot);

$commands["tell"]["apf"] = &$playfield;
$commands["tell"]["setpf"] = &$playfield;
$commands["pgmsg"]["apf"] = &$playfield;
$commands["gc"]["apf"] = &$playfield;
$cron["2sec"][] = &$playfield;

/*
The Class itself...
*/
class Playfield {
    var 
$bot;
var $alert_color;

    
/*
    Constructor:
    Hands over a referance to the "Bot" class.
    */
    
function Playfield (&$bot) {
        
$this -> bot = &$bot;
        if(
$this -> bot -> highlight_color) {
            
$this -> highlight "<font color=" $this -> bot -> highlight_color ">";
            } else {
            
$this -> highlight "<font color=#FFFFFF>";
        }
$this -> alert_color "#00F700";
        
$this -> get_timer();
    }

    
/*
    This gets called on a tell with the command
    */
    
function tell($name$msg
    {
        if (
preg_match("/^" $this -> bot -> commpre "apf$/i"$msg))
        { 
            
$this -> time();
            
$this -> bot -> send_tell($name$this -> msg);
        }
        elseif (
preg_match("/^" $this -> bot -> commpre "setpf$/i"$msg))
        { 
            
$this -> set_timer($name$msg);
        }
    }

 
/*
    This gets called on a msg in the privgroup with the command
    */
    
function pgmsg($name$msg) {
        
$this -> time();
        
$this -> bot -> send_pgroup($this -> msg);
    }

    
/*
    This gets called on a msg in the guildchat with the command
    */
    
function gc($name$msg) {
        
$this -> time();
        
$this -> bot -> send_gc($this -> msg);
        
$this -> bot -> log(GROUPSEND$this -> msg);
    }

    
/*
    This gets called on cron
    */
    
function cron() {
        
$highlight $this -> highlight;
$acolor $this -> alert_color;
        
$this -> time();
        if(
floor($this -> timeleft) <= 3600 && floor($this -> timeleft) >= 3599) {
            
$this -> bot -> send_pgroup("<font color=$acolor>Alien playfield gates opening in$highlight 1</font> hour!");
            
$this -> bot -> send_gc("<font color=$acolor>Alien playfield gates opening in$highlight 1</font> hour!");
        }
else if( $secleft <= 7200 && $secleft >= 7199 ) {
            
$this -> bot -> send_pgroup("<font color=$acolor>Alien playfield gates opening in$highlight 2</font> hours!");
            
$this -> bot -> send_gc("<font color=$acolor>Alien playfield gates opening in$highlight 2</font> hours!");
}
        else if(
floor($this -> timeleft) <= 1800 && floor($this -> timeleft) >= 1799) {
            
$this -> bot -> send_pgroup("<font color=$acolor>Alien playfield gates opening in$highlight 30</font> minutes!");
            
$this -> bot -> send_gc("<font color=$acolor>Alien playfield gates opening in$highlight 30</font> minutes!");
        }
        else if(
floor($this -> timeleft) <= 900 && floor($this -> timeleft) >= 899) {
            
$this -> bot -> send_pgroup("<font color=$acolor>Alien playfield gates opening in$highlight 15</font> minutes!");
            
$this -> bot -> send_gc("<font color=$acolor>Alien playfield gates opening in$highlight 15</font> minutes!");
        }
        else if(
floor($this -> timeleft) <= 300 && floor($this -> timeleft) >= 299) {
            
$this -> bot -> send_pgroup("<font color=$acolor>Alien playfield gates opening in$highlight 5</font> minutes!");
            
$this -> bot -> send_gc("<font color=$acolor>Alien playfield gates opening in$highlight 5</font> minutes!");
        }
        else if(
$this -> timeleft <= 1) {
            
$this -> bot -> send_pgroup("<font color=$acolor>Unicorn Gatekeeper is opening Outzone gates$highlight now</font>!");
            
$this -> bot -> send_gc("<font color=$acolor>Unicorn Gatekeeper is opening Outzone gates$highlight now</font>!");
        }

// updates cache at midnight
$time date("G:i:s"gmmktime());
if ($time == "0:00:00" || $time == "0:00:01")
$this -> update_cache();
    }

    
/*
    Record Time Stamp to Settings Table
    */
    
function set_timer($name$msg) {
    
if ($this -> bot -> admin -> in_group($name"admin"))
    
{
        
$TimeStamp $this -> update_cache();
$this -> bot -> send_tell($name"Time Stamp is set to $TimeStamp");
    
}
    
else $this -> bot -> send_tell($name"You must be an admin to do this");
    }
    
    
/*
    Updates database cache
    */
function update_cache()
{
    
$TimeStamp $this -> bot -> get_site("http://zibby.isa-geek.net/apf.timestamp");
    
$TimeStamp trim($TimeStamp);

    
// Parse the APF Time Stamp from the Site above
    
$datetime explode(" "$TimeStamp);
    
$timetype strtoupper($datetime[0]);
    
$date explode("-"$datetime[1]);
    
$time explode(":"$datetime[2]);
    

    
// Uptime is needed to provide a timestamp without the [type] information in the timestamp file.
    
$settime gmmktime $time[0], $time[1], $time[2], $date[1], $date[2], $date[0] );
    
         
        
$this -> bot -> db -> query("UPDATE settings SET value = '".$settime."' WHERE setting = 'apf_timer'");
$this -> get_timer();
return $TimeStamp;
}


    
/*
    Retrieve Time Stamp from Settings Table
    */
    
function get_timer() {
    
$result $this -> bot -> db -> select("SELECT * FROM settings WHERE setting = 'apf_timer'");
        
$this -> stamp $result[0][1];
    }

    function 
time() {
        
$highlight $this -> highlight;
        
$time $this -> stamp;
        
$int 7*60*60+12*60+2.7;
        
$raids floor((mktime()-$time)/$int);
        
$this -> timeleft = ($time+$int+$int*$raids)-mktime();
        if(
$this -> timeleft >= 7*60*60 && $this -> timeleft <= 7*60*60+12*60+2.7) {
            
$timer floor($this -> timeleft -(7*60*60));
            } else {
            
$timer ceil($this -> timeleft);
        }
        
$h 0;
        while(
$timer >= 3600) {
            
$h++;
            
$timer-=3600;
        }
        
$m 0;
        while(
$timer >= 60) {
            
$m++;
            
$timer-=60;
        }
        
$s $timer;
        if(
$h == 0) {
            
$h '00';
        }
        if(
$m 10) {
            
$m '0' $m;
        }
        if(
$s 10) {
            
$s '0' $s;
        }
        if(
$this -> timeleft >= 7*60*60 && $this -> timeleft <= 7*60*60+12*60+2.7) {
            
$this -> msg "Outzone Gates are open, you have$highlight $m:$s </font>until gates close!";
            } else {
            
$this -> msg $highlight "$h:$m:$s </font>remaining until Alien Playfield opens.";
        }
    }
}
?>

Offline Aiiane

  • BeBot Rookie
  • *
  • Posts: 5
  • Karma: +0/-0
Re: Alien Playfield Module - Keep track of alien PF
« Reply #48 on: December 19, 2005, 11:01:23 pm »
hmm... wtb maximum vertical screen size for CODE blocks :) maybe make them scroll or such.

Offline Khalem

  • BeBot Founder
  • Administrator
  • ********
  • Posts: 1169
  • Karma: +0/-0
    • http://www.ancarim.com
Re: Alien Playfield Module - Keep track of alien PF
« Reply #49 on: December 20, 2005, 09:59:11 am »
hmm... wtb maximum vertical screen size for CODE blocks :) maybe make them scroll or such.

See http://bebot.link/index.php/topic,276.0.html and vote :)
BeBot Founder and Fixer Kingpin

Offline Glarawyn

  • BeBot Hero
  • ******
  • Posts: 521
  • Karma: +0/-0
Re: Alien Playfield Module - Keep track of alien PF
« Reply #50 on: December 20, 2005, 04:36:11 pm »
im using debian linux... not sure about the timezone set in the box, gonna mess with that later. I always try to match the time with campalot, using /campalot !apf, maybe Glara's bot isnt always synchronized with her timestamp.

Campalot should be in sync with my site most of the time. Campalot used to be running my VashBotPHP module, which grabbed the apf.timestamp file from my website every time someone did !apf. Currenty Campalot runs the current development version of my BeBot module. (Not the 0.9.5 module that I've released.) When I do make code updates I make sure it's in sync with my control bots (2 guildbots) and website. Campalot does cache the info for 4 hours before automatically updating from the site, but when I change the site I force the bot to recache the info.

I'm usually at work when FunCom resets the servers, so it usually takes awhile before my timer is in sync with the servers again. :)
« Last Edit: December 20, 2005, 04:42:29 pm by Glarawyn »

Offline craized

  • Contributor
  • *******
  • Posts: 165
  • Karma: +0/-0
    • http://www.craized.net
Re: Alien Playfield Module - Keep track of alien PF
« Reply #51 on: December 26, 2005, 04:20:20 am »
I didn't have much to do, and I deleted the bots I've been working on on accident and I'm not quite ready to go back and try to redo all my work, so I thought I would optimize this a little. The source I modified is from Wanuarmi's most recent post. I haven't gotten to test this either, so no gaurantees... So basically didn't do anything necessary.


<?php
/*
* Playfield Module for BE Bot <http://bebot.fieses.net>
* Module coded by Craized <http://www.craized.net>
* Originally modified by Derroylo
*
* Modified to use Time Stamp From Glarawyn's site by Xenixa (RK1)
* Now uses settings table
*/

/*
Add a '_' at the beginning of the file (_Playfield.php) if you do not want it to be loaded.
*/

// Commented Line below is intedended to set an initial value and was used for testing.
//$db -> query('REPLACE INTO settings (setting, value) VALUES ('apf_timer', '1130355492')');


$playfield = new Playfield($bot);

$commands['tell']['apf'] = &$playfield;
$commands['tell']['setpf'] = &$playfield;
$commands['pgmsg']['apf'] = &$playfield;
$commands['gc']['apf'] = &$playfield;
$cron['2sec'][] = &$playfield;

/*
The Class itself...
*/
class Playfield {
	
var 
$bot;
	
var 
$alert_color;

	
/*
	
Constructor:
	
Hands over a referance to the 'Bot' class.
	
*/
	
function 
Playfield (&$bot) {
	
	
$this -> bot = &$bot;
	
	
$this -> highlight = isset($this -> bot -> highlight_color) ? '<font color='.$this -> bot -> highlight_color.'>' '<font color=#FFFFFF>';
	
	
$this -> alert_color '#00F700';
	
	
$this -> get_timer();
	
}

	
/*
	
This gets called on a tell with the command
	
*/
	
function 
tell($name$msg) {
	
	
if (
preg_match('/^'.$this -> bot -> commpre.'apf$/i'$msg)) $c $this -> time();
	
	
elseif (
preg_match('/^'.$this -> bot -> commpre.'setpf$/i'$msg)) $c $this -> set_timer($name$msg);
	
	
$this -> bot -> send_tell($name$c);
	
}

	
/*
	
This gets called on a msg in the privgroup with the command
	
*/
	
function 
pgmsg($name$msg) {
	
	
if (
preg_match('/^'.$this -> bot -> commpre.'apf$/i'$msg)) $c $this -> time();
	
	
$this -> bot -> send_pgroup($c);
	
}

	
/*
	
This gets called on a msg in the guildchat with the command
	
*/
	
function 
gc($name$msg) {
	
	
if (
preg_match('/^'.$this -> bot -> commpre.'apf$/i'$msg)) $c $this -> time();
	
	
$this -> bot -> send_gc($c);
	
	
$this -> bot -> log('GROUP''SEND'$c);
	
}

	
/*
	
This gets called on cron
	
*/
	
function 
cron() {
	
	
$this -> time();
	
	
if(
floor($this -> timeleft) <= 3600 && floor($this -> timeleft) >= 3599) {
	
	
	
$this -> bot -> send_pgroup('<font color='.$this -> acolor.'>Alien playfield gates opening in '.$this -> highlight.'1</font> hour!');
	
	
	
$this -> bot -> send_gc('<font color='.$this -> acolor.'>Alien playfield gates opening in '.$this -> highlight.'1</font> hour!');
	
	
}
	
	
else if( 
$secleft <= 7200 && $secleft >= 7199 ) {
	
	
	
$this -> bot -> send_pgroup('<font color='.$this -> acolor.'>Alien playfield gates opening in '.$this -> highlight.'2</font> hours!');
	
	
	
$this -> bot -> send_gc('<font color='.$this -> acolor.'>Alien playfield gates opening in '.$this -> highlight.'2</font> hours!');
	
	
}
	
	
else if(
floor($this -> timeleft) <= 1800 && floor($this -> timeleft) >= 1799) {
	
	
	
$this -> bot -> send_pgroup('<font color='.$this -> acolor.'>Alien playfield gates opening in '.$this -> highlight.'30</font> minutes!');
	
	
	
$this -> bot -> send_gc('<font color='.$this -> acolor.'>Alien playfield gates opening in '.$this -> highlight.'30</font> minutes!');
	
	
}
	
	
else if(
floor($this -> timeleft) <= 900 && floor($this -> timeleft) >= 899) {
	
	
	
$this -> bot -> send_pgroup('<font color='.$this -> acolor.'>Alien playfield gates opening in '.$this -> highlight.'15</font> minutes!');
	
	
	
$this -> bot -> send_gc('<font color='.$this -> acolor.'>Alien playfield gates opening in '.$this -> highlight.'15</font> minutes!');
	
	
}
	
	
else if(
floor($this -> timeleft) <= 300 && floor($this -> timeleft) >= 299) {
	
	
	
$this -> bot -> send_pgroup('<font color='.$this -> acolor.'>Alien playfield gates opening in '.$this -> highlight.'5</font> minutes!');
	
	
	
$this -> bot -> send_gc('<font color='.$this -> acolor.'>Alien playfield gates opening in '.$this -> highlight.'5</font> minutes!');
	
	
}
	
	
else if(
$this -> timeleft <= 1) {
	
	
	
$this -> bot -> send_pgroup('<font color='.$this -> acolor.'>Unicorn Gatekeeper is opening Outzone gates '.$this -> highlight.'now</font>!');
	
	
	
$this -> bot -> send_gc('<font color='.$this -> acolor.'>Unicorn Gatekeeper is opening Outzone gates '.$this -> highlight.'now</font>!');
	
	
}

	
	
// updates cache at midnight
	
	
$time date('G:i:s'gmmktime());
	
	
if (
$time == '0:00:00' || $time == '0:00:01')
	
	
$this -> update_cache();
	
}

	
/*
	
Record Time Stamp to Settings Table
	
*/
	
function 
set_timer($name$msg) {
	
	
if (
$this -> bot -> admin -> in_group($name'admin')) {
	
	
	
$TimeStamp $this -> update_cache();
	
	
	
$c 'Time Stamp is set to '.$TimeStamp;
	
	
}
	
	
else 
$c 'You must be an admin to do this';
	
	
return 
$c;
	
}

	
/*
	
Updates database cache
	
*/
	
function 
update_cache()
	
{
	
	
$TimeStamp $this -> bot -> get_site('http://zibby.isa-geek.net/apf.timestamp');
	
	
$TimeStamp trim($TimeStamp);

	
	
// Parse the APF Time Stamp from the Site above
	
	
$datetime explode(' '$TimeStamp);
	
	
$timetype strtoupper($datetime['0']);
	
	
$date explode('-'$datetime['1']);
	
	
$time explode(':'$datetime['2']);

	
	
// Uptime is needed to provide a timestamp without the [type] information in the timestamp file.
	
	
$settime gmmktime $time['0'], $time['1'], $time['2'], $date['1'], $date['2'], $date['0'] );

	
	
$this -> bot -> db -> query('UPDATE settings SET value = "'.$settime.'" WHERE setting = "apf_timer"');
	
	
$this -> get_timer();
	
	
return 
$TimeStamp;
	
}


	
/*
	
Retrieve Time Stamp from Settings Table
	
*/
	
function 
get_timer() {
	
	
$result $this -> bot -> db -> select('SELECT * FROM settings WHERE setting = "apf_timer"');
	
	
$this -> stamp $result['0']['1'];
	
}

	
function 
time() {
	
	
$time $this -> stamp;
	
	
$int 7*60*60+12*60+2.7;
	
	
$raids floor((mktime()-$time)/$int);
	
	
$this -> timeleft = ($time+$int+$int*$raids)-mktime();
	
	
if(
$this -> timeleft >= 7*60*60 && $this -> timeleft <= 7*60*60+12*60+2.7$timer floor($this -> timeleft -(7*60*60));
	
	
else 
$timer ceil($this -> timeleft);
	
	
$h 0;
	
	
while(
$timer >= 3600) {
	
	
	
$h++;
	
	
	
$timer-=3600;
	
	
}
	
	
$m 0;
	
	
while(
$timer >= 60) {
	
	
	
$m++;
	
	
	
$timer-=60;
	
	
}
	
	
$s $timer;
	
	
if(
$h == 0$h '00';
	
	
if(
$m 10$m '0' $m;
	
	
if(
$s 10$s '0' $s;
	
	
if(
$this -> timeleft >= 7*60*60 && $this -> timeleft <= 7*60*60+12*60+2.7) {
	
	
	
$c 'Outzone Gates are open, you have '.$this -> highlight.$m.':'.$s.' </font>until gates close!';
	
	
} else 
$c $this -> highlight.$h.':'.$m.':'.$s.'</font> remaining until Alien Playfield opens.';
	
return 
$c;
	
}
}
?>
« Last Edit: December 26, 2005, 04:26:04 am by craized »
Trailin [213/14][ADVENTURER][RK2]
Bigburtha [216/17][NT][RK2][FROZEN]
Abeham [199/7][TRADER][RK2][FROZEN]


Offline Khalem

  • BeBot Founder
  • Administrator
  • ********
  • Posts: 1169
  • Karma: +0/-0
    • http://www.ancarim.com
Re: Alien Playfield Module - Keep track of alien PF
« Reply #52 on: December 26, 2005, 03:04:38 pm »
Recommend adding a random delay on the midnight updating just so that one doesn't end up with multiple bots hammering the server at the exact same time.
BeBot Founder and Fixer Kingpin

Offline craized

  • Contributor
  • *******
  • Posts: 165
  • Karma: +0/-0
    • http://www.craized.net
Re: Alien Playfield Module - Keep track of alien PF
« Reply #53 on: December 26, 2005, 09:52:25 pm »
I can add that in, but the way I'm thinking of seems kind of sloppy. If anyone else wants to do this, please do. If no one decides to, I'll get to it.
Trailin [213/14][ADVENTURER][RK2]
Bigburtha [216/17][NT][RK2][FROZEN]
Abeham [199/7][TRADER][RK2][FROZEN]


 

* 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: 197
  • 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