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.