Info stránka pro MaNGOS in-game eventy

Z WoWResource Wiki
Přejít na: navigace, hledání

Emulátor MaNGOS podporuje od revize 4275 tzv. game event systém, který umožňuje vytvářet herní události, které trvají jenom určitý vymezený čas a spouští se s danou periodou. Mezi tyto naplánované akce patří např. události pořádané jednou pouze jednou ročně jako Hallow's End (halloween), Winter Veil (vánoce), aj. nebo akce, které probíhají celkem často jako přesun cirkusu Darkmoon Faire nebo Gurubashi Arena Booty Run.

Hráči na oficiálních serverech mají možnost zjistit, kdy tyto akce začnou na stránce Events calendar. Hráči na free serverech by jistě také ocenili podobnou stránku na serveru a k tomuto účelu můžete použít zde uvedený PHP skript. Samozřejmě si jej můžete libovolně upravit na míru svého webového serveru.

Skript načítá údaje z tabulky game_event z databáze mangos. Na základě údajů v tabulce počítá, které události momentálně běží a ty co neběží, tak kdy opět začnou. Vše je zobrazeno přehledně v tabulce včetně odkazů na oficiální stránky a na neoficiální wiki wowwiki.com. U řádku s připojením do databáze si musíte nastavit vaše jméno a heslo pro přístup k databázi.

Podporovaná verze: MaNGOSu 5578+, UDB 0.9.3+

<?php

$EventsLinks = array(
  1 => array('http://www.wowwiki.com/Midsummer_Fire_Festival', 'http://www.worldofwarcraft.com/info/events/midsummer/'),
  2 => array('http://www.wowwiki.com/Feast_of_Winter_Veil', 'http://www.worldofwarcraft.com/info/events/winterveil/'),
  3 => array('http://www.wowwiki.com/Darkmoon_Faire', 'http://www.worldofwarcraft.com/info/basics/factions/darkmoon/'),
  4 => array('http://www.wowwiki.com/Darkmoon_Faire', 'http://www.worldofwarcraft.com/info/basics/factions/darkmoon/'),
  5 => array('http://www.wowwiki.com/Darkmoon_Faire', 'http://www.worldofwarcraft.com/info/basics/factions/darkmoon/'),
  6 => array('http://www.wowwiki.com/New_Year', 'http://www.worldofwarcraft.com/info/events/newyears/'),
  7 => array('http://www.wowwiki.com/Lunar_Festival', 'http://www.worldofwarcraft.com/info/events/lunarnewyears/'),
  8 => array('http://www.wowwiki.com/Love_is_in_the_Air', 'http://www.worldofwarcraft.com/info/events/loveisintheair/'),
  9 => array('http://www.wowwiki.com/Noblegarden', 'http://www.worldofwarcraft.com/community/ingameevents.html#noblegarden'),
  10 => array('http://www.wowwiki.com/Children%27s_Week', 'http://www.worldofwarcraft.com/info/events/childrensweek/'),
  11 => array('http://www.wowwiki.com/Harvest_Festival', 'http://www.worldofwarcraft.com/info/events/harvestfestival/'),
  12 => array('http://www.wowwiki.com/Hallow%27s_End', 'http://www.worldofwarcraft.com/info/events/hallowsend/'),
  13 => array('http://www.wowwiki.com/Elemental_Invasions', 'http://www.worldofwarcraft.com/community/ingameevents.html#elemental'),
  14 => array('http://www.wowwiki.com/Stranglethorn_Fishing_Extravaganza', 'http://www.worldofwarcraft.com/info/events/fishing/'),
  15 => array('http://www.wowwiki.com/Stranglethorn_Fishing_Extravaganza', 'http://www.worldofwarcraft.com/info/events/fishing/'),
  16 => array('http://www.wowwiki.com/Gurubashi_Arena#Gurubashi_Arena_Booty_Run', 'http://www.worldofwarcraft.com/community/ingameevents.html#gurubashi'),
  17 => array('http://www.wowwiki.com/The_Scourge_Invasion', 'http://www.worldofwarcraft.com/info/events/scourgeinvasion/'),
  18 => array('', 'http://www.worldofwarcraft.com/community/ingameevents.html#calltoarms'),
  19 => array('', 'http://www.worldofwarcraft.com/community/ingameevents.html#calltoarms'),
  20 => array('', 'http://www.worldofwarcraft.com/community/ingameevents.html#calltoarms'),
  21 => array('', 'http://www.worldofwarcraft.com/community/ingameevents.html#calltoarms'),
  22 => array('http://www.wowwiki.com/Ahn%27Qiraj_War_Effort', 'http://www.worldofwarcraft.com/wareffort/servers.html'),
  23 => array('', ''),
  24 => array('', ''),
  25 => array('', 'http://www.worldofwarcraft.com/community/ingameevents.html#calltoarms'),
  26 => array('http://www.wowwiki.com/Brewfest', 'http://www.worldofwarcraft.com/info/events/brewfest/'),
  27 => array('', ''),
  28 => array('http://www.wowwiki.com/Noblegarden', 'http://www.worldofwarcraft.com/community/ingameevents.html#noblegarden'),
  29 => array('http://www.wowwiki.com/Edge_of_Madness', ''),
  30 => array('http://www.wowwiki.com/Edge_of_Madness', ''),
  31 => array('http://www.wowwiki.com/Edge_of_Madness', ''),
  32 => array('http://www.wowwiki.com/Edge_of_Madness', ''),
  33 => array('http://www.wowwiki.com/Arena_Tournament', ''),
  34 => array('http://www.wowwiki.com/L70ETC', ''),
);

