Raised This Month: $51 Target: $400
 12% 

Map Rate v0.10 (6/30)


Post New Thread Reply   
 
Thread Tools Display Modes
LocutusH
Senior Member
Join Date: Dec 2007
Location: Hungary
Old 07-31-2008 , 02:49   Re: Map Rate v0.10 (6/30)
Reply With Quote #171

Quote:
Originally Posted by uragan View Post
L 07/23/2008 - 13:583: [maprate.smx] Error establishing database connection: [2002]: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
L 07/23/2008 - 13:583: [maprate.smx] FATAL: An error occurred while connecting to the database.
L 07/23/2008 - 13:583: [SM] Plugin encountered error 25: Call was aborted
L 07/23/2008 - 13:583: [SM] Native "SetFailState" reported: An error occurred while connecting to the database.
L 07/23/2008 - 13:583: [SM] Debug mode is not enabled for "maprate.smx"
L 07/23/2008 - 13:583: [SM] To enable debug mode, edit plugin_settings.cfg, or type: sm plugins debug 27 on


game: DOD:S

I cant start it, get always errors.
You need to put that sock file in the tmp directory, as listed in the error message. I dont know why sourcemod wants it this way, but i had this error with all my mysql plugins too.
__________________
LocutusH is offline
willy1234x1
Senior Member
Join Date: Jun 2008
Old 08-02-2008 , 07:57   Re: Map Rate v0.10 (6/30)
Reply With Quote #172

I think a cvar maprate_on_mapend would be a welcome addition seeing as I and many others use the DMR and some maps have much longer times than others.
willy1234x1 is offline
willy1234x1
Senior Member
Join Date: Jun 2008
Old 08-02-2008 , 07:59   Re: Map Rate v0.10 (6/30)
Reply With Quote #173

Oh and is it possible to add a map's ratings to other pages? like have the main maprate page with all of them but taking only 1 map's rating and everything and placing it on another page and still having it update.
willy1234x1 is offline
Zuko
SourceMod Donor
Join Date: Sep 2006
Location: Poland
Old 08-02-2008 , 12:08   Re: Map Rate v0.10 (6/30)
Reply With Quote #174

maprate.phrases.txt with polish translation / maprate.phrases.txt z polskim tłumaczeniem
Attached Files
File Type: txt maprate.phrases.txt (3.7 KB, 101 views)
__________________
Zuko is offline
Send a message via ICQ to Zuko
ChillyWI
Senior Member
Join Date: Aug 2008
Old 08-11-2008 , 18:27   Re: Map Rate v0.10 (6/30)
Reply With Quote #175

Here's my clan's implementation of this:
http://yinyarr.com/Map_Ratings.aspx

I'm using a SQLite3 database instead of MySQL. It's a bit harder this way, but is still quite usable. Here's the code I used, which basically retrieves the database via FTP and then displays the data. Keep in mind I expect very little load on this page so I haven't tested any blocking or issues that arise when multiple people access the page at the same time (hence overlapping FTP downloads).

Also note that this is a big security risk if you store your admin information in the same database as the ratings, since it'll be transferred to your webhost where people could download it. Simple solutions are to separate these databases or protect the file on the server with htaccess (if available).

Code:
<html>
<head>
    <title>YinYarr Map Ratings</title>
    <style type="text/css">
        BODY  {
            background-color: #2C2A28;
            color: #FFFFFF;
            font: 9pt Calibri, Arial, san-serif;
            line-height: 140%;
        }
        .mainbar  {
            margin-top: 1px;
            height: 20px;
            clear: both;
        }
        .bar1  {
            margin-right: 5px;
            background-color: #bb3c3c;
            height: 20px;
            float: left;
        }
        .bar2  {
            margin-right: 5px;
            background-color: #a64a4d;
            height: 20px;
            float: left;
        }
        .bar3  {
            margin-right: 5px;
            background-color: #8c5b64;
            height: 20px;
            float: left;
        }
        .bar4  {
            margin-right: 5px;
            background-color: #716c7a;
            height: 20px;
            float: left;
        }
        .bar5  {
            margin-right: 5px;
            background-color: #5c798b;
            height: 20px;
            float: left;
        }
        H2  {
            font: 18pt Calibri, Arial, san-serif;
            margin-bottom: 2px;
        }
    </style>
<script type="text/javascript">
function autofitIframe(id)  {
  if (!window.opera && !document.mimeType && document.all && document.getElementById){
    parent.document.getElementById(id).style.height=this.document.body.offsetHeight+"px";
  }
  else if(document.getElementById) {
    parent.document.getElementById(id).style.height=this.document.body.scrollHeight+"px"
  }
}
</script>
</head>
<body onload="autofitIframe('ifrm')">

<?php
    ## Get the remote file and store it
    $database = file("ftp://username:pass@ipaddress/path_on_server/orangebox/tf/addons/sourcemod/data/sqlite/sourcemod-local.sq3");
    file_put_contents("sourcemod-local.sq3", $database);


    ## Connect to the database
    $maps = array();
    $db = new PDO('sqlite:sourcemod-local.sq3');
    $result = $db->query("SELECT * FROM map_ratings");
    while($row = $result->fetchObject()) {
        $maps[$row->map]["$row->rating"]++;
        $maps[$row->map]["ratingcount"]++;
        $maps[$row->map]["ratingtotal"] += $row->rating;
    }


    $result = $db->query("SELECT map, AVG(rating) AS ratingaverage, COuNT(rating) AS ratingcount FROM map_ratings GROUP BY map ORDER BY ratingaverage DESC, map");
    while($row = $result->fetchObject()) {

        ## Get this record
        $mapname = $row->map;
        $ratings = $maps[$mapname];


        ## This should never happen
        if ($ratings["ratingcount"] == 0)  {
            continue;
        }


        ## Prepare fields
        $average = round($ratings["ratingtotal"] / $ratings["ratingcount"], 2);
        if (!$ratings["1"])  {
            $ratings["1"] = 0;
        }
        if (!$ratings["2"])  {
            $ratings["2"] = 0;
        }
        if (!$ratings["3"])  {
            $ratings["3"] = 0;
        }
        if (!$ratings["4"])  {
            $ratings["4"] = 0;
        }
        if (!$ratings["5"])  {
            $ratings["5"] = 0;
        }

        ## Print record
        print "<h2>$mapname</h2>\n";
        print "<b>Average Rating:</b> $average<br>\n";
        print "<b>Total Ratings:</b> " . $ratings["ratingcount"] . "<br>\n";
?>

<div class="mainbar">
    <div class="bar5" style="width:<?=$ratings["5"] / $ratings["ratingcount"] * 500 + 5?>px"></div>
    <?=$ratings["5"]?> Excellent
</diV>
<div class="mainbar">
    <div class="bar4" style="width:<?=$ratings["4"] / $ratings["ratingcount"] * 500 + 5?>px"></div>
    <?=$ratings["4"]?> Good
</diV>
<div class="mainbar">
    <div class="bar3" style="width:<?=$ratings["3"] / $ratings["ratingcount"] * 500 + 5?>px"></div>
    <?=$ratings["3"]?> Average
</diV>
<div class="mainbar">
    <div class="bar2" style="width:<?=$ratings["2"] / $ratings["ratingcount"] * 500 + 5?>px"></div>
    <?=$ratings["2"]?> Poor
</diV>
<div class="mainbar">
    <div class="bar1" style="width:<?=$ratings["1"] / $ratings["ratingcount"] * 500 + 5?>px"></div>
    <?=$ratings["1"]?> Terrible
</diV>

<?php
    }
?>
</body>
</html>
ChillyWI is offline
FunTF2Server
Veteran Member
Join Date: Apr 2008
Old 08-12-2008 , 00:26   Re: Map Rate v0.10 (6/30)
Reply With Quote #176

Quote:
Originally Posted by ChillyWI View Post
Here's my clan's implementation of this:
http://yinyarr.com/Map_Ratings.aspx

I'm using a SQLite3 database instead of MySQL. It's a bit harder this way, but is still quite usable. Here's the code I used, which basically retrieves the database via FTP and then displays the data. Keep in mind I expect very little load on this page so I haven't tested any blocking or issues that arise when multiple people access the page at the same time (hence overlapping FTP downloads).

Also note that this is a big security risk if you store your admin information in the same database as the ratings, since it'll be transferred to your webhost where people could download it. Simple solutions are to separate these databases or protect the file on the server with htaccess (if available).

Code:
<html>
<head>
    <title>YinYarr Map Ratings</title>
    <style type="text/css">
        BODY  {
            background-color: #2C2A28;
            color: #FFFFFF;
            font: 9pt Calibri, Arial, san-serif;
            line-height: 140%;
        }
        .mainbar  {
            margin-top: 1px;
            height: 20px;
            clear: both;
        }
        .bar1  {
            margin-right: 5px;
            background-color: #bb3c3c;
            height: 20px;
            float: left;
        }
        .bar2  {
            margin-right: 5px;
            background-color: #a64a4d;
            height: 20px;
            float: left;
        }
        .bar3  {
            margin-right: 5px;
            background-color: #8c5b64;
            height: 20px;
            float: left;
        }
        .bar4  {
            margin-right: 5px;
            background-color: #716c7a;
            height: 20px;
            float: left;
        }
        .bar5  {
            margin-right: 5px;
            background-color: #5c798b;
            height: 20px;
            float: left;
        }
        H2  {
            font: 18pt Calibri, Arial, san-serif;
            margin-bottom: 2px;
        }
    </style>
<script type="text/javascript">
function autofitIframe(id)  {
  if (!window.opera && !document.mimeType && document.all && document.getElementById){
    parent.document.getElementById(id).style.height=this.document.body.offsetHeight+"px";
  }
  else if(document.getElementById) {
    parent.document.getElementById(id).style.height=this.document.body.scrollHeight+"px"
  }
}
</script>
</head>
<body onload="autofitIframe('ifrm')">

<?php
    ## Get the remote file and store it
    $database = file("ftp://username:pass@ipaddress/path_on_server/orangebox/tf/addons/sourcemod/data/sqlite/sourcemod-local.sq3");
    file_put_contents("sourcemod-local.sq3", $database);


    ## Connect to the database
    $maps = array();
    $db = new PDO('sqlite:sourcemod-local.sq3');
    $result = $db->query("SELECT * FROM map_ratings");
    while($row = $result->fetchObject()) {
        $maps[$row->map]["$row->rating"]++;
        $maps[$row->map]["ratingcount"]++;
        $maps[$row->map]["ratingtotal"] += $row->rating;
    }


    $result = $db->query("SELECT map, AVG(rating) AS ratingaverage, COuNT(rating) AS ratingcount FROM map_ratings GROUP BY map ORDER BY ratingaverage DESC, map");
    while($row = $result->fetchObject()) {

        ## Get this record
        $mapname = $row->map;
        $ratings = $maps[$mapname];


        ## This should never happen
        if ($ratings["ratingcount"] == 0)  {
            continue;
        }


        ## Prepare fields
        $average = round($ratings["ratingtotal"] / $ratings["ratingcount"], 2);
        if (!$ratings["1"])  {
            $ratings["1"] = 0;
        }
        if (!$ratings["2"])  {
            $ratings["2"] = 0;
        }
        if (!$ratings["3"])  {
            $ratings["3"] = 0;
        }
        if (!$ratings["4"])  {
            $ratings["4"] = 0;
        }
        if (!$ratings["5"])  {
            $ratings["5"] = 0;
        }

        ## Print record
        print "<h2>$mapname</h2>\n";
        print "<b>Average Rating:</b> $average<br>\n";
        print "<b>Total Ratings:</b> " . $ratings["ratingcount"] . "<br>\n";
?>

<div class="mainbar">
    <div class="bar5" style="width:<?=$ratings["5"] / $ratings["ratingcount"] * 500 + 5?>px"></div>
    <?=$ratings["5"]?> Excellent
</diV>
<div class="mainbar">
    <div class="bar4" style="width:<?=$ratings["4"] / $ratings["ratingcount"] * 500 + 5?>px"></div>
    <?=$ratings["4"]?> Good
</diV>
<div class="mainbar">
    <div class="bar3" style="width:<?=$ratings["3"] / $ratings["ratingcount"] * 500 + 5?>px"></div>
    <?=$ratings["3"]?> Average
</diV>
<div class="mainbar">
    <div class="bar2" style="width:<?=$ratings["2"] / $ratings["ratingcount"] * 500 + 5?>px"></div>
    <?=$ratings["2"]?> Poor
</diV>
<div class="mainbar">
    <div class="bar1" style="width:<?=$ratings["1"] / $ratings["ratingcount"] * 500 + 5?>px"></div>
    <?=$ratings["1"]?> Terrible
</diV>

<?php
    }
?>
</body>
</html>
Can you walk me through how to add that? I put all that in a .php file and edited the info for my ftp, but all I get is a bunch of gibberish when I open the .php file in my browser

here's what I get in my browser when I run my php file

i have the paths and filenames all correct as far as i know

