• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Powergamers. PHP Script!

Piltrafa

Active Member
Joined
Nov 10, 2010
Messages
654
Reaction score
29
Anyone know how can I edit my PHP - Powergamers.

I want implement:

K = 1,000 (Thousand) | M = 1,000,000 (Million) | B = 1,000,000,000 (Billion)

Actually when player get 100kk = 100.000.000 (And its it very long) better look this: 100M

Actually Script
PHP:
 <?PHP
$limit = 300;
$type = $_REQUEST['type'];
function coloured_value($valuein)
{
    $value2 = $valuein;
    while(strlen($value2) > 3)
    {
        $value .= '.'.substr($value2, -3, 3);
        $value2 = substr($value2, 0, strlen($value2)-3);
    }
    $value = $value2.$value;
    if($valuein > 0)
        return '<font color="green">+'.$value.'</font>';
    elseif($valuein < 0)
        return '<font color="red">'.$value.'</font>';
    else
        return '<font color="black">'.$value.'</font>';
}
if(empty($type))
    $players = $SQL->query(' SELECT * FROM players ORDER BY `players`.`experience`-`players`.`exphist_lastexp` DESC LIMIT '.$limit)->fetchAll();
elseif($type == "sum")
    $players = $SQL->query(' SELECT * FROM players ORDER BY `players`.`exphist1`+`players`.`exphist2`+`players`.`exphist3`+`players`.`exphist4`+`players`.`exphist5`+`players`.`exphist6`+`players`.`exphist7`+`players`.`experience`-`players`.`exphist_lastexp` DESC LIMIT '.$limit)->fetchAll();
elseif($type >= 1 && $type <= 7)
    $players = $SQL->query(' SELECT * FROM players ORDER BY exphist'.(int) $type.' DESC LIMIT '.$limit)->fetchAll();
$main_content .= '<CENTER><H2>Ranking of powergamers</H2></CENTER><BR><TABLE BORDER=0 CELLPADDING=4 CELLSPACING=1 WIDTH=100%></TABLE><TABLE BORDER=0 CELLPADDING=4 CELLSPACING=1 WIDTH=100%><TR BGCOLOR="'.$config['site']['vdarkborder'].'"><TD WIDTH=10% CLASS=whites><B>Rank</B></TD><TD WIDTH=75% CLASS=whites><B>Name</B></TD>';
if($type == "sum")
    $main_content .= '<TD WIDTH=15% bgcolor="red" CLASS=whites><b><center><a href="?subtopic=exphist&type=sum">7 Days sum</a></center></B></TD>';
else
    $main_content .= '<TD WIDTH=15% bgcolor="yellow" CLASS=whites><b><center><a href="?subtopic=exphist&type=sum">7 Days sum</a></center></B></TD>';
for($i = 7; $i >= 2; $i--)
    if($type == $i)
        $main_content .= '<TD WIDTH=15% bgcolor="red" CLASS=whites><b><center><a href="?subtopic=exphist&type='.$i.'">'.$i.' Days Ago</a></center></B></TD>';
    else
        $main_content .= '<TD WIDTH=15% bgcolor="yellow" CLASS=whites><b><center><a href="?subtopic=exphist&type='.$i.'">'.$i.' Days Ago</a></center></B></TD>';
if($type == 1)
    $main_content .= '<TD WIDTH=15% bgcolor="red" CLASS=whites><b><center><a href="?subtopic=exphist&type=1">1 Day Ago</a></center></B></TD>';
else
    $main_content .= '<TD WIDTH=15% bgcolor="yellow" CLASS=whites><b><center><a href="?subtopic=exphist&type=1">1 Day Ago</a></center></B></TD>';
if(empty($type))
    $main_content .= '<TD WIDTH=15% bgcolor="red" CLASS=whites><b><center><a href="?subtopic=exphist">Today</a></center></B></TD>';
else
    $main_content .= '<TD WIDTH=15% bgcolor="yellow" CLASS=whites><b><center><a href="?subtopic=exphist">Today</a></center></B></TD>';
