• 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!

Solved [.PHP] Powergamers

Sentinel3

New Member
Joined
Oct 16, 2014
Messages
180
Reaction score
0
Hi everyone,

Does not work properly, it doesn't go to the next day but keeps adding all experience to Today.

Can someone tell me what's wrong with this .php file?

powergamers.php
PHP:
<?php
if(!defined('INITIALIZED'))
    exit;

$limit = 50;
$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 ' . $SQL->tableName('players') . ' WHERE ' . $SQL->fieldName('group_id') . ' < 2 ORDER BY ' . $SQL->fieldName('experience') . '-' . $SQL->fieldName('exphist_lastexp') . ' DESC LIMIT ' . $limit)->fetchAll();
elseif($type == "sum")
    $players = $SQL->query('SELECT * FROM ' . $SQL->tableName('players') . ' WHERE ' . $SQL->fieldName('group_id') . ' < 2 ORDER BY ' . $SQL->fieldName('exphist1') . '+' . $SQL->fieldName('exphist2') . '+' . $SQL->fieldName('exphist3') . '+' . $SQL->fieldName('exphist4') . '+' . $SQL->fieldName('exphist5') . '+' . $SQL->fieldName('exphist6') . '+' . $SQL->fieldName('exphist7') . '+' . $SQL->fieldName('experience') . '-' . $SQL->fieldName('exphist_lastexp') . ' DESC LIMIT ' . $limit)->fetchAll();
