////NOTE: I MADE THIS SCRIPT IN LIKE 2 MINUTES////
.survey - to view survey
.setsurvey - set new survey
.resetsurv - resets everything
.sa - set option a
.sb - set option b
.sc - set option c
.A - vote A
.B - vote B
.C - vote C
.Total - View total votes
on *:TEXT:*:#: {
if ($1 == .setsurvey) { set %survey $2- }
if ($1 == .sA) { set %optiona $2- }
if ($1 == .sB) { set %optionB $2- }
if ($1 == .sC) { set %optionc $2- }
if ($1 == .survey) { msg $chan %survey | msg $chan A: %optiona | msg $chan B: %optionb | msg $chan C: %optionc | msg $chan To Vote type .A .B or .C }
if ($1 == .A) { inc %surveya | msg $chan A total of %surveya people have voted A }
if ($1 == .B) { inc %surveyb | msg $chan A total of %surveyb people have voted B }
if ($1 == .C) { inc %surveyc | msg $chan A total of %surveyc people have voted C }
if ($1 == .total) { | msg $chan A: %surveya | msg $chan B: %surveyb | msg $chan C: %surveyc }
if ($1 == .resetsurv) { set %surveya 0 | set %surveyb 0 | set %surveyc 0 | set %survey 0 | set %optiona 0 | set %optionb 0 | set %optionc 0 }
if ($1 == .lines) { msg $chan There are 14 lines in this script. }
}
I like the approach taken in this script, as it's a throwback to how we used to write code in simpler languages. You have one event to handle all input, and a simple set of case statements. No bells, no whistles, easy to implement, easy to expand.
Of course, with 12 times the code, you could add all sorts of duplicate-vote checking, flood prevention, time to automatically close voting, ballot secrecy, etc etc. But this snippet is a good example of a smart computer science student.
UK-Sw1ft Said:
I never said it was better, i was just showing an example to how he could use 'ifs', and how a voting script can be made.., so don't jump down my throat -.-.
lol did i say you said it was better? I said "imho = In my honest opinion", and no one is jumping down ur throat so get over ur self.
UK-Sw1ft Said:
http://www.hawkee.com/snippet/7225/
um you never said you were showing them anything all you posted was a link to ur snippet an nothing more.
So to me it looks like ur spamming his snippet with ur's nothing more.....
Adding to Napa's, implement some checks for whether a variable has been added for that specific person's vote, then unset them vars after the message has been sent, and a flood trigger control would be nice.
When you write a script, as per Napa's suggestion, put some thought into it, not just engage in a patchwork and put something together sketchily. Improve it and make your time worthwhile when you go about scripting.
so how come you don't unset them global vars?
imho this snippet looks like it was tossed together in 1 second with no thought.
why don't you spend some time on this and get rid of all them global vars as well as maybe make it so they can only vote once among other things.. like don't have regular users be able to unset/set surveys
Also whats the point of this line?
if ($1 == .lines) { msg $chan There are 14 lines in this script. }
Take some time and..
um keep working on it.....
you seem to have a typo on this line as well
if ($1 == .total) { | msg $chan A: %surveya | msg $chan B: %surveyb | msg $chan C: %surveyc }