mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jul 2014
Posts: 3
M
mike112 Offline OP
Self-satisified door
OP Offline
Self-satisified door
M
Joined: Jul 2014
Posts: 3
Hey everyone,

First of all I'd like to start out by saying I already have a point system in place. What I'm looking to do is create an event that can include multiple winners and multiple losers. Basically, I'd like to be able to let users bet whether or not a broadcaster is going to succeed or fail in a run. So they could say !start and that would then allow the users to type !pass or !fail depending on what they think will happen. IF they pass, the broadcaster could type something like !runpass and all of the viewers who typed !pass will win X points, and all of the losers will lose X points.

Is this possible to do?

Thanks so much for taking the time to look at this.

Last edited by mike112; 11/07/14 01:43 PM.
Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
Code:
on *:text:!start:#:{
  if ($nick !isop #) return
  hfree -w passfail. $+ # | hmake passfail. $+ #
}

on $*:text:/^!(pass|fail)$/iS:#:{
  if (!$hget(passfail. $+ #)) return
  if (!$hget(passfail. $+ #,$nick)) hadd passfail. $+ # $nick $regml(1)
}

on $*:text:/^!run(pass|fail)$/iS:#:{
  if ($nick !isop #) return
  if (!$hget(passfail. $+ #)) return
  var %i = $hget(passfail. $+ #,0).item
  while (%i) {
    var %nick = $hget(passfail. $+ #,%i).item
    if ($hget(passfail. $+ #,%nick) == $regml(1)) addpoints # %nick
    else rempoints # %nick
    dec %i
  }
  hfree -w passfail. $+ #
}

Joined: Jul 2014
Posts: 3
M
mike112 Offline OP
Self-satisified door
OP Offline
Self-satisified door
M
Joined: Jul 2014
Posts: 3
Thank you so much for the reply, Loki.

I believe I can follow what is happening there. However, when I test it, I'm trying to add some msg $chan to see who said (pass | fail). I've never used $hget or hadd/hmake before. Would it be too much to ask for some more info? frown

Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
Those commands are for working with hash tables. A hash table is basically a dictionary that maps an item to a value. So to start with you create the hash table with hmake. You can use $hget with just the name of the table to see if the table already exists. If you $hget with the table name and item, it will return the value. You can also get the Nth entry in the table with the .item property (although this is not efficient).

See /help hash tables for more.

Joined: Jul 2014
Posts: 3
M
mike112 Offline OP
Self-satisified door
OP Offline
Self-satisified door
M
Joined: Jul 2014
Posts: 3
Any hints on how I could relay the information such as if I !runpass, and 10x people said I'd pass, how would I go about displaying those people to the chat? For instance

Code:
 msg $chan (User1), (User2) -> (User10) guessed correctly!


Is there a simple way to go about doing so? Sorry, my programming skills and knowledge are somewhat lacking for doing this. Also, I'd need an !end of some sort to stop "registering" people for the event. I'm sorry if this is asking too much of you.


Link Copied to Clipboard