mIRC Home    About    Download    Register    News    Help

Print Thread
How to make this ? #72515 23/02/04 12:36 PM
Joined: Jan 2003
Posts: 48
O
oSaYaP Offline OP
Ameglian cow
OP Offline
Ameglian cow
O
Joined: Jan 2003
Posts: 48
Hi ! I wanna make a code of "votes"
Something like this:
"Do you think mirc.com is the best page?" type !yes or !no to vote.
I want that the "votation"(i dont know if its ok) has a duration of 2 minutes.
And if nickname "John" write "!yes" and then he vote again with !yes or !no the code tells him that he has voted it.
And then .. the script says for example if John type !yes
a //describe $chan " $nick has voted yes / no"
And finally says the results, something like //describe $chan Results: yes: Numbers of votes
no: Numbers of votes
Help me please if you can do it
Goodbye, thanks a lot.
Best wishes from Argentina.


-= Porque pese a todo Dios .. an te tengo f =-
Re: How to make this ? #72516 23/02/04 10:07 PM
Joined: Jan 2003
Posts: 3,012
KingTomato Offline
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
this might be what you want >:D

(Select the below code, and copy to wordpad (Start>>Run>>"Wordpad") Then reselect and copy again, then paste to mirc. That will make the formatting keep)
Code:
[color:green]; -----------------------------------------------------------------------------
; Channel Poll
; -----------------------------------------------------------------------------

; -----------------------------------------------------------------------------
; Clear out the vote variables
; same with on exit, should they quit
; mirc in th emiddle of a vote[/color]

on *:START: {
  /unset %poll.*
}

on *:EXIT: {
  /unset %poll.*
}

[color:green]; -----------------------------------------------------------------------------
; Trigger
; --
; use:
;  Type !vote <question> to start a cote on a subject[/color]

on *:TEXT:!vote *:#: {
  [color:green]; time to vote in minutes[/color]
  [color:Red]var %time = 2[/color]

  if ($nick isop $chan) {
    if (!%poll.question) {
      [color:green]; make it easier below[/color]
      var %c = $chr(44)

      [color:green]; .info -> Voter,Channel,Votes_For,Votes_Against[/color]
      /set %poll.info $+($nick,%c,$chan,%c,0,%c,0)
      /set %poll.question $2-

      var %secs = %time * 60

      [color:green]; end the poll in 2 minutes[/color]
      .timerpoll 1 %secs /pollend

      [color:green]; warning timers[/color]
      .timerpoll1 1 $calc(%secs - 30) [color:blue]/msg $chan 30 Seconds Remaining![/color]
      .timerpoll2 1 $calc(%secs - 20) [color:blue]/msg $chan 20 Seconds Remaining![/color]
      .timerpoll2 1 $calc(%secs - 10) [color:blue]/msg $chan 10 Seconds Remaining![/color]

      [color:green]; enable "voting booth"[/color]
      .enable #polls

      [color:green]; advertise[/color]
      [color:blue]/msg $chan Polls are now open! ( $+ %time minutes to vote!)
      /msg $chan Current Poll: $2-
      /msg $chan Please type !yes to vote yes, and !no to vote no.[/color]
    }
    else [color:blue]/msg $chan There is already a vote in progress.[/color]
  }
  else [color:blue]/msg $chan You must have operator status to initiate a vote.[/color]
}

[color:green]; -----------------------------------------------------------------------------
; "voting booth"[/color]

#polls off

on *:TEXT:!yes:#: {
  if ($gettok(%poll.info,2,44) == $chan) {
    if (!%poll.vote [ $+ [ $address ] ]) {
      /set %poll.vote [ $+ [ $address ] ] yes
      /pollyes 1
      var %action = voted
    }
    else if (%poll.vote [ $+ [ $address ] ] == no) {
      /set %poll.vote [ $+ [ $address ] ] yes
      /pollyes 1
      /pollno -1
      var %action = change their vote to
    }
    else [color:blue]/msg $chan $nick $+ , you already voted yes.[/color]
    if (%action) [color:blue]/describe $chan $nick has %action yes[/color]
  }
}

on *:TEXT:!no:#: {
  if ($gettok(%poll.info,2,44) == $chan) {
    if (!%poll.vote [ $+ [ $address ] ]) {
      /inc %poll.vote [ $+ [ $address ] ]
      /pollno 1
      var %action = voted
    }
    else if (%poll.vote [ $+ [ $address ] ] == yes) {
      /set %poll.vote [ $+ [ $address ] ] no
      /pollno 1
      /pollyes -1
      var %action = changed their vote to
    }
    else [color:blue]/msg $chan $nick $+ , you already voted no.[/color]
    if (%action) [color:blue]/describe $chan $nick has %action no[/color]
  }
}

#polls end

[color:Green]; -----------------------------------------------------------------------------
; Aliases Needed[/color]

alias pollyes {
  if (%poll.info) {
    var %yes = $calc($gettok(%poll.info,3,44) + $1)
    /set %poll.info $puttok(%poll.info,%yes,3,44)
  }
}

alias pollno {
  if (%poll.info) {
    var %no = $calc($gettok(%poll.info,4,44) + $1)
    /set %poll.info $puttok(%poll.info,%no,4,44)
  }
}

alias pollend {
  if (%poll.question) {
    [color:green]; get info into something we can easily associate[/color]
    /tokenize 44 %poll.info
    var %nick = $1, %chan = $2, %yes = $3, %no = $4

    [color:green]; disable voting booth[/color]
    .disable #polls

    [color:green]; notify users[/color]
    [color:blue]/msg %chan Polls are now closed!    
    /msg %chan Current Poll: %poll.question[/color]

    [color:green]; come up with result[/color]
    if (%yes > %no) [color:blue]/msg %chan Vote Passes![/color]
    else if (%yes < %no) [color:blue]/msg %chan Vote Fails![/color]
    else [color:blue]/msg %chan Vote has ended in a Tie![/color]
  }
  /unset %poll.*
}
[color:green]; ------------------------------------------------------------------------------
; EOF KingTomato[/color]


Red: The value you change for vote time
Blue: The outputted messages on screen. You may not want to change them, but just pointing them out.
green: Just comments >:D


-KingTomato
Re: How to make this ? #72517 23/02/04 10:39 PM
Joined: Sep 2003
Posts: 584
B
bunar Offline
Fjord artisan
Offline
Fjord artisan
B
Joined: Sep 2003
Posts: 584
nice work kingTomato

Re: How to make this ? #72518 25/02/04 12:47 PM
Joined: Jan 2003
Posts: 48
O
oSaYaP Offline OP
Ameglian cow
OP Offline
Ameglian cow
O
Joined: Jan 2003
Posts: 48
Thanks a lot KingTomato smile
:P


-= Porque pese a todo Dios .. an te tengo f =-
Re: How to make this ? #72519 26/02/04 02:13 AM
Joined: Jan 2003
Posts: 3,012
KingTomato Offline
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
No problem >:D

Bunar: thnx for the compliment grin


-KingTomato