mIRC Home    About    Download    Register    News    Help

Print Thread
Need help with voting system #240214 06/01/13 03:10 AM
Joined: Jan 2013
Posts: 2
T
tpt Offline OP
Bowl of petunias
OP Offline
Bowl of petunias
T
Joined: Jan 2013
Posts: 2
I'm working on gather script and its almost done but it needs map voting system.

I've searched on google for vote/poll systems but none of them really helps me. Mainly because they were simple yes/no scripts.

System needs to work this way:

- It has a file with all allowed maps you can vote for.
- When voting starts gather players can use command !vote <mapname> ( Reading allowed maps from file ) this would increase vote count for the map.
- It needs to keep count of all voted maps with their names and votes
- Voting will be stopped IF one option gets most votes ( maxplayers / 2 + 1 )

My question is how this can be done? I'm not saying that anyone should do it for me i just need some ideas what would be the best way to do this. But if someone is up for scripting it i wouldn't mind a bit. laugh

Thanks. smile


EDIT: Managed to do something like this with hash tables and bubble sort type of thing to sort the votes. I'm wondering if there's a better way.

Last edited by tpt; 06/01/13 03:10 AM.
Re: Need help with voting system [Re: tpt] #240217 06/01/13 03:00 PM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
The easiest way to sort a hash table of score results is to save the table and /filter it using line numbers. You can then read the line number in the result to $hget the information you want. It's very fast.

Code:
  ; Sort
  hsave -n tablename path\filename
  filter -ffcuten 2 32 same_path\filename same_path\filename

  ; Get results
  ; Note the "N" in the 2 $read is the line number of your results.
  ; It needs to be replaced with either hard-coded numbers or else a variable
  ; and then you'd loop through however many you want - Top 5, Top 10, etc.
  //echo -a $hget(tablename,$gettok($read(same_path\filename,N),1,32)).item
  //echo -a $gettok($read(same_path\filename,N),2,32)


You can use something like that for your sorting. Hash tables are generally a good option for dealing with any kind of scoring system, so it sounds like you probably have a decent script for this. Whether or not any improvements could be made to it wouldn't be known without seeing what you have.

*Note: The example above assumes the table is set up with the map as the Item and the number of votes as the Data.


Invision Support
#Invision on irc.irchighway.net
Re: Need help with voting system [Re: Riamus2] #240218 06/01/13 04:08 PM
Joined: Jan 2013
Posts: 2
T
tpt Offline OP
Bowl of petunias
OP Offline
Bowl of petunias
T
Joined: Jan 2013
Posts: 2
Originally Posted By: Riamus2

Code:
  ; Sort
  hsave -n tablename path\filename
  filter -ffcuten 2 32 same_path\filename same_path\filename

  ; Get results
  ; Note the "N" in the 2 $read is the line number of your results.
  ; It needs to be replaced with either hard-coded numbers or else a variable
  ; and then you'd loop through however many you want - Top 5, Top 10, etc.
  //echo -a $hget(tablename,$gettok($read(same_path\filename,N),1,32)).item
  //echo -a $gettok($read(same_path\filename,N),2,32)


*Note: The example above assumes the table is set up with the map as the Item and the number of votes as the Data.


Thats exactly how its set up. Thanks for the script. cool