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

Map Rate v0.10 (6/30)


Post New Thread Reply   
 
Thread Tools Display Modes
FunTF2Server
Veteran Member
Join Date: Apr 2008
Old 08-12-2008 , 10:11   Re: Map Rate v0.10 (6/30)
Reply With Quote #181

i'm guessing i have to add something to php.ini on my webserver? anyone know whaT?
__________________
FunTF2Server is offline
crazychicken
Senior Member
Join Date: Mar 2008
Old 08-12-2008 , 11:49   Re: Map Rate v0.10 (6/30)
Reply With Quote #182

does this plugin only work if you use the webpage database too,only installing the smx files will it save the results in a log file or just not work well?
__________________
crazychicken is offline
willy1234x1
Senior Member
Join Date: Jun 2008
Old 08-12-2008 , 12:42   Re: Map Rate v0.10 (6/30)
Reply With Quote #183

Quote:
Originally Posted by crazychicken View Post
does this plugin only work if you use the webpage database too,only installing the smx files will it save the results in a log file or just not work well?
It's not necessary, I posted a method to do it sans website a while back. You can't really use the information on there unless you're in-game though so finding which maps to remove or keep may be harder.
willy1234x1 is offline
willy1234x1
Senior Member
Join Date: Jun 2008
Old 08-12-2008 , 14:03   Re: Map Rate v0.10 (6/30)
Reply With Quote #184

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>
Is that web interface compatible with Mysql instead of sqlite? It's much nicer looking than the other (which is reasonable since the other is meant as a simple viewer.) Also are the map's ratings detachable from the main file? Like on my site http://highsocietygaming.net/?page_id=46 there are per map pages I've created and I'd like to imbed the rating in the page is this possible with your viewer?

Last edited by willy1234x1; 08-13-2008 at 13:00.
willy1234x1 is offline
ChillyWI
Senior Member
Join Date: Aug 2008
Old 08-12-2008 , 15:41   Re: Map Rate v0.10 (6/30)
Reply With Quote #185

Quote:
Originally Posted by willy1234x1 View Post
Is that web interface compatible with Mysql instead of sqlite? It's much nicer looking than the other (which is reasonable since the other is meant as a simple viewer.) Also are the map's ratings detachable from the main file? Like on my site http://highsocietygaming.net/page_id=46 there are per map pages I've created and I'd like to imbed the rating in the page is this possible with your viewer?
It'll work with mysql if you remove the 2 FTP lines and then change the "new PDO" connection string to use mysql instead of sqlite. You'll also have to put in username/pass/etc in that connection string, so you'd have to look into the PDO documentation for mysql. I'd do it for you, but frankly I don't have the time.

Your page isn't loading for me, but to get a single map's data you'd have to make a few modifications. I'd just change the first query from "SELECT * FROM map_ratings" to "SELECT * FROM map_ratings WHERE map='cp_dustbowl'". Then you don't have to loop through the maps in the 2nd query... just select the map by changing "$mapname = $row->map" to "$mapname = 'cp_dustbowl'";

Seems complicated if you don't know PHP, but I'd suggest finding someone with basic PHP knowledge and they'll know exactly what I'm talking about.
ChillyWI is offline
ChillyWI
Senior Member
Join Date: Aug 2008
Old 08-12-2008 , 15:43   Re: Map Rate v0.10 (6/30)
Reply With Quote #186

Quote:
Originally Posted by crazychicken View Post
does this plugin only work if you use the webpage database too,only installing the smx files will it save the results in a log file or just not work well?
You have to use some form of database. SourceMod has SQLite3 built-in, though, so all you have to do is specify that database source in the plugin settings and it'll work without needing to mess with a database.
ChillyWI is offline
willy1234x1
Senior Member
Join Date: Jun 2008
Old 08-12-2008 , 18:02   Re: Map Rate v0.10 (6/30)
Reply With Quote #187

