View Single Post
  #1  
Unread 04-04-2009, 03:51 PM
Drumstix42's Avatar
Drumstix42 Drumstix42 is offline
A Griffon
Featured
 
Join Date: Oct 2004
Server: Antonia Bayle
Posts: 3,287
Default Daily Double block - snippet (PHP)

This snippet of code will return the Daily Double, set to change at the specified time in the specified timezone.
I play on Blackburrow, so my server's timezone is west coast time, and my server's DD cycles at 3am.

I started out in Javascript, and decided that timezones were way too annoying to figure out. So, after a couple slight problems, I started over in PHP. I believe you'll need PHP5 support for the below code. Not positive.

Code:
// 19 missions in all
$mission_total = 19;
$missions = array(
	0	=>	array( zone => "Befallen: Necrotic Asylum", quest => "Destroy the Dread Exarch!" ),
	1	=>	array( zone => "Befallen: Cavern of the Afflicted", quest => "Abating the Evil" ),
	2	=>	array( zone => "Befallen: Halls of the Forsaken", quest	=> "Residual Haunting" ),
	3	=>	array( zone => "The Ruins of Guk: The Lower Corridors", quest => "Freeing the Froglok King" ),
	4	=>	array( zone => "The Ruins of Guk: Ykesha's Outer Stronghold", quest => "The Will of the Warlord" ),
	5	=>	array( zone => "The Ruins of Guk: Halls of the Fallen", quest => "The Will of the Warlord" ),
	6	=>	array( zone => "Miragul's Phylactery: The Anathema", quest => "From Within the Phylactery" ),
	7	=>	array( zone => "Miragul's Phylactery: The Crucible", quest => "The Trials of Miragul" ),
	8	=>	array( zone => "Miragul's Phylactery: Scion of Ice", quest => "Rattling the Pillars" ),
	9	=>	array( zone => "Evernight Abbey", quest => "The Ydalian Anlace" ),
	10	=>	array( zone => "Mistmyr Manor", quest => "Xanne's Carcanet" ),
	11	=>	array( zone => "Ravenscale Repository", quest => "Pillaging the Repository" ),
	12	=>	array( zone => "Deep Forge", quest => "Firing the Firelord" ),
	13	=>	array( zone => "Najena's Hollow Tower", quest => "Creamating the Creation" ),
	14	=>	array( zone => "Nu'roga", quest => "Teaching the Drogans a Lesson" ),
	15	=>	array( zone => "Veksar: The Sunken Theater", quest => "A Night in the Theatre" ),
	16	=>	array( zone => "Obelisk of Ahkzul", quest => "Nothing Short of Perfect Execution" ),
	17	=>	array( zone => "Anchor of Bazzul", quest => "Execution of Executor Zynos" ),
	18	=>	array( zone => "Emperor Atrebe's Laboratory: The Fabled City of Kor-sha", quest => "Removing the Heads" )
);

// edit these values below according to your server's timezone and DD cycle time
// see this page for timzones: http://us.php.net/timezones
date_default_timezone_set('America/Los_Angeles'); // set to westcoast time (Blackburrow's native timezone)
$start_time = strtotime("2009-03-24 03:00:00"); // seconds since January 1 1970 00:00:00 UTC (set to 3am -- when the DD cycles on Blackburrow)
$current_time = strtotime(date("Y-m-d h:i:s")); // seconds since January 1 1970 00:00:00 UTC (get local time in timezone set above)

$start_time = floor( $start_time / (24*60*60) ); // convert seconds to days, round down
$current_time = floor( $current_time / (24*60*60) ); // convert seconds to days, round down

$check_time = $current_time - $start_time; // find difference

$mission_zone = $missions[$check_time%$mission_total][zone]; // get the mission zone name (% is a modulus -- Modulus is the remainder after the division)
$mission_quest = $missions[$check_time%$mission_total][quest]; // get the mission quest name (% is a modulus -- Modulus is the remainder after the division)
$missions[$check_time%$mission_total][zone] -- returns the current misison's zone (ie: Deep Forge)
$missions[$check_time%$mission_total][quest] -- returns the current quest's name (ie: Firing the Firelord)

I like to have the quest name and then link it to a search on say eq2.wikia.com.
Enjoy.
__________________
"I'm afraid you're guilty of thought-crime. Don't bother getting the door, we'll let ourselves in..."
<Donate to DrumsUI> < [DrumsUI] Updater > < [DrumsUI] Full Interface> < Drumstix42 on Twitch.tv
>
Reply With Quote