$main_content .= '</TR>';
foreach($players as $player)
{
    if(!is_int($number_of_rows / 2)) { $bgcolor = $config['site']['darkborder']; } else { $bgcolor = $config['site']['lightborder']; } $number_of_rows++;
    $main_content .= '<tr bgcolor="'.$bgcolor.'"><td align="center">'.$number_of_rows.'. </td>';
    if($player['online'] == 1)
        $main_content .= '<td><a href="?subtopic=characters&name='.urlencode($player['name']).'"><b><font color="green">'.$player['name'].'</font></b></a>';
    else
        $main_content .= '<td><a href="?subtopic=characters&name='.urlencode($player['name']).'"><b><font color="red">'.$player['name'].'</font></b></a>';
    $main_content .= '<br />'.$player['level'].' '.$config_vocations[$player['vocation']].'</td><td align="right">'.coloured_value($player['exphist1'] + $player['exphist2'] + $player['exphist3'] + $player['exphist4'] + $player['exphist5'] + $player['exphist6'] + $player['exphist7'] + $player['experience'] - $player['exphist_lastexp']).'</td>';
    $main_content .= '<td align="right">'.coloured_value($player['exphist7']).'</td><td align="right">'.coloured_value($player['exphist6']).'</td><td align="right">'.coloured_value($player['exphist5']).'</td><td align="right">'.coloured_value($player['exphist4']).'</td><td align="right">'.coloured_value($player['exphist3']).'</td><td align="right">'.coloured_value($player['exphist2']).'</td><td align="right">'.coloured_value($player['exphist1']).'</td><td align="right">'.coloured_value($player['experience']-$player['exphist_lastexp']).'</td></tr>';
}
$main_content .= '</TABLE>';
?>


REP++
 
PHP:
<?PHP
$limit = 300;
$type = $_REQUEST['type'];
function coloured_value($valuein)
{
    $value2 = $valuein;
    while(strlen($value2) > 3)
    {
        $value .= '.'.substr($value2, -3, 3);
        $value2 = substr($value2, 0, strlen($value2)-3);
    }
    $value = $value2.$value;
    if($valuein > 0)
        return '<font color="green">+'.$value.'</font>';
    elseif($valuein < 0)
        return '<font color="red">'.$value.'</font>';
    else
        return '<font color="black">'.$value.'</font>';
}
if(empty($type))
    $players = $SQL->query(' SELECT * FROM players ORDER BY `players`.`experience`-`players`.`exphist_lastexp` DESC LIMIT '.$limit)->fetchAll();
elseif($type == "sum")
    $players = $SQL->query(' SELECT * FROM players ORDER BY `players`.`exphist1`+`players`.`exphist2`+`players`.`exphist3`+`players`.`exphist4`+`players`.`exphist5`+`players`.`exphist6`+`players`.`exphist7`+`players`.`experience`-`players`.`exphist_lastexp` DESC LIMIT '.$limit)->fetchAll();
elseif($type >= 1 && $type <= 7)
    $players = $SQL->query(' SELECT * FROM players ORDER BY exphist'.(int) $type.' DESC LIMIT '.$limit)->fetchAll();
$main_content .= '<CENTER><H2>Ranking of powergamers</H2></CENTER><BR><TABLE BORDER=0 CELLPADDING=4 CELLSPACING=1 WIDTH=100%></TABLE><TABLE BORDER=0 CELLPADDING=4 CELLSPACING=1 WIDTH=100%><TR BGCOLOR="'.$config['site']['vdarkborder'].'"><TD WIDTH=10% CLASS=whites><B>Rank</B></TD><TD WIDTH=75% CLASS=whites><B>Name</B></TD>';
if($type == "sum")
    $main_content .= '<TD WIDTH=15% bgcolor="red" CLASS=whites><b><center><a href="?subtopic=exphist&type=sum">7 Days sum</a></center></B></TD>';
else
    $main_content .= '<TD WIDTH=15% bgcolor="yellow" CLASS=whites><b><center><a href="?subtopic=exphist&type=sum">7 Days sum</a></center></B></TD>';
for($i = 7; $i >= 2; $i--)
    if($type == $i)
        $main_content .= '<TD WIDTH=15% bgcolor="red" CLASS=whites><b><center><a href="?subtopic=exphist&type='.$i.'">'.$i.' Days Ago</a></center></B></TD>';
    else
        $main_content .= '<TD WIDTH=15% bgcolor="yellow" CLASS=whites><b><center><a href="?subtopic=exphist&type='.$i.'">'.$i.' Days Ago</a></center></B></TD>';
if($type == 1)
    $main_content .= '<TD WIDTH=15% bgcolor="red" CLASS=whites><b><center><a href="?subtopic=exphist&type=1">1 Day Ago</a></center></B></TD>';
else
    $main_content .= '<TD WIDTH=15% bgcolor="yellow" CLASS=whites><b><center><a href="?subtopic=exphist&type=1">1 Day Ago</a></center></B></TD>';
if(empty($type))
    $main_content .= '<TD WIDTH=15% bgcolor="red" CLASS=whites><b><center><a href="?subtopic=exphist">Today</a></center></B></TD>';
else
    $main_content .= '<TD WIDTH=15% bgcolor="yellow" CLASS=whites><b><center><a href="?subtopic=exphist">Today</a></center></B></TD>';
$main_content .= '</TR>';
foreach($players as $player)
{
    if(!is_int($number_of_rows / 2)) { $bgcolor = $config['site']['darkborder']; } else { $bgcolor = $config['site']['lightborder']; } $number_of_rows++;
    $main_content .= '<tr bgcolor="'.$bgcolor.'"><td align="center">'.$number_of_rows.'. </td>';
    if($player['online'] == 1)
        $main_content .= '<td><a href="?subtopic=characters&name='.urlencode($player['name']).'"><b><font color="green">'.$player['name'].'</font></b></a>';
    else
        $main_content .= '<td><a href="?subtopic=characters&name='.urlencode($player['name']).'"><b><font color="red">'.$player['name'].'</font></b></a>';
    $main_content .= '<br />'.$player['level'].' '.$config_vocations[$player['vocation']].'</td><td align="right">'.coloured_value($player['exphist1'] + $player['exphist2'] + $player['exphist3'] + $player['exphist4'] + $player['exphist5'] + $player['exphist6'] + $player['exphist7'] + $player['experience'] - $player['exphist_lastexp']).'</td>';
    $main_content .= '<td align="right">'.coloured_value($player['exphist7']).'</td><td align="right">'.coloured_value($player['exphist6']).'</td><td align="right">'.coloured_value($player['exphist5']).'</td><td align="right">'.coloured_value($player['exphist4']).'</td><td align="right">'.coloured_value($player['exphist3']).'</td><td align="right">'.coloured_value($player['exphist2']).'</td><td align="right">'.coloured_value($player['exphist1']).'</td><td align="right">'.coloured_value($player['experience']-$player['exphist_lastexp']).'</td></tr>';
}
$main_content .= '</TABLE>';
?>

