Jump to content
Close
Sign in to follow this  
Micheel15

Website Highscores para reset system

Recommended Posts

OTX 8.60

GALERA, procurei bastante aqui no TK e não obtive sucesso em encontrar um HIGHSCORES.php que funcione no meu gesior

vou deixar uma imagem da parte de highscores, e o codigo, e tbm vou deixar o script do sistema de RESET que eu uso

que no caso é por NPC, se alguem puder me ajudar a solucionar e coloca um sistema de reset na parte de HIGHSCORES ia me ajudar mt

 

imagem abaixo :

 

Spoiler

C:\Users\MicheeL\Desktop\Servidor1\data\npc\scripts\Reseter.lua

 


local config = {
	minlevel = 1500, --- level inical para resetar
	price = 40000000, --- preço inicial para resetar
	newlevel = 20, --- level após reset
	priceByReset = 15000000, --- preço acrescentado por reset
	percent = 10, ---- porcentagem da vida/mana que você terá ao resetar (em relação à sua antiga vida total)
	maxresets = 50,
	levelbyreset = 200 --- quanto de level vai precisar a mais no próximo reset
}
--- end config

function getResets(uid)
	resets = getPlayerStorageValue(uid, 378378)
	if resets < 0 then
		resets = 0
	end
	return resets
end

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
 
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink()                  npcHandler:onThink()                  end
 
function creatureSayCallback(cid, type, msg)
	if not npcHandler:isFocused(cid) then
		return false
	end
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

	function addReset(cid)
		if(npcHandler:isFocused(cid)) then
			npcHandler:releaseFocus(cid)
		end
		
		talkState[talkUser] = 0
		resets = getResets(cid)
		setPlayerStorageValue(cid, 378378, resets+1) 
		doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
		local hp = getCreatureMaxHealth(cid)
		local resethp = hp*(config.percent/100)
		setCreatureMaxHealth(cid, resethp)
		local differencehp = (hp - resethp)
		doCreatureAddHealth(cid, -differencehp)
		local mana = getCreatureMaxMana(cid)
		local resetmana = mana*(config.percent/100)
		setCreatureMaxMana(cid, resetmana)
		local differencemana = (mana - resetmana)
		doCreatureAddMana(cid, -differencemana)
		doRemoveCreature(cid)		
		local description = resets+1
		db.query("UPDATE `players` SET `description` = ' [Reset: "..description.."]' WHERE `players`.`id`= ".. playerid .."")
		db.query("UPDATE `players` SET `level`="..config.newlevel..",`experience`= 0 WHERE `players`.`id`= ".. playerid .."")
		return true
	end
	
	local newPrice = config.price + (getResets(cid) * config.priceByReset)
	local newminlevel = config.minlevel + (getResets(cid) * config.levelbyreset)

	if msgcontains(msg, 'reset') then
		if getResets(cid) < config.maxresets then
			selfSay('You want to reset your character? It will cost '..newPrice..' gp\'s!', cid)
			talkState[talkUser] = 1
		else
			selfSay('You already reached the maximum reset level!', cid)
		end
		
	elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
		if getPlayerMoney(cid) < newPrice then
			selfSay('Its necessary to have at least '..newPrice..' gp\'s for reseting!', cid)
		elseif getPlayerLevel(cid) < newminlevel then
			selfSay('The minimum level for reseting is '..newminlevel..'!', cid)
		else
			doPlayerRemoveMoney(cid,newPrice)
			playerid = getPlayerGUID(cid)
			addEvent(function()
				if isPlayer(cid) then
					addReset(cid)
				end
			end, 3000)
			local number = getResets(cid)+1
			local msg ="---[Reset: "..number.."]-- You have reseted!  You'll be disconnected in 3 seconds."
			doPlayerPopupFYI(cid, msg) 
			talkState[talkUser] = 0
			npcHandler:releaseFocus(cid)
		end
		talkState[talkUser] = 0
	elseif(msgcontains(msg, 'no')) and isInArray({1}, talkState[talkUser]) == TRUE then
		talkState[talkUser] = 0
		npcHandler:releaseFocus(cid)
		selfSay('Ok.', cid)
	elseif msgcontains(msg, 'quantity') then
		selfSay('You have a total of '..getResets(cid)..' reset(s).', cid)
		talkState[talkUser] = 0
	end
	return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

 

 

