Raised This Month: $32 Target: $400
 8% 

time limit vote


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
vi3tmofo
Member
Join Date: Jun 2009
Old 05-25-2011 , 20:26   time limit vote
Reply With Quote #1

: Description :.
This Plugin start voting for timelimit in 3 minutes after the beginning of a map.
There are 5 options, and u can change it.
Add new vote count system:
Calculate the average number of minutes from the options which was voted.
For example:

5 players vote for 20 minutes
4 players vote for 60 minutes

5x20 + 4x60 = 340 minutes
4 + 5 = 9 votes(total)
Then 340 / 9 = 37,77 and rounds the result
Final result - 40 minutes

Default:
1. 20 minutes
2. 30 minutes
3. 40 minutes
4. 50 minutes
5. 60 minutes


****** OK this is what i need help on changing.*******

I want to take the time calculation out , so when people vote it doesnt calculate it just go straight to the minutes they vote.

thanks you

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "TimeLimit vote"
#define AUTHOR "many"
#define VERSION "0.4"

#define MAX_RESULTS 5

//thnx pr4er for help

new Float:g_timelimit
new menu

new g_voteCount[MAX_RESULTS + 1]
new g_tls[MAX_RESULTS]
new tls[MAX_RESULTS]

new g_CountSys

public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)

g_CountSys = register_cvar("amx_countsys", "1")

new name[12], string[12]
new multiplic = 20 // +++++

for(new i=0;i<MAX_RESULTS;i++)
{
format(name, sizeof name -1, "amx_tl_%d", i+1)

format(string, sizeof string -1, "%d", multiplic)

tls[i] = register_cvar(name, string)

multiplic += 10
}
}

public plugin_cfg()
{
menu = menu_create("\wChoose timelimit for this map?", "menu_handler")

for(new i=0;i<MAX_RESULTS;i++)
g_tls[i] = get_pcvar_num(tls[i])

set_task(180.0, "start_vote")

build_menu()
}

build_menu()
{
new option[64], temp[12]
for(new i=0;i<MAX_RESULTS;i++)
{
format(option, sizeof option -1, "\w%d minutes", g_tls[i])
format(temp, sizeof temp -1, "%d", i+1)

menu_additem(menu, option, temp, 0)
}

menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
}

public start_vote(id)
{
new players[32], inum, i
get_players(players, inum, "ch")

for(i=0;i<inum;i++)
menu_display(players[i], menu, 0)

set_task(15.0, "finish_vote")

for(i=1;i<(MAX_RESULTS+1);i++)
g_voteCount[i] = 0

return PLUGIN_CONTINUE
}

public menu_handler(id, menu, item)
{
if( !is_user_connected( id ) )
return PLUGIN_HANDLED

if(item == MENU_EXIT)
{
menu_cancel(id)

return PLUGIN_HANDLED
}

new data[6], name[32]
new access, callback

menu_item_getinfo(menu, item, access, data, 5, "", 0, callback)

new key = str_to_num(data)
get_user_name(id, name, 31)

client_print(0, print_chat, "[KZ] %s voted for %d minutes", name, g_tls[key -1])

g_voteCount[key]++

menu_cancel(id)

return PLUGIN_HANDLED
}

public finish_vote()
{
new players[32], inum
get_players(players, inum, "ch")

for(new i=0;i<inum;i++)
client_cmd(players[i], "slot10")

CountVotes()
}

public CountVotes()
{
g_timelimit = get_cvar_float("mp_timelimit")
new votesNum = 0

if(!get_pcvar_num(g_CountSys))
{
new best = 0

for(new i=1;i<(MAX_RESULTS+1);i++)
{
if(g_voteCount[i] > g_voteCount[best])
best = i
}

for(new i=1;i<(MAX_RESULTS+1);i++)
votesNum += g_voteCount[i]

new iRatio = votesNum ? floatround(get_cvar_float("amx_vote_ratio") * float(votesNum), floatround_ceil) : 1
new iResult = g_voteCount[best]

if(iResult >= iRatio)
{
new new_time = g_tls[best -1]

client_print(0, print_chat, "[KZ] Voting successful. Option %d minutes won.", new_time)

set_cvar_num("mp_timelimit", new_time)
}
else
{
client_print(0, print_chat, "[KZ] Voting failed.")
}
}
if(get_pcvar_num(g_CountSys) == 1)
{
new summ_time = 0
new _time

for(new i=1;i<(MAX_RESULTS+1);i++)
{
votesNum += g_voteCount[i]
summ_time += g_voteCount[i] * g_tls[i-1]
}

if(votesNum)
{
_time = floatround(float(summ_time) / float(votesNum), floatround_ceil)
if (_time - (_time = _time / 10 * 10) >= 5)
_time += 10

client_print(0, print_chat, "[KZ] Voting successful. Time limit is set to average - %d minutes", _time)

set_cvar_num("mp_timelimit", _time)

}
else
{
client_print(0, print_chat, "[KZ] Voting failed.")
}

}
}

public plugin_end()
{
set_cvar_float("mp_timelimit", g_timelimit)
}

vi3tmofo is offline
vi3tmofo
Member
Join Date: Jun 2009
Old 05-25-2011 , 22:14   Re: time limit vote
Reply With Quote #2

****** OK this is what i need help on changing.*******

I want to take the time calculation out , so when people vote it doesnt calculate it just go straight to the minutes they vote.

thanks you
vi3tmofo is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-25-2011 , 23:59   Re: time limit vote
Reply With Quote #3

Your request in unclear. Try doing: amx_countsys 0

Also, this is a more flexible version of that plugin.

P.S. If you don't plan on editing code yourself then post it in the Requets section. Also, don't post the code unless you've changed it and post a link to the original.
__________________

Last edited by fysiks; 05-26-2011 at 00:01.
fysiks 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 16:44.


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