Ir para conteúdo

Featured Replies

Postado
  • Este é um post popular.

Bom, hoje fiquei um bom tempo para achar este conteúdo que eu acho que vale a pena estar neste fórum... Eu achei ele neste fórum porém o tópico que ele foi postado esta tudo bagunçado contendo apenas CTRL+C e CTRL+V(este aqui)...

--------------------------------------------------------------------------------------------------------------------

A função deste código é mostrar em uma pagina de seu site um ranking em que mostra quem matou a maior quantidade de determinados monstros...  Eu particularmente acho muito bom este sistema.

 

Imagem de exemplo:

126690662154.png

--------------------------------------------------------------------------------------------------------------------

 

Crie um arquivo dentro da pasta htdocs com o nome countKill.php e adicione isso dentro:

<?php
/* Scrip by zonet */
$kills = $config['site']['creatureKills'];
$limit = $config['site']['creatureKillShowLimit'];
$main_content .= '<table border="0px" cellspacing="1px" cellpadding="4px" width="100%">
            <tr bgcolor="#505050" style="color: white;"><th width="10%">Creature</th><th>Creature name</th><th>Most Killer ( '.$limit.' )</th></tr>';
$row = 1;
    foreach($kills as $name => $storage) {
    $qa = $SQL->query('SELECT `player_storage`.`player_id`, `player_storage`.`key`, `player_storage`.`value` AS `value`, `players`.`id`, `players`.`name` AS `name` FROM `player_storage` LEFT JOIN `players` ON `player_storage`.`player_id` = `players`.`id` WHERE `player_storage`.`key` = '.$storage.' ORDER BY ABS(value) DESC LIMIT '.$limit)->fetchAll();
    $color = ( $row % 2 ? $config['site']['darkborder'] : $config['site']['lightborder']);
    $row++;
    $main_content .= '<tr bgcolor="'.$color.'"><td><img src="/images/monsters/'.(str_replace(" ", "" , $name)).'.gif"></td><td width="20%" style="font-size: 13pt; font-weight: bold; color: darkorange;"><center>'.(ucfirst($name)).'</center></td><td>';
        $a = 0;
        foreach( $qa as $q )
        {
            $a++;
            if($a == 1)
                $main_content .= '<font color="green">';
            if($a == $limit)
                $main_content .= '<font color="red">';
            if($a == $limit/2)
                $main_content .= '<font color="darkorange">';

            $main_content .= '<b>'.$a.'. Name:</b> <a href="?subtopic=characters&name='.urlencode($q['name']).'">'.$q['name'].'</a> (Kills:  '.$q['value'].') </font></font></font><br />';
        }
    }
    $main_content .= '</td></table>';
?>

Em htdocs/config abra o arquivo config.php e adicione a seguinte linha no final:

$config['site']['creatureKillShowLimit'] = 6;
$config['site']['creatureKills'] = array('dragon' => 9541, 'dragon lord' => 9542, 'frost dragon' => 9543, 'wyrm' => 9544, 'demon' => 9545);

Agora abra o arquivo index.php que fica dentro da pasta htdocs e logo abaixo desta parte:

	case "killstatistics";
                $topic = "Last Kills";
                $subtopic = "killstatistics";
                include("killstatistics.php");
	break;  

Adicione isso:

	case "countkill";
                $topic = "Count Kills";
                $subtopic = "countkill";
                include("countKill.php");
	break;	

Em htdocs/layouts/tibiacom abra o arquivo layouts.php e logo abaixo disto:

<a href='index.php?subtopic=killstatistics'>
  <div id='submenu_killstatistics' class='Submenuitem' onMouseOver='MouseOverSubmenuItem(this)' onMouseOut='MouseOutSubmenuItem(this)'>
    <div class='LeftChain' style='background-image:url(<?PHP echo "$layout_name"; ?>/images/general/chain.gif);'></div>
    <div id='ActiveSubmenuItemIcon_killstatistics' class='ActiveSubmenuItemIcon' style='background-image:url(<?PHP echo "$layout_name"; ?>/images/menu/icon-activesubmenu.gif);'></div>
    <div class='SubmenuitemLabel'>Last Kills</div>
    <div class='RightChain' style='background-image:url(<?PHP echo "$layout_name"; ?>/images/general/chain.gif);'></div>
  </div>
</a>

Adicione isso:

<a href='index.php?subtopic=countkill'>
  <div id='submenu_countkill' class='Submenuitem' onMouseOver='MouseOverSubmenuItem(this)' onMouseOut='MouseOutSubmenuItem(this)'>
    <div class='LeftChain' style='background-image:url(<?PHP echo "$layout_name"; ?>/images/general/chain.gif);'></div>
    <div id='ActiveSubmenuItemIcon_killstatistics' class='ActiveSubmenuItemIcon' style='background-image:url(<?PHP echo "$layout_name"; ?>/images/menu/icon-activesubmenu.gif);'></div>
    <div class='SubmenuitemLabel'>Count Kills</div>
    <div class='RightChain' style='background-image:url(<?PHP echo "$layout_name"; ?>/images/general/chain.gif);'></div>
  </div>
</a>

Bom a parte do website esta pronta, vamos para o servidor agora!

Em creaturescripts/scripts crie um arquivo com o nome count.lua e adicione isso dentro:

local monsters = {
["dragon"] = 9541,
["dragon lord"] = 9542,
["frost dragon"] = 9543,
["wyrm"] = 9544,
["demon"] = 9545,
}

function onKill(cid, target)
if(isPlayer(target) ~= true and isPlayer(cid)) then
local name = getCreatureName(target)
local monster = monsters[string.lower(name)]
if(monster) then
local killedMonsters = getPlayerStorageValue(cid, monster)
if(killedMonsters < 0) then
killedMonsters = 1
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You killed " .. killedMonsters .. " " .. name .. "'s.")
setPlayerStorageValue(cid, monster, killedMonsters + 1)
end
end
return true
end

Em creaturescripts abra o arquivo creaturescripts.xml e adicione isso dentro:

<event type="kill" name="countKill" event="script" value="count.lua"/>

Em creaturescripts/scripts abra o arquivo login.lua e adicione esta tag:

registerCreatureEvent(cid, "countKill")

Pronto, o sistema foi instalado, agora vamos configurar!

Para adicionar novos monstros basta modificar esta parte no código lua em creaturescripts:

local monsters = {
["dragon"] = 9541,
["dragon lord"] = 9542,
["frost dragon"] = 9543,
["wyrm"] = 9544,
["demon"] = 9545,
}

E nesta parte em layouts.php

$config['site']['creatureKillShowLimit'] = 6;
$config['site']['creatureKills'] = array('dragon' => 9541, 'dragon lord' => 9542, 'frost dragon' => 9543, 'wyrm' => 9544, 'demon' => 9545);

Tópico original: Aqui

Créditos: Zonet

Editado por AnneMotta (veja o histórico de edições)

16/11/2014

23/11/2014

 

RIP AnneMotta 21/01/2012 - 15/01/2014

Liga das lendas: DIAMOND É A META

6qpqBbJ.png

  • Respostas 7
  • Visualizações 1.9k
  • Created
  • Última resposta

Top Posters In This Topic

  • 3 months later...
Postado

este é o meu index.php...

<?php
 
// comment to show E_NOTICE [undefinied variable etc.], comment if you want make script and see all errors
error_reporting(E_ALL ^ E_STRICT ^ E_NOTICE);
 
// true = show sent queries and SQL queries status/status code/error message
define('DEBUG_DATABASE', false);
 
define('INITIALIZED', true);
 
// if not defined before, set 'false' to load all normal
if(!defined('ONLY_PAGE'))
define('ONLY_PAGE', false);
 
// check if site is disabled/requires installation
include_once('./system/load.loadCheck.php');
 
// fix user data, load config, enable class auto loader
include_once('./system/load.init.php');
 
// DATABASE
include_once('./system/load.database.php');
if(DEBUG_DATABASE)
Website::getDBHandle()->setPrintQueries(true);
// DATABASE END
 
// LOGIN
if(!ONLY_PAGE)
include_once('./system/load.login.php');
// LOGIN END
 
// COMPAT
// some parts in that file can be blocked because of ONLY_PAGE constant
include_once('./system/load.compat.php');
// COMPAT END
 
// LOAD PAGE
include_once('./system/load.page.php');
// LOAD PAGE END
 
// LAYOUT
// with ONLY_PAGE we return only page text, not layout
if(!ONLY_PAGE)
include_once('./system/load.layout.php');
else
echo $main_content;
// LAYOUT END

Editado por DamianMeneses (veja o histórico de edições)

  • 1 month later...

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

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo