Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once(WCF_DIR.'lib/system/event/EventListener.class.php');
- require_once(WCF_DIR.'lib/data/samp/SampQueryAPI.php');
- /**
- * @author Kevin Härtling
- * @copyright 2012
- * @package de.canna-design.sampviewer
- */
- class SAMPOnlineViewer implements EventListener {
- public function execute($eventObj, $className, $eventName) {
- $s = new SampQueryAPI(IPADRESSE, PORT);
- if($s->isOnline()) {
- $i = $s->getInfo();
- $p = $s->getDetailedPlayers();
- //var_dump($o);
- //exit;
- WCF::getTPL()->assign(array('host' => $i['hostname'], 'gm' => $i['gamemode'], 'players' => $i['players'], 'maxplayers' => $i['maxplayers']));
- $nicks = array();
- foreach($p as $key => $value) {
- $nicks[$key] = $value['nickname'];
- }
- WCF::getTPL()->assign('nicks', $nicks);
- }
- WCF::getTPL()->append('additionalBoxes', WCF::getTPL()->fetch('viewer'));
- }
- }
- ?>
- // Template - viewer.tpl
- {if $host|isset}
- <div class="container-1">
- <div class="containerIcon">
- <img src="{icon}sampM.png{/icon}" alt="SA:MP Viewer by Canna" />
- </div>
- <div class="containerContent">
- <b>SA:MP Server Viewer:</b>
- <p class="smallFont">{$host} - Gamemode: {$gm} - Players: {$players}/{$maxplayers} - Status: <font color="#008000"><b>Online</b></font> - {IPADRESSE}:{PORT}</p>
- <p class="smallFont">{implode from=$nicks item=nick}{if $nick|isset}{$nick}{else}<i>Kein Spieler auf dem Server online.</i>{/if}{/implode}</p>
- </div>
- </div>
- {else}
- <div class="container-1">
- <div class="containerIcon">
- <img src="{icon}sampM.png{/icon}" alt="SA:MP Viewer by Canna" />
- </div>
- <div class="containerContent">
- <b>SA:MP Server Viewer:</b>
- <p class="smallFont"><font color="#B70000">Der Gameserver ist <b>offline</b>!</font></p>
- </div>
- </div>
- {/if}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement