Ir para conteúdo
  • Cadastre-se

Posts Recomendados

Ótimo, basta substituir todo o seu highscore.php

<?php
if (!defined('INITIALIZED')) exit;

$list = 'experience';
if (isset($_REQUEST['list'])) $list = $_REQUEST['list'];

$page = 0;
if (isset($_REQUEST['page'])) $page = min(50, $_REQUEST['page']);

$vocation = '';
if (isset($_REQUEST['vocation'])) $vocation = $_REQUEST['vocation'];

switch ($list) {
    case "fist":
        $id = Highscores::SKILL_FIST;
        $list_name = 'Fist Fighting';
        break;
    case "club":
        $id = Highscores::SKILL_CLUB;
        $list_name = 'Club Fighting';
        break;
    case "sword":
        $id = Highscores::SKILL_SWORD;
        $list_name = 'Sword Fighting';
        break;
    case "axe":
        $id = Highscores::SKILL_AXE;
        $list_name = 'Axe Fighting';
        break;
    case "distance":
        $id = Highscores::SKILL_DISTANCE;
        $list_name = 'Distance Fighting';
        break;
    case "shield":
        $id = Highscores::SKILL_SHIELD;
        $list_name = 'Shielding';
        break;
    case "fishing":
        $id = Highscores::SKILL_FISHING;
        $list_name = 'Fishing';
        break;
    case "magic":
        $id = Highscores::SKILL__MAGLEVEL;
        $list_name = 'Magic';
        break;
    case "reset":
        $id = Highscores::SKILL__RESET;
        $list_name = 'Resets';
        break;
    default:
        $id = Highscores::SKILL__LEVEL;
        $list_name = 'Experience';
        break;
}

$world_name = $config['server']['serverName'];

$offset = $page * 100;
$skills = new Highscores($id, 100, $page, $vocation);

// Iniciar a construção do conteúdo principal
$main_content .= '<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%><TR><TD><IMG SRC="'.$layout_name.'/images/blank.gif" WIDTH=10 HEIGHT=1 BORDER=0></TD><TD><CENTER><H2>Ranking for '.htmlspecialchars($list_name).' on '.htmlspecialchars($world_name).'</H2></CENTER><BR>';

$main_content .= '<br><table border="0" cellpadding="4" cellspacing="1" width="100%">
<tr bgcolor="'.$config['site']['vdarkborder'].'">
<td class="whites"><b>Rank</b></td>
<td width="75%" class="whites"><b>Name</b></td>
<td width="10%" class="whites"><b><center>Level</center></b></td>';

if ($list == "experience") {
    $main_content .= '<td width="10%" class="whites"><b><center>Experience</center></b></td>
    <td width="10%" class="whites"><b><center>Resets</center></b></td>';
}

$main_content .= '</tr>';

$number_of_rows = 0;

foreach ($skills as $skill) {
    $value = $list == "magic" ? $skill->getMagLevel() : ($list == "experience" ? $skill->getLevel() : $skill->getScore());
    $bgcolor = (($number_of_rows++ % 2 == 1) ? $config['site']['darkborder'] : $config['site']['lightborder']);

    $main_content .= '<tr bgcolor="'.$bgcolor.'">
    <td style="text-align:right">'.($offset + $number_of_rows).'. </td>
    <td><a href="?subtopic=characters&name='.urlencode($skill->getName()).'">'.($skill->getOnline() > 0 ? "<font color=\"green\">".htmlspecialchars($skill->getName())."</font>" : "<font color=\"red\">".htmlspecialchars($skill->getName())."</font>").'</a><br><small>'.$skill->getLevel().' '.htmlspecialchars(Website::getVocationName($skill->getVocation())).'</small></td>
    <td><center>'.$value.'</center></td>';

    if ($list == "experience") {
        $main_content .= '<td><center>'.$skill->getExperience().'</center></td>';

        $main_content .= '<td><center>'.$skill->getResets().'</center></td>'; 
    }

    $main_content .= '</tr>';
}


$main_content .= '</table>';

$main_content .= '<table border="0" cellpadding="4" cellspacing="1" width="100%">
<tr bgcolor="'.$config['site']['vdarkborder'].'">
<td class="whites" colspan="2"><center><b>Choose a skill</b></center></td>
</tr>
<tr bgcolor="'.$config['site']['lightborder'].'">
<td style="text-align: center;">
<a href="?subtopic=highscores&list=experience" class="size_xs">Experience</a><br>
<a href="?subtopic=highscores&list=magic" class="size_xs">Magic</a><br>
<a href="?subtopic=highscores&list=shield" class="size_xs">Shielding</a><br>
<a href="?subtopic=highscores&list=distance" class="size_xs">Distance</a><br>
<a href="?subtopic=highscores&list=club" class="size_xs">Club</a><br>
<a href="?subtopic=highscores&list=sword" class="size_xs">Sword</a><br>
<a href="?subtopic=highscores&list=axe" class="size_xs">Axe</a><br>
<a href="?subtopic=highscores&list=fist" class="size_xs">Fist</a><br>
<a href="?subtopic=highscores&list=fishing" class="size_xs">Fishing</a><br>
<a href="?subtopic=highscores&list=reset" class="size_xs">Resets</a><br>
</td>
</tr>
</table>';

E depois vá em htdocs/classes/player.php

e procure por essa linha.

	public function loadStorages()
	{
		$this->storages = array();
		// load all
		$storages = $this->getDatabaseHandler()->query('SELECT ' . $this->getDatabaseHandler()->fieldName('player_id') . ', ' . $this->getDatabaseHandler()->fieldName('key') . 
			', ' . $this->getDatabaseHandler()->fieldName('value') . ' FROM ' .$this->getDatabaseHandler()->tableName('player_storage') .
			' WHERE ' . $this->getDatabaseHandler()->fieldName('player_id') . ' = ' . $this->getDatabaseHandler()->quote($this->data['id']))->fetchAll();
		foreach($storages as $storage)
		{
			$this->storages[$storage['key']] = $storage['value'];
		}
	}

É só adicionar abaixo e salvar. Pronto, o seu ranking com resets está pronto.

public function getResets()
{
    $result = $this->getDatabaseHandler()->query('SELECT resets FROM ' . $this->getDatabaseHandler()->tableName('players') . 
        ' WHERE id = ' . $this->getDatabaseHandler()->quote($this->data['id']))->fetch();

    if ($result) {
        return (int)$result['resets'];
    } else {
        $this->getDatabaseHandler()->execute('INSERT INTO ' . $this->getDatabaseHandler()->tableName('players') . 
            ' (id, resets) VALUES (' . $this->getDatabaseHandler()->quote($this->data['id']) . ', 0)' .
            ' ON DUPLICATE KEY UPDATE resets = 0'); 
        return 0; 
    }
}

Depois, não se esqueça de dar REP e marcar como solução :)

Editado por Mateus Robeerto (veja o histórico de edições)
Link para o post
Compartilhar em outros sites
  • Respostas 8
  • Created
  • Última resposta

Top Posters In This Topic

32 minutos atrás, Mateus Robeerto disse:

Ótimo, basta substituir todo o seu highscore.php


<?php
if (!defined('INITIALIZED')) exit;

$list = 'experience';
if (isset($_REQUEST['list'])) $list = $_REQUEST['list'];

$page = 0;
if (isset($_REQUEST['page'])) $page = min(50, $_REQUEST['page']);

$vocation = '';
if (isset($_REQUEST['vocation'])) $vocation = $_REQUEST['vocation'];

switch ($list) {
    case "fist":
        $id = Highscores::SKILL_FIST;
        $list_name = 'Fist Fighting';
        break;
    case "club":
        $id = Highscores::SKILL_CLUB;
        $list_name = 'Club Fighting';
        break;
    case "sword":
        $id = Highscores::SKILL_SWORD;
        $list_name = 'Sword Fighting';
        break;
    case "axe":
        $id = Highscores::SKILL_AXE;
        $list_name = 'Axe Fighting';
        break;
    case "distance":
        $id = Highscores::SKILL_DISTANCE;
        $list_name = 'Distance Fighting';
        break;
    case "shield":
        $id = Highscores::SKILL_SHIELD;
        $list_name = 'Shielding';
        break;
    case "fishing":
        $id = Highscores::SKILL_FISHING;
        $list_name = 'Fishing';
        break;
    case "magic":
        $id = Highscores::SKILL__MAGLEVEL;
        $list_name = 'Magic';
        break;
    case "reset":
        $id = Highscores::SKILL__RESET;
        $list_name = 'Resets';
        break;
    default:
        $id = Highscores::SKILL__LEVEL;
        $list_name = 'Experience';
        break;
}

$world_name = $config['server']['serverName'];

$offset = $page * 100;
$skills = new Highscores($id, 100, $page, $vocation);

// Iniciar a construção do conteúdo principal
$main_content .= '<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%><TR><TD><IMG SRC="'.$layout_name.'/images/blank.gif" WIDTH=10 HEIGHT=1 BORDER=0></TD><TD><CENTER><H2>Ranking for '.htmlspecialchars($list_name).' on '.htmlspecialchars($world_name).'</H2></CENTER><BR>';

$main_content .= '<br><table border="0" cellpadding="4" cellspacing="1" width="100%">
<tr bgcolor="'.$config['site']['vdarkborder'].'">
<td class="whites"><b>Rank</b></td>
<td width="75%" class="whites"><b>Name</b></td>
<td width="10%" class="whites"><b><center>Level</center></b></td>';

if ($list == "experience") {
    $main_content .= '<td width="10%" class="whites"><b><center>Experience</center></b></td>
    <td width="10%" class="whites"><b><center>Resets</center></b></td>';
}

$main_content .= '</tr>';

$number_of_rows = 0;

foreach ($skills as $skill) {
    $value = $list == "magic" ? $skill->getMagLevel() : ($list == "experience" ? $skill->getLevel() : $skill->getScore());
    $bgcolor = (($number_of_rows++ % 2 == 1) ? $config['site']['darkborder'] : $config['site']['lightborder']);

    $main_content .= '<tr bgcolor="'.$bgcolor.'">
    <td style="text-align:right">'.($offset + $number_of_rows).'. </td>
    <td><a href="?subtopic=characters&name='.urlencode($skill->getName()).'">'.($skill->getOnline() > 0 ? "<font color=\"green\">".htmlspecialchars($skill->getName())."</font>" : "<font color=\"red\">".htmlspecialchars($skill->getName())."</font>").'</a><br><small>'.$skill->getLevel().' '.htmlspecialchars(Website::getVocationName($skill->getVocation())).'</small></td>
    <td><center>'.$value.'</center></td>';

    if ($list == "experience") {
        $main_content .= '<td><center>'.$skill->getExperience().'</center></td>';

        $main_content .= '<td><center>'.$skill->getResets().'</center></td>'; 
    }

    $main_content .= '</tr>';
}


$main_content .= '</table>';

$main_content .= '<table border="0" cellpadding="4" cellspacing="1" width="100%">
<tr bgcolor="'.$config['site']['vdarkborder'].'">
<td class="whites" colspan="2"><center><b>Choose a skill</b></center></td>
</tr>
<tr bgcolor="'.$config['site']['lightborder'].'">
<td style="text-align: center;">
<a href="?subtopic=highscores&list=experience" class="size_xs">Experience</a><br>
<a href="?subtopic=highscores&list=magic" class="size_xs">Magic</a><br>
<a href="?subtopic=highscores&list=shield" class="size_xs">Shielding</a><br>
<a href="?subtopic=highscores&list=distance" class="size_xs">Distance</a><br>
<a href="?subtopic=highscores&list=club" class="size_xs">Club</a><br>
<a href="?subtopic=highscores&list=sword" class="size_xs">Sword</a><br>
<a href="?subtopic=highscores&list=axe" class="size_xs">Axe</a><br>
<a href="?subtopic=highscores&list=fist" class="size_xs">Fist</a><br>
<a href="?subtopic=highscores&list=fishing" class="size_xs">Fishing</a><br>
<a href="?subtopic=highscores&list=reset" class="size_xs">Resets</a><br>
</td>
</tr>
</table>';

E depois vá em htdocs/classes/player.php

e procure por essa linha.


	public function loadStorages()
	{
		$this->storages = array();
		// load all
		$storages = $this->getDatabaseHandler()->query('SELECT ' . $this->getDatabaseHandler()->fieldName('player_id') . ', ' . $this->getDatabaseHandler()->fieldName('key') . 
			', ' . $this->getDatabaseHandler()->fieldName('value') . ' FROM ' .$this->getDatabaseHandler()->tableName('player_storage') .
			' WHERE ' . $this->getDatabaseHandler()->fieldName('player_id') . ' = ' . $this->getDatabaseHandler()->quote($this->data['id']))->fetchAll();
		foreach($storages as $storage)
		{
			$this->storages[$storage['key']] = $storage['value'];
		}
	}

É só adicionar abaixo e salvar. Pronto, o seu ranking com resets está pronto.


public function getResets()
{
    $result = $this->getDatabaseHandler()->query('SELECT resets FROM ' . $this->getDatabaseHandler()->tableName('players') . 
        ' WHERE id = ' . $this->getDatabaseHandler()->quote($this->data['id']))->fetch();

    if ($result) {
        return (int)$result['resets'];
    } else {
        $this->getDatabaseHandler()->execute('INSERT INTO ' . $this->getDatabaseHandler()->tableName('players') . 
            ' (id, resets) VALUES (' . $this->getDatabaseHandler()->quote($this->data['id']) . ', 0)' .
            ' ON DUPLICATE KEY UPDATE resets = 0'); 
        return 0; 
    }
}

Depois, não se esqueça de dar REP e marcar como solução :)

apareceu foi esse erro agora

Fatal error: Cannot redeclare Player::getResets() in C:\xampp\htdocs\classes\player.php on line 310

Erro fatal : Constante de classe indefinida 'SKILL__RESET' em C:\xampp\htdocs\pages\highscores.php na linha 47

 

 

 

Link para o post
Compartilhar em outros sites

Você adicionou corretamente?

13 minutos atrás, Gatinha Pirada disse:

'SKILL__RESET

Desculpe, houve outro arquivo. Esqueci de postar. Então, vá em htdocs/classes/highscores.php

e procure por essa linha.

const SKILL__LEVEL = 8;

é so adicione baixo.

const SKILL__RESET = 9;

 

Link para o post
Compartilhar em outros sites
43 minutos atrás, Mateus Robeerto disse:

Você adicionou corretamente?

Desculpe, houve outro arquivo. Esqueci de postar. Então, vá em htdocs/classes/highscores.php

e procure por essa linha.


const SKILL__LEVEL = 8;

é so adicione baixo.


const SKILL__RESET = 9;

 

continua dando esse erro

Fatal error: Cannot redeclare Player::getResets() in C:\xampp\htdocs\classes\player.php on line 310

Link para o post
Compartilhar em outros sites

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

  • Estatísticas dos Fóruns

    96851
    Tópicos
    519617
    Posts



×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo