Latest Shouts In The Shoutbox -- View The Shoutbox · Rules
Jcink -- mmm.
Dan -- ehh not that great
card123 -- g2g ttyal =]
card123 -- Check out my latest mod, its amazing!! its in the addon section
card123 -- i dont have a problem with members logging in, i have a problem getting them to post lol
Skullmonkey -- im lucky if someone even logs in on mine tongue.gif
Corey.B -- I had a really active board that got up to about 40 active members a day. Then I kinda messed it up lol

[ Smilies | BBCodes ]

Pages: (3) [1] 2 3  ( Go to first unread post ) Reply to this topic Start new topic Start Poll

> Game Ratings Mod
Architect
 Posted: April 14, 2009 05:02 pm

Quest Points: 220

Group: Member

Posts: 3058

Credits: 20

Joined: July 10, 2006

Age: >1
Gender: Male
Location: England, UK
Status: Offline




This is a ratings mod for the Arcade which will allow the user to rate a game 1 to 5 stars.

Once install this mod should produce something that looks like this:
user posted image

Note: That I assume you've got a default, unedited version of Arcade.php, if you have edited it, well then good luck to you.

Step 1:
Download the attached file and copy the /ratings folder to the root directory of your Arcade.

Then go to your arcade's directory /ratings/rate_install.php.
e.g. If your arcade url is http://example.com/arcade/Arcade.php
go to http://example.com/arcade/ratings/rate_install.php

NOTICE how it's /ratings/rate_install.php if you have /ratings/ratings/rate_install.php then you need to move all the files up to the higher ratings folder.

You can delete this file once you're done with it.


Ok let's open up Arcade.php

A useful thing to do is to ctrl+f and paste in the content in the find box to find the correct place to add the code. For example for the following put the line
CODE
if($_GET['action']=="emotes") {
in the find box.

Step 2:
Find:
CODE
<?PHP
if($_GET['action']=="emotes") {


Add ABOVE the following:

CODE

<script type='text/javascript'>
var key = '<?PHP echo $key; ?>';
</script>
<script src="./ratings/ratings.js" type="text/javascript"></script>


Step 3:
Find:
CODE

while($g=mysql_fetch_array($catquer)){


Add ABOVE the following:
CODE

// Rating Code Section 1 BEGIN
// I'm too scared to try and edit the $catquer query directly, that is one quest that's just...
$gameIds = array();
while($r=mysql_fetch_row($catquer)){
$gameIds[] = $r[0]; // We're just interested in the game Id.
}

// Reset the data pointer. The first one is the random game... so skip that.
if(mysql_num_rows($catquer) !== 1){
mysql_data_seek($catquer, 1);
}

$gameIds_str =  "'" . implode("', '", $gameIds) . "'";

$result = run_query('SELECT GameID, TotalScore, NoOfVoters  FROM phpqa_rating WHERE GameID IN (' . $gameIds_str . ') ');
$ratings = array();

while($r=mysql_fetch_row($result)){
// Create an array where the key is the gameid and the value the game's rating.
$ratings[$r[0]] = round($r[1] / $r[2]);
}
// Rating Code Section 1 END


Step 4:
Find:
CODE

if($_GET['fav']) $fav_action="<br /><a href='Arcade.php?action=fav&game=$g[0]&favtype=remove&akey=$key&fav=1'>[Remove favorite]</a>";
}


Add BELOW the following:
CODE

// Rating Code Section 2 BEGIN

if(array_key_exists($g[0], $ratings)){
 $rating = $ratings[$g[0]];
} else {
 $rating = 0;
}

$rating_html = ''; // Clear the previous entry.
$rating_html .= '<div id="rate' . $g[0] . '">';

for($x=0;$x<5;$x++){
 $javascript_bit = (isset($_COOKIE['phpqa_user_c'])) ?
   'onclick="rate(' . $x . ',  \'' . $g[0] . '\')" onmouseover="rateImage(\'' . $g[0] . '\', ' . $x . ', false)" onmouseout="rateImage(\'' . $g[0] . '\', ' . $x . ', true)" ' : '';
 $rating_html .=  '<img src="./ratings/rate' . (($x<$rating) ? '1' : '0') . '.gif" alt="' . ($x+1) . '" ' . $javascript_bit . '>';
}

$rating_html .= '</div>';

// Rating Code Section 2 END


Step 5:
Find (It should be the next line down from the code you've just pasted in):
CODE
echo "<div class='viewedtimes'>Played ".$g[times_played]." Time".($g[times_played]!=1?"s":"")."{$fav_action}</div></td><td class='arcade1' valign='top' align='center'><img alt='image' src='$crowndir/crown1.gif' /><br /><b>".$g[Champion_score]."</b><br />".($g[Champion_name]?"<a href='Arcade.php?action=profile&amp;user=$g[Champion_name]'>$g[Champion_name]</a>":"<b>------------</b>")."<br /><a href='Arcade.php?id=$g[0]'>View Highscores</a></td></tr></table></div><br />";


Now, we're going to alter this line.
Find:
CODE
{$fav_action}

Add AFTER:
CODE
<br/>{$rating_html}


Now close and save Arcade.php and you should be done!

If you want to display the game rating on the game's highscore page then follow these additional steps.

Find:
CODE

if (!$gameinfo) {
header("Location: index.php");
die();
}


Add after:
CODE

// Rating in highscore description code BEGIN
$f = array();
$f[0] = $gameinfo['gameid'];
$query = 'SELECT GameID, TotalScore, NoOfVoters  FROM phpqa_rating WHERE GameID = \'' . $f[0] . '\' LIMIT 1';
$result = run_query($query);

if(mysql_num_rows($result) !== 0){
$r=mysql_fetch_row($result);
$rating = round($r[1] / $r[2]);
} else {
$rating = 0;
}

$rating_html = ''; // Clear the previous entry.
$rating_html .= '<div id="rate' . $f[0] . '">';

for($x=0;$x<5;$x++){
(isset($_COOKIE['phpqa_user_c'])) ?
$javascript_bit = 'onclick="rate(' . $x . ',  \'' . $f[0] . '\')" onmouseover="rateImage(\'' . $f[0] . '\', ' . $x . ', false)" onmouseout="rateImage(\'' . $f[0] . '\', ' . $x . ', true)" ' : '';
$rating_html .=  '<img src="./ratings/rate' . (($x<$rating) ? '1' : '0') . '.gif" alt="' . ($x+1) . '" ' . $javascript_bit . '>';
}

$rating_html .= '</div>';

// Rating in highscore description code END


Then find:
CODE

<? echo "Played ".$gameinfo[times_played]." Time".($gameinfo[times_played]!=1?"s":""); ?>


and add directly after:
CODE

<br /><?PHP echo $rating_html; ?>


The End.

This post has been edited by Architect on May 14, 2009 08:23 pm

Attached File ( Number of downloads: 50 )
Attached File  ratings.zip


--------------------
user posted image

The Online PC Pitstop

Todo:
*Finish Connect4
*Figure out how to get my time machine working without screwing up the future again.
Done:
*Completed Reputation System for TFBB
*Release ratings mod for PHPQA
New Posts
^
timewind
 Posted: April 14, 2009 11:26 pm

Virtual Research

Group: Member

Posts: 402

Credits: 665

Joined: January 07, 2008

Age: 33
Gender: Male
Location: ohio
Status: Offline




the Attached File is bunk

Warning:
No Archives Found


--------------------
PlanetPlayersClub - Clique Adult League & Arcade
Over 2Million Games played!... No Ads!..as of yet?¿
And Still The Largest PHP Quick Arcade Flash Site!
AiM: redworminc
user posted image
New Posts
^
Architect
 Posted: April 15, 2009 01:02 am

Quest Points: 220

Group: Member

Posts: 3058

Credits: 20

Joined: July 10, 2006

Age: >1
Gender: Male
Location: England, UK
Status: Offline




It works for me, can you double check and try downloading the files again?
If it doesn't work what are you using the extract the archive?

This post has been edited by Architect on April 15, 2009 01:02 am


--------------------
user posted image

The Online PC Pitstop

Todo:
*Finish Connect4
*Figure out how to get my time machine working without screwing up the future again.
Done:
*Completed Reputation System for TFBB
*Release ratings mod for PHPQA
New Posts
^
timewind
 Posted: April 15, 2009 01:39 am

Virtual Research

Group: Member

Posts: 402

Credits: 665

Joined: January 07, 2008

Age: 33
Gender: Male
Location: ohio
Status: Offline




QUOTE (Architect @ April 15, 2009 01:02 am)
It works for me, can you double check and try downloading the files again?
If it doesn't work what are you using the extract the archive?

WinZip
WinRAR

Posted Image (Reduced size. Click thumbnail to expand)
User posted image


--------------------
PlanetPlayersClub - Clique Adult League & Arcade
Over 2Million Games played!... No Ads!..as of yet?¿
And Still The Largest PHP Quick Arcade Flash Site!
AiM: redworminc
user posted image
New Posts
^
Architect
 Posted: April 15, 2009 02:06 am

Quest Points: 220

Group: Member

Posts: 3058

Credits: 20

Joined: July 10, 2006

Age: >1
Gender: Male
Location: England, UK
Status: Offline




I can open it with winrar. If you're in windows try right clicking and extract all.
If it doesn't work. Then do other zips work and can anyone else confirm this problem?

Thanks.


--------------------
user posted image

The Online PC Pitstop

Todo:
*Finish Connect4
*Figure out how to get my time machine working without screwing up the future again.
Done:
*Completed Reputation System for TFBB
*Release ratings mod for PHPQA
New Posts
^
timewind
 Posted: April 15, 2009 02:27 am

Virtual Research

Group: Member

Posts: 402

Credits: 665

Joined: January 07, 2008

Age: 33
Gender: Male
Location: ohio
Status: Offline




done everything from a-z & 1-10... even re-downloaded the file.. samething... Never got that warning before...


--------------------
PlanetPlayersClub - Clique Adult League & Arcade
Over 2Million Games played!... No Ads!..as of yet?¿
And Still The Largest PHP Quick Arcade Flash Site!
AiM: redworminc
user posted image
New Posts
^
Architect
 Posted: April 15, 2009 01:00 pm

Quest Points: 220

Group: Member

Posts: 3058

Credits: 20

Joined: July 10, 2006

Age: >1
Gender: Male
Location: England, UK
Status: Offline




Here's a Rar for you to try then:
http://www.fileqube.com/file/OzcFeTP188213

Hopefully it'll work.

This post has been edited by Architect on April 15, 2009 07:20 pm


--------------------
user posted image

The Online PC Pitstop

Todo:
*Finish Connect4
*Figure out how to get my time machine working without screwing up the future again.
Done:
*Completed Reputation System for TFBB
*Release ratings mod for PHPQA
New Posts
^
Jcink
 Posted: April 15, 2009 04:41 pm

The Final Boss

Group: Admin

Posts: 16248

Credits: 9600

Joined: June 26, 2006

Age: 20
Gender: Male
Location: New Jersey, USA
Status: Online




The download file works just fine for me too. Great work, I can't wait to test it.


--------------------
http://jcink.com
[ JFB | phpQuickArcade | Air-Proxy.com | ircd.jcink.com #jcink.com ]
admin@jcink.com
New Posts
^
RTl93
 Posted: April 15, 2009 04:43 pm

Advanced Member

Group: Member

Posts: 94

Credits: 275

Joined: December 15, 2007

Age: 19
Gender: Male
Location: N/A
Status: Offline




Lol my arcade.php has a lot of edits so its not gonna work for me.
New Posts
^
Jcink
 Posted: April 15, 2009 04:49 pm

The Final Boss

Group: Admin

Posts: 16248

Credits: 9600

Joined: June 26, 2006

Age: 20
Gender: Male
Location: New Jersey, USA
Status: Online




Unless you totally hacked the entire thing to death, these are some very basic areas of the arcade to cut and paste these codes in... did you actually try it to see if you can find the codes he showed?


--------------------
http://jcink.com
[ JFB | phpQuickArcade | Air-Proxy.com | ircd.jcink.com #jcink.com ]
admin@jcink.com
New Posts
^
RTl93
 Posted: April 15, 2009 04:54 pm

Advanced Member

Group: Member

Posts: 94

Credits: 275

Joined: December 15, 2007

Age: 19
Gender: Male
Location: N/A
Status: Offline




Yeah. For example the first code I was supposed to find I couldnt find in it. I've only edited to install full screen mode, random games, top played games.
New Posts
^
Architect
 Posted: April 15, 2009 05:49 pm

Quest Points: 220

Group: Member

Posts: 3058

Credits: 20

Joined: July 10, 2006

Age: >1
Gender: Male
Location: England, UK
Status: Offline




Send me your Arcade.php and I'll take a look.


--------------------
user posted image

The Online PC Pitstop

Todo:
*Finish Connect4
*Figure out how to get my time machine working without screwing up the future again.
Done:
*Completed Reputation System for TFBB
*Release ratings mod for PHPQA
New Posts
^
RTl93
 Posted: April 15, 2009 06:05 pm

Advanced Member

Group: Member

Posts: 94

Credits: 275

Joined: December 15, 2007

Age: 19
Gender: Male
Location: N/A
Status: Offline




Here it is.

Attached File ( Number of downloads: 34 )
Attached File  Arcade.php
New Posts
^
Architect
 Posted: April 15, 2009 06:15 pm

Quest Points: 220

Group: Member

Posts: 3058

Credits: 20

Joined: July 10, 2006

Age: >1
Gender: Male
Location: England, UK
Status: Offline




All the lines you need to find are in that file. I don't know what text editor you're using. I'd recommend Notepad++. But failing that try wordpad.


--------------------
user posted image

The Online PC Pitstop

Todo:
*Finish Connect4
*Figure out how to get my time machine working without screwing up the future again.
Done:
*Completed Reputation System for TFBB
*Release ratings mod for PHPQA
New Posts
^
RTl93
 Posted: April 15, 2009 06:50 pm

Advanced Member

Group: Member

Posts: 94

Credits: 275

Joined: December 15, 2007

Age: 19
Gender: Male
Location: N/A
Status: Offline




Ok lol thanks well I added them all and I am getting a database error. Here's my site.
http://rtlarcade.vh1realitycheck.com/Arcade.php

This post has been edited by RTl93 on April 15, 2009 06:50 pm
New Posts
^
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

[+]Pages: (3) [1] 2 3  Reply to this topic Start new topic Start Poll

 


 



[ Script Execution time: 0.0631 ]   [ 22 queries used ]   [ GZIP Disabled ]   [ Server Load: 1.05 ]