First, why an invite only channel, and not a PM? You might have your reasons, though.

Secondly, you say that each person is allowed 1 vote. How do you recognize a person? Nickname? Hostmask? You got to make up your mind about that.

Something like this should work from the top of my head. Haven't tested it, though.

Code:
on *:text:*:#vote: {

  ;Reset the votes.
  if $1 == !reset {
    unset -w %votetotal*
    unset -w %voteuser*
    .timervoteuser* off
    .notice $nick Votes resetted.
  }

  ;Show the votes.
  elseif $1 == !stats {
    .notice $nick There are %votetotalA votes for A.
    .notice $nick There are %votetotalB votes for B.
    .notice $nick There are %votetotalC votes for C.
    .notice $nick There are %votetotalD votes for D.
  }

  ;Check if the vote is legit.
  elseif $1 != A && $1 != B && $1 != C && $1 != D {
    .notice $nick You can only vote A, B, C or D.
  }

  ;Check if the vote changed (optional, but nice).
  elseif %voteuser [ $+ [ $site ] ] == $1 {
    .notice $nick You're already voting for $+($1, .)
    .timervoteuser $+ $site 1 7200 votetimeout $site
  }

  else {

    ;Reduce the old vote total.
    if %voteuser [ $+ [ $site ] ] {
      dec %votetotal [ $+ [ %voteuser [ $+ [ $site) ] ] ] ] 1
    }

    ;Apply the new vote.
    inc %votetotal [ $+ [ $1 ] ] 1
    set %voteuser [ $+ [ $site ] ] $1
    .notice $nick You have voted for $+($1, .)
    .timervoteuser $+ $site 1 7200 votetimeout $site
  }
}

;Remove a vote.
alias -l votetimeout {
  if %voteuser [ $+ [ $1 ] ] {
    dec %votetotal [ $+ [ %voteuser [ $+ [ $1) ] ] ] ] 1
    unset %voteuser [ $+ [ $1 ] ]
  }
}


EDIT: Fixed an array bug.

Note that by giving a specific name to the timer, each time the user votes, the old vote timer is overwritten, which means the vote resets 2 hours after the user's last vote, not 2 hours after the first vote.

Last edited by Thels; 25/08/10 06:49 PM.

Learning something new every day.