Jump to content

Progress bar online player [v1.4]


Guest deathart

Recommended Posts

Hello,

Here's a new version of online player:

Function:

-When the server is off a text indicates that there is no players because el server is OFF

-Introduction of a spoiler

-Gives the player name and level connected

-Progress bar that progresses bah xD

Codons: :ph34r:!

Create a page named: barre.php and enter this code:

<?php

/**
* @author deathart
* @copyright 2010
* @For: Zone-emu & Getmangos
*/

require_once("kernel/config.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
<link rel="stylesheet" href="css/barre.css" type="text/css" media="screen" />
<script type="text/javascript" src="js/spoiler.js"></script>
</head>
<body>
<?php
if (! $sock = @fsockopen($host, $port, $num, $error, 5))
// Si il est hors ligne
echo 'No player because the server is OFF';

else{
mysql_connect($host, $user, $pass);
mysql_select_db ($characters) or die (mysql_error());
$a = mysql_query("SELECT * FROM `characters` WHERE `online` = '1'");  
$b = mysql_num_rows($a);
$total = 100;
$pourcent = ( 100 / $total ) * $b; 
$width = ( $pourcent / 100 ) * 167; 

echo "<div class='bg-barre'><div class='joueur' style='width: ";
echo $width;
echo "px;'></div><div class='textbarre'>[b]Joueur(s) co : ";
?>
<a href="#" onclick="spoiler('1')">
<?php 
echo "".$b."</a>";
echo(' / ');
echo $total;
echo('[/b]</div></div>');
?>
<div id='1' style='display:none; border:0px solid #666'>
<?php 
   $result = mysql_query('SELECT count(online) FROM `characters` WHERE `online` = 1');
   $row = mysql_fetch_array($result);
$retour = mysql_query("SELECT COUNT(*) AS nbre FROM characters WHERE online = 1");
$donnees = mysql_fetch_array($retour);
$nbreconnect = $donnees['nbre'];
if ($nbreconnect >=1) { ?>
<table border="1px">
           <tr>
           <td width="100"><div align="center"><span>[b]Pseudo[/b]</span></div></td>
           <td width="100"><div align="center"><span>[b]Level[/b]</span></div></td>
           </tr>
<?php

$reponse = mysql_query("SELECT * FROM characters WHERE online = 1");
while ($donnees = mysql_fetch_array($reponse) )
{
?>      
           <tr>
           <td><div align="center"><span><?php echo $donnees['name']; ?></span></div></td>
           <td><div align="center"><span><?php echo $donnees['level']; ?></span></div></td>
           </tr>
<?php
}
}
?>
</table>
<?php 
echo('</body></html> ');
fclose($sock);
}
?>

Create a folder css and create a page named: barre.css and enter this code:

.bg-barre {
z-index:0;
background-image:url(../images/barrefond.png);
width:205px;
height:20px;
font-size:11px;
margin-left:12px;
}
.joueur {
z-index:1;
position:absolute;
margin-left:3px;
margin-top:3px;
height:15px;
opacity:10;
filter : alpha(opacity=10) ;
background-image: url('../images/barrecolor.png') ;
background-repeat: repeat-x;
}
.textbarre {
color: 99F;
padding:2px 2px 2px 12px;
z-index:2;
font-size:11px;
position:absolute;
margin-left:20px;
}

Create a folder kernel and create a page named: config.php and insert this code:

<?php

/**
* @author deathart
* @copyright 2010
* @For: Zone-emu & Getmangos
*/

$host = "127.0.0.1";
$user = "login";
$pass = "motsdepass";
$characters = "characters";
$connect = TRUE; // Autoriser ou non la connexion
$port = "8085"; // Port du serveur

?>

Js file and create a create a page named: spoiler.js and enter this code:

function spoiler(leId){
               var MonElement = document.getElementById(leId)
               if(MonElement.style.display == "none"){
                       MonElement.style.display  = "block";
               }
               else{
                       MonElement.style.display = "none";
               }
       }

Et pour finir les images:

Creez un dossier images et mettez y 2 images:

509704barrecolor.png

972360barrefond.png

Voili voilou! remember to change the IDs!

For lazy like me :P

Here is a rar:

https://compile-deathar.svn.sourceforge.net/svnroot/compile-deathar/Web/barre.rar

Excuse me my English because I'm French

Link to comment
Share on other sites

  • 4 months later...
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use