Quote:
query("SELECT * FROM map_ratings"); while($row = $result->fetchObject()) { $maps[$row->map]["$row->rating"]++; $maps[$row->map]["ratingcount"]++; $maps[$row->map]["ratingtotal"] += $row->rating; } $result = $db->query("SELECT map, AVG(rating) AS ratingaverage, COuNT(rating) AS ratingcount FROM map_ratings GROUP BY map ORDER BY ratingaverage DESC, map"); while($row = $result->fetchObject()) { ## Get this record $mapname = $row->map; $ratings = $maps[$mapname]; ## This should never happen if ($ratings["ratingcount"] == 0) { continue; } ## Prepare fields $average = round($ratings["ratingtotal"] / $ratings["ratingcount"], 2); if (!$ratings["1"]) { $ratings["1"] = 0; } if (!$ratings["2"]) { $ratings["2"] = 0; } if (!$ratings["3"]) { $ratings["3"] = 0; } if (!$ratings["4"]) { $ratings["4"] = 0; } if (!$ratings["5"]) { $ratings["5"] = 0; } ## Print record print "$mapname

\n"; print "Average Rating: $average
\n"; print "Total Ratings: " . $ratings["ratingcount"] . "
\n"; ?> px">
Excellent
px">
Good
px">
Average
px">
Poor
px">
Terrible
__________________

Last edited by FunTF2Server; 08-12-2008 at 01:05.
FunTF2Server is offline
FunTF2Server
Veteran Member
Join Date: Apr 2008
Old 08-12-2008 , 01:09   Re: Map Rate v0.10 (6/30)
Reply With Quote #177

heres a snippet of whats in MY php file, a snippet of the parts i am supposed to configure

Code:
 ## Get the remote file and store it
    $database = file("ftp://CENSOREDNAME:[email protected]/69.12.92.177 port 27015/ZPS/addons/sourcemod/data/sqlite/maprate.sq3");
    file_put_contents("maprate.sq3", $database);


    ## Connect to the database
    $maps = array();
    $db = new PDO('sqlite:maprate.sq3');
    $result = $db->query("SELECT * FROM map_ratings");
    while($row = $result->fetchObject()) {
        $maps[$row->map]["$row->rating"]++;
        $maps[$row->map]["ratingcount"]++;
        $maps[$row->map]["ratingtotal"] += $row->rating;
    }
maprate.sq3 is the name of the sqlite database I'm storing maprate in, so that is correct

the path to the file is correct, i typed the path in my browser and it downloaded the file with no 404 errors.

the map_ratings table is correct, that is what my table cvar is set to

what am i doing wrong?
__________________
FunTF2Server is offline
ChillyWI
Senior Member
Join Date: Aug 2008
Old 08-12-2008 , 02:28   Re: Map Rate v0.10 (6/30)
Reply With Quote #178

You need PHP on your web host. Plus your FTP path is messed up. Do this: open an FTP program and browse to the file. Copy the path to the file and replace all of the values in this:

ftp://username:password@ftp_ip_addre...e/filename.ext
ChillyWI is offline
FunTF2Server
Veteran Member
Join Date: Apr 2008
Old 08-12-2008 , 09:49   Re: Map Rate v0.10 (6/30)
Reply With Quote #179

Quote:
Originally Posted by ChillyWI View Post
You need PHP on your web host. Plus your FTP path is messed up. Do this: open an FTP program and browse to the file. Copy the path to the file and replace all of the values in this:

ftp://username:password@ftp_ip_addre...e/filename.ext
yep that's the path to my file, what i got up there, double checked it.

so if my host has PHP, what now?
__________________
FunTF2Server is offline
FunTF2Server
Veteran Member
Join Date: Apr 2008
Old 08-12-2008 , 09:59   Re: Map Rate v0.10 (6/30)
Reply With Quote #180

i uploaded it to my webserver and accessing it that way, now i get this when i browse to the file on my webserver
Quote:
Warning: file() [function.file]: connect() failed: Connection timed out in /home/content/p/h/o/photogd/html/mapratings.php on line 66

Warning: file(ftp://[email protected]/69.12.92.177 port 27015/ZPS/addons/sourcemod/data/sqlite/maprate.sq3) [function.file]: failed to open stream: Operation now in progress in /home/content/p/h/o/photogd/html/mapratings.php on line 66

Fatal error: Call to a member function fetchObject() on a non-object in /home/content/p/h/o/photogd/html/mapratings.php on line 74
__________________
FunTF2Server is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 13:05.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode