Your phpBB Type: Standard phpBB3
MODs installed: Nope
Your knowledge: Ultra-Beginner in forum related things
Description and Message
Hiho, I try to adapt an easy block which must show a server status, number of online players, and max players. It's made for GF portal, but as it's dead, and your is fine, I try edit the block .
I followed the tutorial to create the new bloc, and I can succesfully add things inside.
Problem is I don't get how the hell it's supposed to work. And there is no tutorial post-block creation ;o.
I have understood :
- you must create an html to "format" datas you want to show, and a php located in portal/block/.
- {L_VARIABLE] is supposed to show variable on html, but it shows {VARIABLE} inboard. In the PHP, I have found variables were all down, in an array.
And that's all lol. I tried to check existing blocks (the leader one, I thought it was simple), but I just don't get it how the link between the PHP and the HTML is done without using the ACP (aka admin panel/mods).
If you can point me on existing tuto I didn't see, or even an existing case... I read 10-15 topics about custom block, but it doesn't talk of creation.
I post code of what I tried to make, if you need original code ask, I will post.
PHP side (near not edited) :
Code: Select all
<?php
/**
*
* Mod: Server Status Bloc
* Auteur: Psychokiller1888 (http://www.l2-semper-fidelis.com / http://www.team-masters-of-war.com)
* Notes: Oui, c'est completement gratuit, vous pouvez tout changer si vous le voulez, sans me demander quoi que ce soit
* mais s'il vous plait, soyez assez sympa et gardez au moin un trace de moi!
*
* Version: 1.1.0
* Date: 29.06.08
*
* Version History
* 1.1.0 Modif sur record en ligne
*
*/
if (!defined('IN_PHPBB') || !defined('IN_PORTAL'))
{
exit;
}
include ("./config_l2server.php");
$serverhost = $dbhost;
//Game server
$check = @fsockopen ($serverhost, 7777, $errno, $errstr, 1.0);
if (!$check)
{
$servers['game_server'] = "<img src=\"/images/offline.gif\" width=\"14\" height=\"14\" title=\"Offline\" alt=\"Offline\"> Offline";
}
else
{
$servers['game_server'] = "<img src=\"/images/online.gif\" width=\"14\" height=\"14\" title=\"Online\" alt=\"Online\"> Online";
$gs_online = TRUE;
}
@fclose($$check);
//Login Server
$check = @fsockopen ($serverhost, 2106, $errno, $errstr, 1.0);
if (!$check)
{
$servers['login_server'] = "<img src=\"/images/offline.gif\" width=\"14\" height=\"14\" title=\"Offline\" alt=\"Offline\"> Offline";
}
else
{
$servers['login_server'] = "<img src=\"/images/online.gif\" width=\"14\" height=\"14\" title=\"Online\" alt=\"Online\"> Online";
$ls_online = TRUE;
}
@fclose($check);
//On recherche le nombre de joueurs, mais seulement si le game server est en ligne
$nbr_player = 0;
$max_players = "";
$date = "";
if ($gs_online)
{
$connect = @mysql_connect ("$dbhost", "$dbusername", "$dbuserpw");
@mysql_select_db( "$dbname", $connect );
$sql = "select online from characters where online = '1'";
if (!$result = mysql_query($sql))
{
die('Impossible de retourner les joueurs en ligne!');
}
$nbr_player = mysql_num_rows($result);
$multiple = ($nbr_player < 2) ? "" : "s";
//On recherche le record absolu de joueurs en ligne
$req_sql = "select * from record ORDER BY maxplayer DESC LIMIT 1";
$sql = mysql_query($req_sql);
$line = mysql_fetch_array($sql);
$max_players = $line['maxplayer']." joueurs en ligne";
$date = $line['date'];
$date_explode = explode("-", $date);
$year = $date_explode[0];
$month = $date_explode[1];
$day = $date_explode[2];
$date = $day."-".$month."-".$year;
}
$template->assign_vars(array(
'L_GS' => "Game Server : ",
'L_LS' => "Login Server : ",
'L_PLAYERS' => $multiple." players online",
'L_RECORD' => "Record : ",
'GAME_SERVER' => $servers['game_server'],
'LOGIN_SERVER' => $servers['login_server'],
'MAX_PLAYERS' => $max_players,
'DATE' => "Le ".$date,
'PLAYERS' => $nbr_player)
);
mysql_close;
$modvar = $template->pparse_mod('body');
?>
Code: Select all
{$LR_BLOCK_H_L}SERVERS STATUS{$LR_BLOCK_H_R}
<div>
<b>{L_GS}</b>{GAME_SERVER}<br />
<b>{L_LS}</b>{LOGIN_SERVER}<br />
<br /><br />
{L_PLAYERS}{PLAYERS}<br />
{L_RECORD}{MAX_PLAYERS}<br>{DATE}
</div>
{$LR_BLOCK_F_L}{$LR_BLOCK_F_R}
I could ask to the author too, but he still uses GF portal, so I don't think he could be helpful :/.
[/i]