TinyPortal

Development => Block Codes => Topic started by: Polymath on November 17, 2006, 06:01:03 PM

Title: Arcade champion block score
Post by: Polymath on November 17, 2006, 06:01:03 PM
Hi guys,

Sorry if its already here but I can't find it using the keywords search.

But anyway My champions block(the scrolling one on home page) has the scores showing wrong. Its the only block it does it in and it looks untidy and unprofessional. Its another thing in a list that I want to try and fix.  I fixed this in the arcade pages months ago. So its now only this block that needs score corrected.

what does it show?  6.00078E+06 for the million scores

heres the block code.
/*
|----------------------------------
      SMF ARCADE CHAMPS BLOCK
      by Eric Lawson
|----------------------------------
      Made for

      TinyPortal
      SMF SMF forum 1.1RC1/RC2
      SMF Arcade_1.2.4b (1.2.4 should be ok :) )
      And Works with Beta Arcade


*/


//Upload the arcade_block.gif (you can use you own gif - just name it arcade_block.gif)
//to your Themes/<themename>/images/ folder

// -- SETUP EDITS ---

$db_prefix = 'arcade_'; //edit this to your your database prefix - usually smf_
$no = 10; //number of top players to show

// --LANGUAGE EDITS --
$txtplay = "The Top Players"; // change "The Top Players" to your language
$txtwin = "Number Of Wins :";// change "Number Of Wins :" to your language
$txtlate = "Latest High Score by ";// change "Latest High Score set by" to your language
$txtwit = "with ";// change "with" to your language
$txton = "on ";// change "on" to your language

require('./Settings.php');


$link = mysql_connect($db_server, $db_user, $db_passwd);
mysql_select_db($db_name, $link);

// --START BLOCK CODE --
$content = "";  //set blank for a start

//Get newest champ or die
$sql = "SELECT m.ID_MEMBER,m.realName,g.id, g.game, g.name,g.champion_score "
. "FROM {$db_prefix}members m , {$db_prefix}games g "
. "WHERE g.champion_score > 0 AND m.ID_MEMBER=g.champion_member "
. "ORDER BY g.champion_time DESC LIMIT 0,1";

if(!($result = mysql_query($sql,$link)))
{
die("Could not get the newest champ");
}
$row = mysql_fetch_assoc($result);
mysql_free_result($result);

//newest champ details
$playerid = $row['ID_MEMBER'];
$player = $row['realName'];
$game_id = $row['id'];
$game_name = $row['name'];
$score = $row['champion_score'];

//now get the pic for the game
$ext = array('gif','GIF','png','PNG','jpg','JPG',);
$game_pic = ""; // No thumbnail for default
foreach($ext as $ex)
{
if(file_exists($boarddir. "/Games/".$row['game'].".".$ex))
{
$game_pic = $boardurl."/Games/".$row['game'].".".$ex;
}
}


//Get the 10 best players or die
$sql = "SELECT m.ID_MEMBER, m.realName, count(g.id) As cnt"
. " FROM {$db_prefix}games g, {$db_prefix}members m"
. " WHERE m.ID_MEMBER=g.champion_member"
. " GROUP BY realName "
. " ORDER BY cnt DESC LIMIT 0,{$no}";
if(!($result = db_query($sql,__FILE__,__LINE__)))
{
die("Could not get the best players");
}

$row = mysql_fetch_assoc($result);

$score_poss=0; //players position

//make the block content
$content .= "<table width=\"100%\" ><tr>
<td align=\"center\">







</td>
</tr>";

$content .= "
<tr>
<td>
<marquee behavior='scroll' align='center' direction='up' height='160' scrollamount='1' scrolldelay='50' onmouseover='this.stop()' onmouseout='this.start()'>
<br />
<div align=\"center\"><a href=\"{$scripturl}?action=arcade;sa=play;game={$game_id}\"><img src=\"{$game_pic}\" border= \"0\" /></a>
<br />{$txtlate}<br />
<a href=\"{$scripturl}?action=profile;u=$playerid\">{$player}</a><br />{$txtwit} {$score} {$txton} {$game_name}
<br />------------------<br />{$txtplay}
<br /><br /> ";
do
{
$score_poss++;
$content .= "
$score_poss -
<a href=\"{$scripturl}?action=profile;u=".$row['ID_MEMBER']."\"> ".$row['realName']."</a>
<br /> $txtwin ".$row['cnt']."
<br /><br />";
}  while ($row = mysql_fetch_assoc($result));

mysql_free_result($result);
$content .= "</marquee></div></td></tr></table>" ;

echo $content;


and if you could point me to the thread for the fix or what I need to do would me many thanks.

Thankyou.
Title: Re: Arcade champion block score
Post by: rebelrose on November 17, 2006, 06:09:20 PM
This should be in the block code snippets as it is not a TP function but a code added to a block.
Title: Re: Arcade champion block score
Post by: RoarinRow on November 17, 2006, 06:37:57 PM
Try posting the question here - http://www.smfarcade.net/index.php
Title: Re: Arcade champion block score
Post by: Polymath on November 17, 2006, 07:02:11 PM
Yeah sorry. I thought it was a TP block. I've been there and repaired the blocks in the arcade but not in my SMF/TP.

I'll put it there.
Title: Re: Arcade champion block score
Post by: Polymath on November 17, 2006, 07:06:59 PM
Remove this block topic.
Title: Re: Arcade champion block score
Post by: rebelrose on November 17, 2006, 07:19:31 PM
This topic was moved to the block snippet area Polymath. I hope you get it worked out on your site.
Title: Re: Arcade champion block score
Post by: RoarinRow on November 17, 2006, 08:01:41 PM
Here's the fix from eeek - smfarcade (http://www.smfarcade.net/index.php/topic,1811.msg12858.html#new)

Quote from: eeek on November 17, 2006, 07:44:06 PM
untested but should do the trick...

In the posted code above

Replace
$score = $row['champion_score'];

With
$score = round($row['champion_score'],2);
Title: Re: Arcade champion block score
Post by: Polymath on November 17, 2006, 08:54:58 PM
Beat me to it there RoarinRow. Just came in to post it. Lol.

Changed it at my site and as yet not tested will have to wait for another million score.

Cheers.
Title: Re: Arcade champion block score
Post by: RoarinRow on November 17, 2006, 09:35:03 PM
Quote from: Polymath on November 17, 2006, 08:54:58 PM
Beat me to it there RoarinRow. Just came in to post it. Lol.

Changed it at my site and as yet not tested will have to wait for another million score.

Cheers.

hahaha, sorry.  I applied the fix myself.    :o
Title: Re: Arcade champion block score
Post by: Polymath on November 18, 2006, 01:04:44 AM
Well good. I always thought it was an error I had.. not something everybody had.

lol