PHP:
ALTER TABLE `players` ADD `exphist_lastexp` BIGINT( 255 ) NOT NULL DEFAULT '0', 
ADD `exphist1` BIGINT( 255 ) NOT NULL DEFAULT '0', 
ADD `exphist2` BIGINT( 255 ) NOT NULL DEFAULT '0', 
ADD `exphist3` BIGINT( 255 ) NOT NULL DEFAULT '0', 
ADD `exphist4` BIGINT( 255 ) NOT NULL DEFAULT '0', 
ADD `exphist5` BIGINT( 255 ) NOT NULL DEFAULT '0', 
ADD `exphist6` BIGINT( 255 ) NOT NULL DEFAULT '0', 
ADD `exphist7` BIGINT( 255 ) NOT NULL DEFAULT '0', 
ADD `onlinetimetoday` BIGINT( 255 ) NOT NULL DEFAULT '0', 
ADD `onlinetime1` BIGINT( 255 ) NOT NULL DEFAULT '0', 
ADD `onlinetime2` BIGINT( 255 ) NOT NULL DEFAULT '0', 
ADD `onlinetime3` BIGINT( 255 ) NOT NULL DEFAULT '0', 
ADD `onlinetime4` BIGINT( 255 ) NOT NULL DEFAULT '0', 
ADD `onlinetime5` BIGINT( 255 ) NOT NULL DEFAULT '0', 
ADD `onlinetime6` BIGINT( 255 ) NOT NULL DEFAULT '0', 
ADD `onlinetime7` BIGINT( 255 ) NOT NULL DEFAULT '0', 
ADD `onlinetimeall` BIGINT( 255 ) NOT NULL DEFAULT '0';


Credits to nwtr.
 
PHP:
CREATE TABLE IF NOT EXISTS `player_experience` (
  `player_id` INT(10) UNSIGNED NOT NULL,
  `lastlogout` INT(10) UNSIGNED NOT NULL,
  `period` INT(10) NOT NULL DEFAULT 0,
  `experience` BIGINT NOT NULL DEFAULT 0,
  
  FOREIGN KEY (`player_id`) REFERENCES `players` (`id`) ON DELETE CASCADE
) ENGINE = InnoDB;

CREATE TRIGGER `onupdate_players`
AFTER UPDATE
ON `players`
FOR EACH ROW
BEGIN
    DECLARE expGain BIGINT UNSIGNED;
    SET expGain = NEW.`experience` - OLD.`experience`;
    
    # let's avoid keeping data from players who never enters
    IF (expGain <> 0) THEN
        INSERT INTO `player_experience` VALUES (OLD.`id`, NEW.`lastlogout`, (NEW.`lastlogout` - NEW.`lastlogin`), expGain);
    END IF;
END;

Execute this in your database.

Credits to Nostradamus.


Regards,
Zysen
 
I think you don't understand me.

I want a script like this:
herepz.png



Or only show the last 3 days... not 7 days :p
 
anyone know how can i edit my php - powergamers.

I want implement:

K = 1,000 (thousand) | m = 1,000,000 (million) | b = 1,000,000,000 (billion)

actually when player get 100kk = 100.000.000 (and its it very long) better look this: 100m

actually script
PHP:
 <?php
$limit = 300;
$type = $_request['type'];
function coloured_value($valuein)
{
    $value2 = $valuein;
    while(strlen($value2) > 3)
    {
        $value .= '.'.substr($value2, -3, 3);
        $value2 = substr($value2, 0, strlen($value2)-3);
    }
    $value = $value2.$value;
    if($valuein > 0)
        return '<font color="green">+'.$value.'</font>';
    elseif($valuein < 0)
        return '<font color="red">'.$value.'</font>';
    else
        return '<font color="black">'.$value.'</font>';
}
if(empty($type))
    $players = $sql->query(' select * from players order by `players`.`experience`-`players`.`exphist_lastexp` desc limit '.$limit)->fetchall();
elseif($type == "sum")
    $players = $sql->query(' select * from players order by `players`.`exphist1`+`players`.`exphist2`+`players`.`exphist3`+`players`.`exphist4`+`players`.`exphist5`+`players`.`exphist6`+`players`.`exphist7`+`players`.`experience`-`players`.`exphist_lastexp` desc limit '.$limit)->fetchall();
elseif($type >= 1 && $type <= 7)
    $players = $sql->query(' select * from players order by exphist'.(int) $type.' desc limit '.$limit)->fetchall();
$main_content .= '<center><h2>ranking of powergamers</h2></center><br><table border=0 cellpadding=4 cellspacing=1 width=100%></table><table border=0 cellpadding=4 cellspacing=1 width=100%><tr bgcolor="'.$config['site']['vdarkborder'].'"><td width=10% class=whites><b>rank</b></td><td width=75% class=whites><b>name</b></td>';
if($type == "sum")
    $main_content .= '<td width=15% bgcolor="red" class=whites><b><center><a rel="nofollow" href="?subtopic=exphist&amp;type=sum">7 days sum</a></center></b></td>';
else
    $main_content .= '<td width=15% bgcolor="yellow" class=whites><b><center><a rel="nofollow" href="?subtopic=exphist&amp;type=sum">7 days sum</a></center></b></td>';
for($i = 7; $i >= 2; $i--)
    if($type == $i)
        $main_content .= '<td width=15% bgcolor="red" class=whites><b><center><a rel="nofollow" href="?subtopic=exphist&amp;type='.$i.'">'.$i.' days ago</a></center></b></td>';
    else
        $main_content .= '<td width=15% bgcolor="yellow" class=whites><b><center><a rel="nofollow" href="?subtopic=exphist&amp;type='.$i.'">'.$i.' days ago</a></center></b></td>';
if($type == 1)
    $main_content .= '<td width=15% bgcolor="red" class=whites><b><center><a rel="nofollow" href="?subtopic=exphist&amp;type=1">1 day ago</a></center></b></td>';
else
    $main_content .= '<td width=15% bgcolor="yellow" class=whites><b><center><a rel="nofollow" href="?subtopic=exphist&amp;type=1">1 day ago</a></center></b></td>';
if(empty($type))
    $main_content .= '<td width=15% bgcolor="red" class=whites><b><center><a rel="nofollow" href="?subtopic=exphist">today</a></center></b></td>';
else
    $main_content .= '<td width=15% bgcolor="yellow" class=whites><b><center><a rel="nofollow" href="?subtopic=exphist">today</a></center></b></td>';
$main_content .= '</tr>';
foreach($players as $player)
{
    if(!is_int($number_of_rows / 2)) { $bgcolor = $config['site']['darkborder']; } else { $bgcolor = $config['site']['lightborder']; } $number_of_rows++;
    $main_content .= '<tr bgcolor="'.$bgcolor.'"><td align="center">'.$number_of_rows.'. </td>';
    if($player['online'] == 1)
        $main_content .= '<td><a rel="nofollow" href="?subtopic=characters&amp;name='.urlencode($player['name']).'"><b><font color="green">'.$player['name'].'</font></b></a>';
    else
        $main_content .= '<td><a rel="nofollow" href="?subtopic=characters&amp;name='.urlencode($player['name']).'"><b><font color="red">'.$player['name'].'</font></b></a>';
    $main_content .= '<br />'.$player['level'].' '.$config_vocations[$player['vocation']].'</td><td align="right">'.coloured_value($player['exphist1'] + $player['exphist2'] + $player['exphist3'] + $player['exphist4'] + $player['exphist5'] + $player['exphist6'] + $player['exphist7'] + $player['experience'] - $player['exphist_lastexp']).'</td>';
    $main_content .= '<td align="right">'.coloured_value($player['exphist7']).'</td><td align="right">'.coloured_value($player['exphist6']).'</td><td align="right">'.coloured_value($player['exphist5']).'</td><td align="right">'.coloured_value($player['exphist4']).'</td><td align="right">'.coloured_value($player['exphist3']).'</td><td align="right">'.coloured_value($player['exphist2']).'</td><td align="right">'.coloured_value($player['exphist1']).'</td><td align="right">'.coloured_value($player['experience']-$player['exphist_lastexp']).'</td></tr>';
}
$main_content .= '</table>';
?>


rep++

bump
 
PHP:
function expConvert($exp) //By olafurw [at] gmail.com
    {
        $s = array('', 'k', 'M', 'B', 'T');
        $e = floor(log($exp)/log(1000));
      
        return sprintf('%.2f '.$s[$e], ($exp/pow(1000, floor($e))));
    }
However, it can be made without using logarithm at all (which would save you a few CPU cycles)... And no. I'm in no way telling you where and how to use it. Figure it yourself if you want to have such thing.
 
Back
Top