Quote:
Originally Posted by ChillyWI View Post
You have to use some form of database. SourceMod has SQLite3 built-in, though, so all you have to do is specify that database source in the plugin settings and it'll work without needing to mess with a database.
Not quite true. If you set it up like so you don't need to have a webserver database.
Quote:
Originally Posted by willy1234x1 View Post
K for those who don't know SQL here's a simple solution to install it.

Step one. download the maprate.sp file (click on get source.)

Step two. open the maprate.sp in a text editor such as notepad++ or even notepad (can be done by right clicking and clicking on open with then selecting the program)

step three. find the cvar maprate_db_config and change it's value to "maprate" take this time to edit any other cvars you want changed.
Code:
 g_cvars[CVAR_DB_CONFIG] = CreateConVar(
    "maprate_db_config",
    "maprate",
    "Database configuration to use for Map Rate plugin",
    FCVAR_PLUGIN);
Should look like this once edited.

step four. find your databases.cfg and add the following database
Code:
   "maprate"
    {
        "driver"            "sqlite"
        "database"            "maprate"
    }
step five. compile your maprate.sp either with the one in the scripting folder or with this one http://www.sourcemod.net/compiler.php

step six. place the maprate.sp in your scripting folder and the maprate.smx you just compiled in the plugins folder and restart your server.

Congratulations you have maprate working now.
Credits for this tutorial go to Redheadkid since he helped me out back when I just started with SM (last month haha.)

P.S. Stevieboy I'll post up the Portugeuse translations soon. They're going to be in the BR-Portugeuse so if anyone wanted standard Portugal Portugeuse sorry. I'm Brazilian not Portugeuse.

P.S.S. Sorry to anyone who thinks that the tutorial is talking down I just wanted to make it as easy as possible.
willy1234x1 is offline
crazychicken
Senior Member
Join Date: Mar 2008
Old 08-13-2008 , 04:24   Re: Map Rate v0.10 (6/30)
Reply With Quote #188

Wow thanks for the help guys, I haven't got a clue about sql and html so be as condescending as you want I won't detect it

I did what you listed in the above post willy, and its working on the server <3 thanks for your guide and the plugin creator Is it possible for a message to pop up in chat at the start of a map saying people can type !maprate to rate the map?


in your big post above that where you quote chillwi's code for the database I think, how would I use that?

I have a web server and also an sv_downloadurl host, can I use the host to make the data tables viewable in a web browser and how do I make that secure because I have no idea about that either
__________________

Last edited by crazychicken; 08-13-2008 at 04:54.
crazychicken is offline
doa
Member
Join Date: Nov 2007
Old 08-13-2008 , 08:00   Re: Map Rate v0.10 (6/30)
Reply With Quote #189

Great plugin!

Where's the config supposed to go? I created a maprate.cfg which being exec'd from server.cfg, but no success.

Thanks
__________________
-- Growing older is mandatory --
----- Growing up is optional -----
doa is offline
willy1234x1
Senior Member
Join Date: Jun 2008
Old 08-13-2008 , 12:58   Re: Map Rate v0.10 (6/30)
Reply With Quote #190

Quote:
Originally Posted by crazychicken View Post
Wow thanks for the help guys, I haven't got a clue about sql and html so be as condescending as you want I won't detect it

I did what you listed in the above post willy, and its working on the server <3 thanks for your guide and the plugin creator Is it possible for a message to pop up in chat at the start of a map saying people can type !maprate to rate the map?


in your big post above that where you quote chillwi's code for the database I think, how would I use that?

I have a web server and also an sv_downloadurl host, can I use the host to make the data tables viewable in a web browser and how do I make that secure because I have no idea about that either
You have to check with your webhost on whether they use mySQL or SQlite because his viewer works with SQlite only right now and the one on the first page is a mySQL only viewer. As for having it say something like "You can rate the map by typing !maprate" you can use the advertisements plugin http://forums.alliedmods.net/showthread.php?t=67885 but I personally have both an advert of it and I set it to automatically ask players to rate the map after 5 minutes of playing in the server.
willy1234x1 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 10:33.


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