Spoiler

C:\xampp\htdocs\pages\highscores.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;
	default:
		$id=Highscores::SKILL__LEVEL;
		$list_name='Experience';
		break;
}
if(count($config['site']['worlds']) > 1)
{
	foreach($config['site']['worlds'] as $idd => $world_n)
	{
		if($idd == (int) $_REQUEST['world'])
		{
			$world_id = $idd;
			$world_name = $world_n;
		}
	}
}
if(!isset($world_id))
{
	$world_id = 0;
	$world_name = $config['server']['serverName'];
}
if(count($config['site']['worlds']) > 1)
{
	$main_content .= '<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%><TR><TD></TD><TD>
	<FORM ACTION="" METHOD=get><INPUT TYPE="hidden" NAME="subtopic" VALUE="highscores"><TABLE WIDTH=100% BORDER=0 CELLSPACING=1 CELLPADDING=4><TR><TD BGCOLOR="'.$config['site']['vdarkborder'].'" CLASS=white><B>World Selection</B></TD></TR><TR><TD BGCOLOR="'.$config['site']['darkborder'].'">
	<TABLE BORDER=0 CELLPADDING=1><TR><TD>Best players on world:</TD><TD><SELECT SIZE="1" NAME="world">';
	foreach($config['site']['worlds'] as $wid => $world_n)
	{
		if($wid == $world_id)
			$main_content .= '<OPTION VALUE="'.htmlspecialchars($wid).'" selected="selected">'.htmlspecialchars($world_n).'</OPTION>';
		else
			$main_content .= '<OPTION VALUE="'.htmlspecialchars($wid).'">'.htmlspecialchars($world_n).'</OPTION>';
	}
	$main_content .= '</SELECT> </TD><TD><INPUT TYPE="image" NAME="Submit" ALT="Submit" SRC="'.$layout_name.'/images/buttons/sbutton_submit.gif">
		</TD></TR></TABLE></TABLE></FORM></TABLE>';
}
$offset = $page * 50;
$skills = new Highscores($id, 50, $page, $world_id, $vocation);
$main_content .= '<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%><TR><TD></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%></TABLE><TABLE BORDER=0 CELLPADDING=4 CELLSPACING=1 WIDTH=100%><TR BGCOLOR="'.$config['site']['vdarkborder'].'"><TD CLASS=whites><B><centeR>#</center></B></TD><TD CLASS=whites><b>Outfit</b></TD><TD WIDTH=75% CLASS=whites><B>Name</B></TD><TD WIDTH=15% CLASS=whites><b><center>Level</center></B></TD>';
if($list == "experience")
	$main_content .= '<TD CLASS=whites><b><center>Experience</center></B></TD>';
//$main_content .= '</TR><TR>';
$main_content .= '</TR>';
$number_of_rows = 0;
foreach($skills as $skill)
{
	if($list == "magic")
		$value = $skill->getMagLevel();
	elseif($list == "experience")
		$value = $skill->getLevel();
	else
		$value = $skill->getScore();
	$bgcolor = (($number_of_rows++ % 2 == 1) ?  $config['site']['darkborder'] : $config['site']['lightborder']);
	$main_content .= '<tr bgcolor="'.$bgcolor.'"><td style="text-align:center">'.($offset + $number_of_rows).'.</td><TD><img src="' . $config['site']['outfit_images_url'] . '?id=' . $skill->getLookType() . '&addons=' . $skill->getLookAddons() . '&head=' . $skill->getLookHead() . '&body=' . $skill->getLookBody() . '&legs=' . $skill->getLookLegs() . '&feet=' . $skill->getLookFeet() . '" alt="" /></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(), $skill->getPromotion())).'</small></td><td><center>'.$value.'</center></td>';
	if($list == "experience")
		$main_content .= '<td><center>'.$skill->getExperience().'</center></td>';
	$main_content .= '</tr>';
}
$main_content .= '</TABLE><TABLE BORDER=0 CELLPADDING=4 CELLSPACING=1 WIDTH=100%>';
if($page > 0)
	$main_content .= '<TR><TD WIDTH=100% ALIGN=right VALIGN=bottom><A HREF="?subtopic=highscores&list='.urlencode($list).'&page='.($page - 1).'&vocation=' . urlencode($vocation) . '&world=' . urlencode($world_id) . '" CLASS="size_xxs">Previous Page</A></TD></TR>';
if($page < 50)
	$main_content .= '<TR><TD WIDTH=100% ALIGN=right VALIGN=bottom><A HREF="?subtopic=highscores&list='.urlencode($list).'&page='.($page + 1).'&vocation=' . urlencode($vocation) . '&world=' . urlencode($world_id) . '" CLASS="size_xxs">Next Page</A></TD></TR>';
$main_content .= '</TABLE></TD><TD WIDTH=5%></TD><TD WIDTH=15% VALIGN=top ALIGN=right><TABLE BORDER=0 CELLPADDING=4 CELLSPACING=1><TR BGCOLOR="'.$config['site']['vdarkborder'].'"><TD CLASS=whites><B>Choose a skill</B></TD></TR><TR BGCOLOR="'.$config['site']['lightborder'].'"><TD><A HREF="?subtopic=highscores&list=experience&world='.$world_id.'" CLASS="size_xs">Experience</A><BR><A HREF="?subtopic=highscores&list=magic&world='.$world_id.'" CLASS="size_xs">Magic</A><BR><A HREF="?subtopic=highscores&list=shield&world='.$world_id.'" CLASS="size_xs">Shielding</A><BR><A HREF="?subtopic=highscores&list=distance&world='.$world_id.'" CLASS="size_xs">Distance</A><BR><A HREF="?subtopic=highscores&list=club&world='.$world_id.'" CLASS="size_xs">Club</A><BR><A HREF="?subtopic=highscores&list=sword&world='.$world_id.'" CLASS="size_xs">Sword</A><BR><A HREF="?subtopic=highscores&list=axe&world='.$world_id.'" CLASS="size_xs">Axe</A><BR><A HREF="?subtopic=highscores&list=fist&world='.$world_id.'" CLASS="size_xs">Fist</A><BR><A HREF="?subtopic=highscores&list=fishing&world='.$world_id.'" CLASS="size_xs">Fishing</A><BR></TD></TR></TABLE></TD><TD></TD></TR></TABLE>';

 

 

HIGHSCORES.jpg


Share this post


Link to post
Share on other sites

igual esse voce diz ?

 

http://triflex.servegame.com/?subtopic=highscores

 

dá uma olhada tambem em.

http://triflex.servegame.com/?subtopic=characters&amp;name=Drago

 

segue a teoria de como funciona esse sistema, o sistema em si nao posso passar , mas é facil,

edita o query que o highscores.php usa, poe ele pra puxar a coluna de resets do players, e depois copia as funcoes de qualquer highscore(sword, magic etc) e altera ele pra exibir por ordem na aba 'reset'

 

de quebra voce pode se basear nesse sistema pra criar o seu

http://chaitosoft.com/blog/sistema-de-reset-pagina-gesior/


Edited by mattos123 (see edit history)

Untitled-1.png.8656131ae2dbaec55df217b785d3e486.png

Share this post


Link to post
Share on other sites

Primeiramente você precisa fazer a verificação de onde está sendo salvo o valor dos resets dos players, logo depois vocÊ pode criar ou uma query de consulta para esses dados ou utilizar uma já existente no sistema.

Após isso você irá criar um novo espaço no código html para poder apresentar o resultado dessa busca. para assim depois apresentar os dados no site.



<?php

$assinatura = function($texto) {
	return $texto;
};

$assinatura('Eu ainda não tenho uma assinatura decente ):, php ♥');
?>

Meus sites.:

https://ferobraglobal.com/
https://codenome.com/
https://uam.codenome.com/

https://myci.myara.net/

 

Me ajuda no café:
http://picpay.me/ricardo.codenome

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

Open Tibia Server

Quer aprender a criar seu próprio servidor de Tibia? Então está no lugar certo, aqui você encontrará milhares de tutorias, scripts, códigos, mapas e utilitários para que você possa fazer o seu próprio servidor de Tibia partindo do zero.

Redes Sociais

Anuncie no Tibia King

Precisa de mais visibilidade em seus projetos? Quer publicidade para o seu servidor? Anuncie no Tibia King e faça sua divulgação, possuímos centenas de acessos simultâneos e milhares diários, com certeza será a sua solução! A publicação do seu anuncio é instantânea!

×
×
  • Create New...