function Events()
{
  global $Database, $EventsLinks;
  $Events = array('Running' => array(), 'Planned' => array());
  $Database->select_db('mangos');
  
  // Add already started events
  $DbResult = $Database->query('SELECT *, UNIX_TIMESTAMP(start_time) as start FROM game_event WHERE end_time > NOW() AND start_time < NOW()');
  while($Row = $DbResult->fetch_array())
  { 
    if(!array_key_exists($Row['entry'], $EventsLinks)) $EventsLinks[$Row['entry']] = array('', '');
    $Start = (floor((time() - $Row['start']) / ($Row['occurence'] * 60))) * $Row['occurence'] * 60 + $Row['start'];
    $End = $Start + $Row['length'] * 60;
    if((time() > $Start) and (time() < $End)) $EventState = 'Running';
    else 
    {
      $EventState = 'Planned'; 
      $Start += $Row['occurence'] * 60;
      $End += $Row['occurence'] * 60;
    }
    $Events[$EventState][$Row['start']] = array('StartTime' => $Start, 'EndTime' => $End, 'Title' => $Row['description'], 'WoWWiki' => $EventsLinks[$Row['entry']][0], 'Official' => $EventsLinks[$Row['entry']][1]);
  }

  // Add events not started so far
  $DbResult = $Database->query('SELECT *, UNIX_TIMESTAMP(start_time) as start FROM game_event WHERE start_time > NOW()');
  while($Row = $DbResult->fetch_array())
  { 
    if(!array_key_exists($Row['entry'], $EventsLinks)) $EventsLinks[$Row['entry']] = array('', '');
    $Events['Planned'][$Row['start']] = array('StartTime' => $Row['start'], 'EndTime' => ($Row['start'] + $Row['length'] * 60), 'Title' => $Row['description'], 'WoWWiki' => $EventsLinks[$Row['entry']][0], 'Official' => $EventsLinks[$Row['entry']][1]);
  }

  sort($Events['Running']);
  sort($Events['Planned']);

  return($Events);
}

function ShowEventList($Events)
{
  foreach($Events as $Event)
  {
    echo('<tr><td align="Left">'.$Event['Title'].'</td><td align="right">'.date('j.n.Y H:i', $Event['StartTime']).'</td><td align="right">'.date('j.n.Y H:i', $Event['EndTime']).'</td>');
    if($Event['WoWWiki'] != '') echo('<td><a href="'.$Event['WoWWiki'].'">wowwiki</a></td>'); 
else echo('<td> </td>');
    if($Event['Official'] != '') echo('<td><a href="'.$Event['Official'].'">worldofwarcraft</a></td>'); else echo('<td> </td>');
    echo('</tr>');
  }
}

$Database = new mysqli('localhost', 'root', 'password', 'mangos');

echo('<h3>Události ve hře:</h3><div align="center">');

$Events = Events();
echo('<table class="TableGuilda" border="1" cellpadding="3" cellspacing="0">');
echo('<tr><th>Název</th><th>Začátek</th><th>Konec</th><th>Informace</th><th>Informace</th></tr>');
echo('<tr><td colspan="5"><strong style="color: yellow;">Aktuálně běžící akce</strong></td></tr>');
ShowEventList($Events['Running']);
echo('<tr><td colspan="5"><strong style="color: yellow;">Plánované akce</strong></td></tr>');
ShowEventList($Events['Planned']);
echo('</table></div>');
?>


Externí odkazy