Raised This Month: $ Target: $400
 0% 

Rate map


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
reinert
Veteran Member
Join Date: Feb 2007
Old 05-07-2011 , 04:50   Rate map
Reply With Quote #1

Hey, could someone explain me how should I make a something like a map list in mysql, and I want to make that on every map last round players will get a map rate menu, and they can rate a map that they have played right now,

Like:

Rate map : De_dust2
5/5 Stars
4/5 Stars
3/5 Stars
2/5 Stars
1/5 Stars

But I want to avoid multiple votes for one map, for Example

Player1 can rate for 1 map only 1 time.

Like Player1 once voted for de_dust2, so next time he wont get the rate menu if the rating is for de_dust2.

How should my mysql table look like.

Lets say right now I've this:

Quote:
Map----------Rating----------Total_Votes
de_dust2----3.4--------------27
de_inferno--4.2--------------60
But I with this table I can't check does user already voted for de_dust2.

Maybe it's possible to make a .txt files like:

de_dust2.txt and write there a steamids of people that already have rated de_dust2 map (if yes, how to do it ?)

Quote:
de_dust2.txt
reinert
trenier2
niertre6
kamsd55
asodmn

Last edited by reinert; 05-07-2011 at 05:00.
reinert is offline
SonicSonedit
Veteran Member
Join Date: Nov 2008
Location: Silent Hill
Old 05-07-2011 , 11:08   Re: Rate map
Reply With Quote #2

If such plugin doesn't exist, I'll make it myself some time later. Public, ofcourse.
__________________

SonicSonedit is offline
reinert
Veteran Member
Join Date: Feb 2007
Old 05-07-2011 , 11:09   Re: Rate map
Reply With Quote #3

I've half of code already, it exists but it's way too different to mines I can give you code if you help me to finish it
reinert is offline
SonicSonedit
Veteran Member
Join Date: Nov 2008
Location: Silent Hill
Old 05-07-2011 , 11:38   Re: Rate map
Reply With Quote #4

reinert
Well, i'm up to it, except the idea of voting only once.
I really don't see any point to add this feature:
1) You can vote only once per map change. So why don't allow player to vote every time he played the map? I think it's fair.
2) About 70% of gaming community is no-steam, therefore there is no reliable way to make it "only once per client", except hacking (and if user has some brains, this won't help either).
__________________

SonicSonedit is offline
jc980
Veteran Member
Join Date: Jan 2010
Location: God is with us...
Old 05-07-2011 , 11:47   Re: Rate map
Reply With Quote #5

80%. are non-steam.
__________________
jc980 is offline
reinert
Veteran Member
Join Date: Feb 2007
Old 05-07-2011 , 11:58   Re: Rate map
Reply With Quote #6

but If how I already told you, making a .txt file and putting steam auths into it, then checking them.

http://forums.alliedmods.net/showthread.php?t=69593

Would be cool with those features
reinert is offline
SonicSonedit
Veteran Member
Join Date: Nov 2008
Location: Silent Hill
Old 05-07-2011 , 12:01   Re: Rate map
Reply With Quote #7

reinert
Quote:
but If how I already told you, making a .txt file and putting steam auths into it, then checking them.
And about 70-80% of players will never ever vote, because they have same STEAMID.
I know, this forum about Steam and stuff (I personally use steam and happy) but if you are making a plugin for players, you should think about players.
__________________

SonicSonedit is offline
reinert
Veteran Member
Join Date: Feb 2007
Old 05-07-2011 , 12:05   Re: Rate map
Reply With Quote #8

The server I'm making this plugin for, contains only steamed players.

So I've a rating system with

5 stars,
Quote:
1. #####_[5/5]
2. ####__[4/5]
3. ###___[3/5]
4. ##____[2/5]
5. #_____[1/5]
6. ______[0/5]
I've every star vote count, like
Quote:
5stars - 25votes
4stars - 10votes
3stars - 40votes
2stars - 38 votes
1star - 51 votes
0stars - 19 votes
total = 183 votes.

I would like to show the rating in percents,
Code:
5stars = 25/183*100;
4stars = 10/183*100;
Quote:
1. 5stars ( 13.6% )
2. 4stars ( 5.4% )
PHP Code:
formatex(5stars192"##### ( %1.f%% )"i5 iVoteCount 100.0
I'm doing it like this but percent value is always 0. I don't know why.

Last edited by reinert; 05-07-2011 at 12:21.
reinert is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 05-07-2011 , 12:18   Re: Rate map
Reply With Quote #9

Steam, no sql.
PHP Code:
/*    Formatright © 2010, ConnorMcLeod

    This plugin is free software;
    you can redistribute it and/or modify it under the terms of the
    GNU General Public License as published by the Free Software Foundation.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this plugin; if not, write to the
    Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/

#include <amxmodx>

#define VERSION "0.1.2"
#define PLUGIN "Rate that map"

#define NOT_VOTED_YET -1

enum _:Votes {
    
Terrible,
    
Bad,
    
Not_Bad,
    
Good,
    
Awesome
}

new 
g_iVotes[Votes]

new 
Trie:g_tPlayerVotes
new g_szStoreFile[64], g_szMapName[32]
new 
g_pCvarMenuDelay

public plugin_init()
{
    
register_plugin(PLUGINVERSION"ConnorMcLeod")

    
g_pCvarMenuDelay register_cvar("amx_ratemap_delay""30.0")

    
get_localinfo("amxx_datadir"g_szStoreFilecharsmax(g_szStoreFile))
    
add(g_szStoreFilecharsmax(g_szStoreFile), "/maprates")
    if( !
dir_exists(g_szStoreFile) )
    {
        
mkdir(g_szStoreFile)
    }

    
get_mapname(g_szMapNamecharsmax(g_szMapName))
    
strtolower(g_szMapName)
    
format(g_szStoreFilecharsmax(g_szStoreFile), "%s/%s.dat"g_szStoreFileg_szMapName)

    
g_tPlayerVotes TrieCreate()

    new 
fp fopen(g_szStoreFile"rt")
    if( 
fp )
    {
        new 
szBuffer[128], szAuthid[32], szVote[2], c
        
new szName[32], iVote
        
while( !feof(fp) )
        {
            
fgets(fpszBuffercharsmax(szBuffer))
            
trim(szBuffer)
            
szBuffer[0]
            if( !
|| == '/' || == ';' || == '#' )
            {
                continue
            }
            
parse(szBufferszAuthidcharsmax(szAuthid), szVotecharsmax(szVote), szNamecharsmax(szName))
            
g_iVotes[ (iVote szVote[0] - '0') ]++
            
TrieSetCell(g_tPlayerVotesszAuthidiVote)
        }
        
fclose(fp)
    }
    else
    {
        
fp fopen(g_szStoreFile"wt")
        
fprintf(fp";^n^n")
        
fclose(fp)
    }

    
register_concmd("amx_show_maprates""ConCmd_ShowRates"ADMIN_MAP"[MapName optional] Show map rates")
}

public 
ConCmd_ShowRatesid )
{
    new 
szMapName[32]
    if( 
read_argv(1szMapNamecharsmax(szMapName)) && !equali(szMapNameg_szMapName) && is_map_valid(szMapName) )
    {
        
strtolower(szMapName)
        new 
szFile[64]
        
get_localinfo("amxx_datadir"szFilecharsmax(szFile))
        
format(szFilecharsmax(szFile), "%s/maprates/%s.dat"szFileszMapName)
        if( 
file_exists(szFile) )
        {
            new 
szBuffer[256], iLen
            read_file
(szFile0szBuffercharsmax(szBuffer), iLen)
            if( 
iLen )
            {
                
console_print(idszBuffer[1])
                return 
PLUGIN_HANDLED
            
}
        }
        
console_print(id"No votes for map %s")
        return 
PLUGIN_HANDLED
    
}
    
    new 
iTotalVotes
    
for(new i=Terriblei<=Awesomei++)
    {
        
iTotalVotes += g_iVotes[i]
    }
    if( !
iTotalVotes )
    {
        
console_print(id"Map Rates : No Votes Yet !!")
        return 
PLUGIN_HANDLED
    
}
    
console_print(id"^nMap Rates :")
    
console_print(id"%s : %d/%d %3d%%%""Awesome"g_iVotes[Awesome], iTotalVotesg_iVotes[Awesome]*100/iTotalVotes)
    
console_print(id"%s : %d/%d %3d%%%""Good"g_iVotes[Good], iTotalVotesg_iVotes[Good]*100/iTotalVotes)
    
console_print(id"%s : %d/%d %3d%%%""Not Bad"g_iVotes[Not_Bad], iTotalVotesg_iVotes[Not_Bad]*100/iTotalVotes)
    
console_print(id"%s : %d/%d %3d%%%""Bad"g_iVotes[Bad], iTotalVotesg_iVotes[Bad]*100/iTotalVotes)
    
console_print(id"%s : %d/%d %3d%%%^n""Terrible"g_iVotes[Terrible], iTotalVotesg_iVotes[Terrible]*100/iTotalVotes)
    return 
PLUGIN_HANDLED
}

public 
plugin_end()
{
    new 
iTotalVotes
    
for(new i=Terriblei<=Awesomei++)
    {
        
iTotalVotes += g_iVotes[i]
    }
    if( 
iTotalVotes )
    {
        new 
szBuffer[256]
        
formatex(szBuffercharsmax(szBuffer), ";Awesome %d (%d%%) | Good %d (%d%%) | Not Bad %d (%d%%) | Bad %d (%d%%) | Terrible %d (%d%%) | TOTAL %d",
                                        
g_iVotes[Awesome], g_iVotes[Awesome]*100/iTotalVotes,
                                        
g_iVotes[Good], g_iVotes[Good]*100/iTotalVotes,
                                        
g_iVotes[Not_Bad], g_iVotes[Not_Bad]*100/iTotalVotes,
                                        
g_iVotes[Bad], g_iVotes[Bad]*100/iTotalVotes,
                                        
g_iVotes[Terrible], g_iVotes[Terrible]*100/iTotalVotes,
                                        
iTotalVotes)
        
write_file(g_szStoreFileszBuffer0)
    }
}

public 
client_putinserverid )
{
    
remove_task(id)
    if( !
is_user_bot(id) && !is_user_hltv(id) )
    {
        
set_task(get_pcvar_float(g_pCvarMenuDelay), "Show_Rate_Menu"id)
    }
}

public 
client_disconnectid )
{
    
remove_task(id)
}

public 
Show_Rate_Menuid )
{
    if( !
is_user_connected(id) )
    {
        return
    }

    new 
iCrap
    
if( player_menu_info(idiCrapiCrap) )
    {
        
set_task(15.0"Show_Rate_Menu"id)
        return
    }


    new 
szAuthid[32]
    
get_user_authid(idszAuthidcharsmax(szAuthid))

    new 
iPreviousVote NOT_VOTED_YET
    TrieGetCell
(g_tPlayerVotesszAuthidiPreviousVote)

    new const 
szVotes[][] = {"Terrible""Bad""Not Bad""Good""Awesome"}
    new 
iMenu menu_create("\yHow would you rate that map ?""MapRate_Menu_Handled")
    
menu_setprop(iMenuMPROP_NUMBER_COLOR"\y")
    for(new 
i=Terriblei<=Awesomei++)
    {
        if( 
iPreviousVote == )
        {
            new 
szText[32]
            
formatex(szTextcharsmax(szText), "\d%d. \w%s\w"i+1szVotes[i])
            
menu_addtext(iMenuszText)
        }
        else
        {
            
menu_additem(iMenuszVotes[i])
        }
    }
    
menu_display(idiMenu)
}

public 
MapRate_Menu_Handled(idiMenuiItem)
{
    
menu_destroy(iMenu)
    if( 
iItem >= )
    {
        new 
szName[32]
        new 
szAuthid[32]
        new 
iPreviousVote
        get_user_authid
(idszAuthidcharsmax(szAuthid))

        new 
bool:bAlreadyVoted TrieGetCell(g_tPlayerVotesszAuthidiPreviousVote)
        
get_user_name(idszNamecharsmax(szName))
        if( 
bAlreadyVoted )
        {
            
g_iVotesiPreviousVote ]--
            
g_iVotesiItem ]++
        }

        
TrieSetCell(g_tPlayerVotesszAuthidiItem)

        
WriteVote(szAuthidszNameiItembAlreadyVoted)
    }
}

WriteVote(const szAuthid[32], const szName[], const iVotebool:bAlreadyVoted)
{
    if( !
bAlreadyVoted )
    {
        new 
fp fopen(g_szStoreFile"at")
        
fprintf(fp"%s %d %s^n"szAuthidiVoteszName)
        
fclose(fp)
    }
    else
    {
        new 
iLine = -1szSteamId[32], szBuffer[128]
        new 
fp fopen(g_szStoreFile"rt")
        while( !
feof(fp) )
        {
            
iLine++
            
fgets(fpszBuffercharsmax(szBuffer))
            
trim(szBuffer)
            
parse(szBufferszSteamIdcharsmax(szSteamId))
            if( 
equal(szSteamIdszAuthid) )
            {
                break
            }
        }
        
fclose(fp)
        
formatex(szBuffercharsmax(szBuffer), "%s %d %s"szAuthidiVoteszName)
        
write_file(g_szStoreFileszBufferiLine)
    }

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
reinert
Veteran Member
Join Date: Feb 2007
Old 05-07-2011 , 12:30   Re: Rate map
Reply With Quote #10

What does %3d% stands for ?

Last edited by reinert; 05-07-2011 at 12:36.
reinert 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 04:22.


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