mIRC Home    About    Download    Register    News    Help

Print Thread
#76056 21/03/04 08:23 PM
Joined: Mar 2004
Posts: 359
L
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Mar 2004
Posts: 359
Hey i'm writing a Voting Both script..and trying to figure out how to make a var. count up like for instance:
on 1:TEXT:`yes:#:/msg $chan 7$nick Voted Yes! |/msg $chan %tag Yes: %vyes No: %vno


oh and dont mind the %tag var..its there soo i dont have to waste time putting in15<14<15>14>7 all the time..please help its buggin me cool cool

Last edited by LostServ; 21/03/04 08:39 PM.
#76057 21/03/04 11:18 PM
Joined: Jun 2003
Posts: 994
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Jun 2003
Posts: 994
/help /inc


I refuse to engage in a battle of wits with an unarmed person. wink
#76058 22/03/04 03:03 AM
Joined: Mar 2004
Posts: 359
L
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Mar 2004
Posts: 359
I see the /inc part but how about an example..

#76059 22/03/04 06:33 AM
Joined: Mar 2003
Posts: 1,271
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Mar 2003
Posts: 1,271
Why is it that with one of the most simple commands there is you require an example? Did you play around with /inc to see how it works?

/inc [-cszuN] <%var> [value]
This increases the value of %var by value.

It's quite easy to understand...


DALnet #Helpdesk
I hear and I forget. I see and I remember. I do and I understand. -Confucius
#76060 22/03/04 10:34 AM
Joined: Dec 2002
Posts: 1,321
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Dec 2002
Posts: 1,321
In answer to your question, here's an example, using your code.

on 1:TEXT:`yes:#:{
  • inc %vyes
    msg $chan $+(7,$nick) Voted Yes!
    msg $chan %tag Yes: %vyes No: %vno
}

However...

You will want to check a variable to see if you are currently in a voting process; you don't want the script to react if there is no voting going on. You will also want to make sure one nick (or even user[/b]@host) can vote only once. There are many popular ways to do this, but to keep things simple, I'll just show you one easy way.

You can build a variable name using $+ or $+( ) that includes a common element - such as %VotingBooth. - which makes unsetting them all when your script determines that the voting is over much easier. You follow this initial part of the variable name by their $nick or $wildsite (*!*@) or a $mask of their $fulladdress that best suits your needs. For the value, you use whatever they voted; this makes it easy to remove their vote if they leave the channel while the vote is in progress. I'll build each element of the variable one step at a time to show how the values are arrived at, but you can just as easily do it all in one step once you get the idea; I'll also just use the nick, also for simplicity's sake.

You will end up with variables like %VotingBooth.Hammer which will equal either Yes or No.

on 1:TEXT:`yes:#:{
  • ; If voting is not turned on, skip this code.
    if (%VotingBooth.On != True) return

    ; If this nick has already voted, skip this code.
    if ($eval(% $+ VotingBooth. $+ $nick, 2) != $null) return

    ; Increment the yes count.
    inc %VotingBooth.Yes

    ; Save this nick's vote.
    set %VotingBooth. $+ $nick Yes

    ; Message the channel with the results.
    msg $chan $+(7,$nick) Voted Yes!
    msg $chan %tag Yes: %VotingBooth.Yes No: %VotingBooth.No
}
; Here's the same thing for the No votes, without the comments.
on 1:TEXT:`no:#:{
  • if (%VotingBooth.On != True) return
    var %AlreadyVoted = % $+ VotingBooth. $+ $nick
    if ($eval(% $+ VotingBooth. $+ $nick, 2) != $null) return
    inc %VotingBooth.No
    set %VotingBooth. $+ $nick No
    msg $chan $+(7,$nick) Voted No!
    msg $chan %tag Yes: %VotingBooth.Yes No: %VotingBooth.No
}

This lets you unset %VotingBooth.* somewhere later in your code when the voting is turned off, cleaning up all the variables you used for it in one command.


DALnet: #HelpDesk and #m[color:#FF0000]IR[color:#EEEE00]C
#76061 22/03/04 11:10 PM
Joined: Mar 2004
Posts: 359
L
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Mar 2004
Posts: 359
well 'borg' it is becasue its been over a year since ive done mirc scripting and im getting back into it..now with that said an done (i tried to make it where only one can vote while it being on..and even if its 'off' (`vstop) it still allows someone to do `yes or `no but yet i added groups where i shouldnt do that..damned if it still does here is the script:
Code:
on 10:TEXT:`vtopic*:#:{
  set %vtopic $2
  msg $chan %tag Vote Topic Set To: $2 %tag
}
on 10:TEXT:`von:#:{
  if (%on != on) { 
    msg $chan %tag Vote Now! %tag
    msg $chan %tag Topic: %vtopic
    msg $chan %tag Vote: `yes or `no
    enable #group2
    set %vote on 
  }
}
#group2 on
on 1:TEXT:`yes:#:{
  if (%vote == on) {
    inc %vyes 1
    msg $chan  %tag 7 $nick Voted Yes!
    msg $chan %tag Yes: %vyes No: %vno 
  }
}
on 1:TEXT:`no:#:{
  if (%vote == on) {
    inc %vno 1
    msg $chan %tag 7 $nick Voted No!
    msg $chan %tag Yes: %vyes No: %vno 
  }
}
#group2 off
on 10:TEXT:`vstop:#:{
  if (%vote == on) { 
    msg $chan %tag Voting Stopped. %tag
    msg $chan %tag Topic: %vtopic
    msg $chan %tag Totals: %tag
    msg $chan %tag Yes: %vyes No: %vno
    set %vyes 0
    set %vno 0
    set $vtopic NetBot Ver.1 -=Phase=-
    disable #group2
    set %vote off 
  }
}


EDIT: Formatted the script code to better fit the forums. -Hammer

Last edited by Hammer; 23/03/04 02:02 AM.

Link Copied to Clipboard