This is the updated version, it's more cleaner, and it suplies more information. (please beware, if three or more options have the same vote, the grammer will be terrible [e.i. yes and no and maybe and something])
So, just use this poll for many miscellaneous things. The reason I made the poll allowation of write in's is because it can get annoying sometimes. (It automatically sets the poll to forbid write in's, so if you're doing a poll that may require a write in, be sure to turn it on. (e.i. a new character creation poll)
!poll - Displayes the current poll (If one is active)
!makepoll - Sets the position for a poll to be created (if there isn't a poll already going)
!topic - Sets the poll's topic/title
!opt - Sets an option to your topic
!end - moves on in the step process
!polltime - Sets the polltime (how long your poll will be up) on the current poll
!endpoll - Ends the poll (mainly used for polls running on infinite time)
!vote (#) - Votes the number of an option, you may only vote once
!write - Writes in an extra option to the poll, this is just like voting for that option, only adding it to the poll misconseptionally (I figure it'd bring more amusement to the poll era)
!writeyes - allows the ability to write in a ballet on your poll
!writeno - forbids the ability to write in a ballet on your poll
Please, please, please, please tell me if there's any bugs, so I may correct them towards your satisfaction with this snippet.
on *:text:*:#:{
If ($strip($1-) == !Poll) {
if (!%poll) { msg # There isn't a poll going at the time, make one with !makepoll }
else { display.poll $chan }
}
if ($strip($1-) == !makepoll) {
if (%poll) { msg # There's already a poll going, type !poll to recieve the information }
else {
set %pmaker $nick
msg # Please type !topic (poll topic)
msg # You can have an infite number of poll options as long as it doesn't disconnect the bot.
}
}
if ($strip($1) == !topic) {
if (%poll) { msg # There's already a poll going, type !Poll to recieve the information }
elseif ($nick != %pmaker) { msg # You didn't start this poll, let %pmaker finish it for them selves }
elseif (%ptopic) { msg # There's already a topic for this poll, it's $qt( %ptopic ) }
elseif (!$2) { msg # Your topic can't be nothing }
else {
set %ptopic $2-
msg # The topic is now: %ptopic
msg # Now type !opt (poll option)
}
}
if ($strip($1) == !opt) {
if (%poll) { msg # There's already a poll going, type !Poll to recieve the information }
elseif ($nick != %pmaker) { msg # You didn't start this poll, let %pmaker finish it for them selves }
elseif (%polltime) { msg # You can't add any more options now }
elseif (!$2) { msg # You can't make a blank option }
else {
inc %options
set %option [ $+ [ [ [ %options ] ] ] ] $2-
msg # $+ %options $+ . %option [ $+ [ [ [ %options ] ] ] ]
if (%options >= 2) { msg # You now have %options options, you can type !end to stop making options, or continue making options. }
}
}
if ($strip($1) == !write) {
if (%votewrite == no) { msg # Sorry $nick $+ , %pmaker has forbidden the ability of writing in a ballet on this poll. }
else {
if (!%poll) { msg # You can't add an option to a non existant poll, type !makepoll to make a poll. }
elseif (%wrote [ $+ [ $nick ] ]) { msg # You've already wrote in an extra option }
elseif (!$2) { msg # You can't write in a blank ballet }
else {
inc %options
set %option [ $+ [ [ [ %options ] ] ] ] $2-
msg # $+ %options $+ . %option [ $+ [ [ [ %options ] ] ] ]
set %wrote [ $+ [ $nick ] ] valid
set %vote [ $+ [ %options ] ] 1
inc %votess
set %voted [ $+ [ $fulladdress ] ] yes
display.poll $chan
}
}
}
if ($strip($1-) == !end) {
if (%poll) { msg # A poll is already going }
elseif ($nick != %pmaker) { msg # Let %pmaker finish the poll for themselves }
elseif (%options < 2) { msg # Please make sure you have atleast 2 poll options, you only have $iif(!%options,0,1) so far. }
elseif (%polltime) { msg # You've already ended option picking }
else {
msg # Now you set how long the poll will be up, use !polltime (number of minutes), or put 0 to make it run forever, but it can't be longer than 2000 minutes.
set.vote
}
}
if ($strip($1) == !polltime) {
if (%poll) { msg # A poll is already going }
elseif ($nick != %pmaker) { msg # Let %pmaker finish the poll for themselves }
elseif (%polltime) { msg # You've already set a poll time }
elseif (!$2) { msg # the polltime can't be blank }
else {
if ($2 > 2000) { msg # Too many minutes, please only set it to 2000 minutes or less, or infinite for infinite }
else {
set %polltime $calc($2 * 60)
if ($2 <= 0) { msg # $2 can't be picked, $nick $+ . }
elseif ($2 == infinite) { say.poll # | set %polltime $false | set %poll on | msg # If you want to unset this poll, type !endpoll. Also, at any point in the poll's life time you may type, !writeyes or !writeno to turn off the ability to write in a ballet | set %votewrite no | halt }
.timer 1 [ [ %polltime ] ] end.poll $chan | set %poll on | say.poll # | msg # If you wish to end the poll early, type !endpoll. Also, at any point in the poll's life time you may type, !writeyes or !writeno to turn off the ability to write in a ballet | set %votewrite no
}
}
}
if ($strip($1-) == !endpoll) {
if (!%poll) { msg # There isn't a poll going }
elseif ($Nick != %pmaker) { msg # You didn't make the poll, so you can't end it }
else { end.poll $chan }
}
if ($strip($1) == !vote) {
if (!%poll) { msg # There isn't a poll right now, make one with !makepoll }
elseif (%voted [ $+ [ $fulladdress ] ]) { notice $Nick You've already voted }
elseif ($2 > %options) { msg # Sorry, there are only %options options available, there is no option number $2 }
elseif (!$2) { msg # You can't vote for nothing, please pick one of the options }
else {
inc %vote [ $+ [ $2 ] ]
inc %votess
set %voted [ $+ [ $fulladdress ] ] yes
notice $nick your vote has been counted
notice $Nick Current Votes for option $2 $+ : $+ $2 $+ . %option [ $+ [ $2 ] ] -- %vote [ $+ [ $2 ] ]
}
}
if ($strip($1-) == !writeyes) {
if ($nick != %pmaker) { msg # You can't decide this function, only %pmaker can. }
else { set %votewrite yes }
}
if ($strip($1-) == !writeno) {
if ($nick != %pmaker) { msg # You can't decide this function, only %pmaker can. }
else { set %votewrite no }
}
}
alias say.poll {
:startova
inc %poll#
msg $1 $+ %poll# $+ . %option [ $+ [ [ [ %poll# ] ] ] ]
if (%poll# == %options) { msg $1 Please type !Vote (number) | unset %poll# }
else { goto startova }
}
alias set.vote {
:sterova
inc %vote#
set %vote [ $+ [ [ [ %vote# ] ] ] ] 0
if (%vote# == %options) { unset %vote# }
else { goto sterova }
}
alias end.poll {
:again
inc %number
msg $1 $+ %number $+ . %option [ $+ [ [ [ %number ] ] ] ] -- %vote [ $+ [ %number ] ]
set %vote.ini $iif(%vote.ini, [ [ %vote.ini ] ] $+ . ) $+ %vote [ $+ [ [ [ %number ] ] ] ]
writeini poll.ini vote %vote [ $+ [ [ [ %number ] ] ] ] $iif($readini(poll.ini,vote,%vote [ $+ [ [ [ %number ] ] ] ]),$readini(poll.ini,vote,%vote [ $+ [ [ [ %number ] ] ] ]) and %option [ $+ [ %number ] ],%option [ $+ [ %number ] ])
if (%number == %options) {
msg $1 there was $iif(%votess, [ [ %votess ] ], 0) vote(s)
set %vote.ini2 $sorttok( $mid(%vote.ini,1,$pos(%vote.ini, $chr(46), 1)), 46, nr)
msg $1 The options(s) with %vote.ini2 vote(s) is $readini(poll.ini,vote, [ [ [ [ %vote.ini2 ] ] ] ])
remini poll.ini vote
unset %poll* %vote* %option* %pmaker %polltime %ptopic %num* %wrote*
}
else { goto again }
}
alias display.poll {
msg $1 Poll's Topic: $+ %ptopic
:ofcourse
inc %num#
msg $1 $+ %num# $+ . %option [ $+ [ [ [ %num# ] ] ] ] -- %vote [ $+ [ [ [ %num# ] ] ] ]
if (%num# == %options) { unset %num# | halt }
else { goto ofcourse }
}
I noticed a small grammar error, this: > alias end.poll {
:again
inc %number
msg $1 $+ %number $+ . %option [ $+ [ [ [ %number ] ] ] ] -- %vote [ $+ [ %number ] ]
set %vote.ini $iif(%vote.ini, [ [ %vote.ini ] ] $+ . ) $+ %vote [ $+ [ [ [ %number ] ] ] ]
writeini poll.ini vote %vote [ $+ [ [ [ %number ] ] ] ] $iif($readini(poll.ini,vote,%vote [ $+ [ [ [ %number ] ] ] ]),$readini(poll.ini,vote,%vote [ $+ [ [ [ %number ] ] ] ]) and %option [ $+ [ %number ] ],%option [ $+ [ %number ] ])
if (%number == %options) {
msg $1 there was $iif(%votess, [ [ %votess ] ], 0) vote(s)
set %vote.ini2 $sorttok( $mid(%vote.ini,1,$pos(%vote.ini, $chr(46), 1)), 46, nr)
msg $1 The options(s) with %vote.ini2 vote(s) is $readini(poll.ini,vote, [ [ [ [ %vote.ini2 ] ] ] ])
remini poll.ini vote
unset %poll %vote %option %pmaker %polltime %ptopic %num %wrote*
}
should be
alias end.poll {
:again
inc %number
msg $1 $+ %number $+ . %option [ $+ [ [ [ %number ] ] ] ] -- %vote [ $+ [ %number ] ]
set %vote.ini $iif(%vote.ini, [ [ %vote.ini ] ] $+ . ) $+ %vote [ $+ [ [ [ %number ] ] ] ]
writeini poll.ini vote %vote [ $+ [ [ [ %number ] ] ] ] $iif($readini(poll.ini,vote,%vote [ $+ [ [ [ %number ] ] ] ]),$readini(poll.ini,vote,%vote [ $+ [ [ [ %number ] ] ] ]) and %option [ $+ [ %number ] ],%option [ $+ [ %number ] ])
if (%number == %options) {
msg $1 there was $iif(%votess, [ [ %votess ] ], 0) vote(s)
set %vote.ini2 $sorttok( $mid(%vote.ini,1,$pos(%vote.ini, $chr(46), 1)), 46, nr)
msg $1 The option(s) with %vote.ini2 vote(s) is $readini(poll.ini,vote, [ [ [ [ %vote.ini2 ] ] ] ])
remini poll.ini vote
unset %poll %vote %option %pmaker %polltime %ptopic %num %wrote*
}
There you go Typo, I made some of th changes you suggested. I just don't use while commands, because everytime I use them, the script fails. =\
So, I cleaned it up a bit, and added the vote accomidation. I actually came up with that way of voting when I was making my Killer Game snippet. So please enjoy, and I hope you find this useful.
Hey trikola, you should put all those On Text events into one large on text event like:
On *:text:*:#:{
if (!%poll) {
if ($1 == !Trigger1) { action 1 }
if ($1 == !Trigger2) { action 2 }
if ($1 == !Trigger3) { action 3 }
}
else { msg # There isn't a poll right now, make one with !makepoll }
}
Also, you should consider using while loops over goto loops and also you can unset more than one item on a line and lastly you should try to leave out the halts when the 'if then else' already handles the halting by not doing anything and ending the routine:
alias end.poll {
var %number = 0
while (%number <= %options) {
inc %number
msg %chal $+ %number $+ . %option [ $+ [ [ [ %number ] ] ] ] -- %vote [ $+ [ %number ] ]
if (%number == %options) { msg %chal there was $iif(%votess, [ [ %votess ] ], 0) vote(s) }
}
unset %poll* %vote* %option* %pmaker %polltime %ptopic %num* %chal %wrote*
}
Instead of:
alias end.poll {
:again
inc %number
msg %chal $+ %number $+ . %option [ $+ [ [ [ %number ] ] ] ] -- %vote [ $+ [ %number ] ]
if (%number == %options) {
msg %chal there was $iif(%votess, [ [ %votess ] ], 0) vote(s)
unset %poll*
unset %vote*
unset %option*
unset %pmaker
unset %polltime
unset %ptopic
unset %num*
unset %chal
unset %wrote*
halt
}
else { goto again }
}
I havent tested this yes but it looks decent.
Maybe ill give it a shot when you try those changes, especially combining all those on texts.