elseif($type >= 1 && $type <= 7)
    $players = $SQL->query('SELECT * FROM ' . $SQL->tableName('players') . ' WHERE ' . $SQL->fieldName('group_id') . ' < 2 ORDER BY ' . $SQL->fieldName('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%"><TR BGCOLOR="'.$config['site']['vdarkborder'].'"><TD style="color:white"><B>Rank</B></TD><TD style="color:white"><B>Name</B></TD>';
if($type == "sum")
    $main_content .= '<TD bgcolor="red"><b><center><a href="?subtopic=powergamers&type=sum">7 Days sum</a></center></B></TD>';
else
    $main_content .= '<TD bgcolor="yellow"><b><center><a href="?subtopic=powergamers&type=sum">7 Days sum</a></center></B></TD>';
for($i = 7; $i >= 2; $i--)
{
    if($type == $i)
        $main_content .= '<TD bgcolor="red"><b><center><a href="?subtopic=powergamers&type='.$i.'">'.$i.' Days Ago</a></center></B></TD>';
    else
        $main_content .= '<TD bgcolor="yellow"><b><center><a href="?subtopic=powergamers&type='.$i.'">'.$i.' Days Ago</a></center></B></TD>';
}
if($type == 1)
    $main_content .= '<TD bgcolor="red"><b><center><a href="?subtopic=powergamers&type=1">1 Day Ago</a></center></B></TD>';
else
    $main_content .= '<TD bgcolor="yellow"><b><center><a href="?subtopic=powergamers&type=1">1 Day Ago</a></center></B></TD>';
if(empty($type))
    $main_content .= '<TD bgcolor="red"><b><center><a href="?subtopic=powergamers">Today</a></center></B></TD>';
else
    $main_content .= '<TD bgcolor="yellow"><b><center><a href="?subtopic=powergamers">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::isPlayerOnline($player['id']))
        $main_content .= '<td><a href="?subtopic=characters&name='.urlencode($player['name']).'"><b><font color="green">'.htmlspecialchars($player['name']).'</font></b></a>';
    else
        $main_content .= '<td><a href="?subtopic=characters&name='.urlencode($player['name']).'"><b><font color="red">'.htmlspecialchars($player['name']).'</font></b></a>';
    $main_content .= '<br />'.$player['level'].' '.htmlspecialchars(Website::getVocationName($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>';
<?
 
Not certain how this script works, but do you get any errors? Can you see the index file but you can't click the link? Or is the link simply empty?

Ignazio
 
The PHP script doesn't move the experience to the next day. You need to add the globalevent as well.

Powergamers Globalevent:
Code:
function onThink()
    if (tonumber(os.date("%d")) ~= getGlobalStorageValue(23456)) then
        setGlobalStorageValue(23456, (tonumber(os.date("%d"))))
        db.executeQuery("UPDATE `players` SET `onlinetime7`=`onlinetime6`, `onlinetime6`=`onlinetime5`, `onlinetime5`=`onlinetime4`, `onlinetime4`=`onlinetime3`, `onlinetime3`=`onlinetime2`, `onlinetime2`=`onlinetime1`, `onlinetime1`=`onlinetimetoday`, `onlinetimetoday`=0;")
        db.executeQuery("UPDATE `players` SET `exphist7`=`exphist6`, `exphist6`=`exphist5`, `exphist5`=`exphist4`, `exphist4`=`exphist3`, `exphist3`=`exphist2`, `exphist2`=`exphist1`, `exphist1`=`experience`-`exphist_lastexp`, `exphist_lastexp`=`experience`;")
    end
    db.executeQuery("UPDATE `players` SET `onlinetimetoday`=`onlinetimetoday`+60, `onlinetimeall`=`onlinetimeall`+60 WHERE `online` = 1;")
end

If you don't have a top online chart than you an remove those lines.
 
[Error - BaseEvents::loadFromXml] Failed to load data/globalevents/globalevents.xml: Error parsing start element tag
> ERROR: Unable to load global events!
> ERROR: Failed to load script systems
 
HTML:
<globalevent name="powergamers" interval="2000" script="others/powergamers.lua"/>

Error in script of powergamers.lua
HTML:
Lua Script Error: [GlobalEvent Interface]
data/globalevents/scripts/others/powergamers.lua:onThink
data/globalevents/scripts/others/powergamers.lua:7: attempt to call field 'executeQuery' (a nil value)
stack traceback:
        [C]: in function 'executeQuery'
        data/globalevents/scripts/others/powergamers.lua:7: in function <data/globalevents/scripts/others/powergamers.lua:1>
[Error - GlobalEvents::think] Failed to execute event: powergamers
 
Please post your full globalevents.xml, or just scan it yourself maybe you can find the missing tag.

Edit: Change db.executeQuery to db.query
Code:
function onThink(interval, lastExecution)
    if (tonumber(os.date("%d")) ~= getGlobalStorageValue(23456)) then
        setGlobalStorageValue(23456, (tonumber(os.date("%d"))))
        db.query("UPDATE `players` SET `onlinetime7`=players.onlinetime6, `onlinetime6`=players.onlinetime5, `onlinetime5`=players.onlinetime4, `onlinetime4`=players.onlinetime3, `onlinetime3`=players.onlinetime2, `onlinetime2`=players.onlinetime1, `onlinetime1`=players.onlinetimetoday, `onlinetimetoday`=0;")
        db.query("UPDATE `players` SET `exphist7`=players.exphist6, `exphist6`=players.exphist5, `exphist5`=players.exphist4, `exphist4`=players.exphist3, `exphist3`=players.exphist2, `exphist2`=players.exphist1, `exphist1`=players.experience-players.exphist_lastexp, `exphist_lastexp`=players.experience;")
    end
    db.query("UPDATE `players` SET `onlinetimetoday`=players.onlinetimetoday+60000, `onlinetimeall`=players.onlinetimeall+60000 WHERE `online` = 1;")
    return TRUE
end
 
Globalevents.xml
HTML:
<?xml version="1.0" encoding="UTF-8"?>
<globalevents>
    <!-- Blooming Griffinclaw -->
    <globalevent name="bloomingGriffinclaw" type="start" script="blooming griffinclaw/bloomingGriffinclaw.lua"/>

    <!-- Wrath Of The Emperor Quest -->
    <globalevent name="wrathOfTheEmeperorQuestDoors" interval="5000" script="wrath of the emperor quest/wrathOfTheEmeperorQuestDoors.lua"/>

    <!-- Demon Oak Quest -->
    <globalevent name="OakThink" interval="15000" script="demon oak quest/oakthink.lua"/>

    <!-- Rent Horses -->
    <globalevent name="RentThink" interval="15000" script="others/checkmount.lua"/>

    <!-- World Changes -->
    <globalevent name="furygates" type="startup" script="worldchanges/gates.lua"/>
    <globalevent name="resetfurygates" type="shutdown" script="worldchanges/resetgates.lua"/>

    <!-- Others -->
    <globalevent type="startup" name="ServerStartup" script="startup.lua"/>
    <globalevent type="record" name="PlayerRecord" script="record.lua"/>
    <globalevent name="Server Save" time="09:55:00" script="serversave.lua"/>
    <globalevent name="Shop" interval="60000" script="shop.lua" />

    <!-- Spawn -->
    <globalevent name="RandomBossSummon" interval="3600000" script="spawn/BossSpawn.lua"/>
    <globalevent type="startup" name="RashidSpawnStartup" script="spawn/RashidSpawn.lua"/>
    <globalevent type="startup" name="CilliaSpawnStartup" script="spawn/CilliaSpawn.lua"/>
    <globalevent name="raid" interval="108000" script="spawn/raid.lua"/>

    <!-- Animated -->
    <globalevent name="talkingSigns" interval="2000" script="animated/talking.lua"/>
   
    <!-- Powergamers -->
    <globalevent name="powergamers" interval="2000" script="others/powergamers.lua"/>
   
    <!-- Zombie Event -->
    <!-- <globalevent name="zombie" interval="60000" script="zombie_think.lua"/> -->
<!--
    <globalevent name="website_shop_item_delivery" interval="30000" script="shop.lua"/>
-->
</globalevents>
 
Error in console:
HTML:
data/globalevents/scripts/others/powergamers.lua:7: in function <data/globalevents/scripts/others/powergamers.lua:1>
-bash: syntax error near unexpected token `newline'
otsmanager@ubuntu:~$ [Error - GlobalEvents::think] Failed to execute event: powergamers
 
Error in console:
HTML:
data/globalevents/scripts/others/powergamers.lua:7: in function <data/globalevents/scripts/others/powergamers.lua:1>
-bash: syntax error near unexpected token `newline'
otsmanager@ubuntu:~$ [Error - GlobalEvents::think] Failed to execute event: powergamers

Code:
function onThink(interval, lastExecution)
    if (tonumber(os.date("%d")) ~= getGlobalStorageValue(23456)) then
        setGlobalStorageValue(23456, (tonumber(os.date("%d"))))
        db.query("UPDATE `players` SET `exphist7`=players.exphist6, `exphist6`=players.exphist5, `exphist5`=players.exphist4, `exphist4`=players.exphist3, `exphist3`=players.exphist2, `exphist2`=players.exphist1, `exphist1`=players.experience-players.exphist_lastexp, `exphist_lastexp`=players.experience;")
    end 
    return TRUE
end
 
i have error
Lua:
Class 'Player' not found


Backtrace:

#0 /var/www/html/index.php(347): require()
#1 {main}
This code is for Gesior2012 acc. maker and it must be loaded as page of acc. maker.
1.x version:
0.4 version:
 
Back
Top