mIRC Home    About    Download    Register    News    Help

Print Thread
#113147 01/03/05 04:53 PM
Joined: Feb 2005
Posts: 16
J
jkouzes Offline OP
Pikka bird
OP Offline
Pikka bird
J
Joined: Feb 2005
Posts: 16
I need a script that will allow the chatters to vote on whether or not game/s should be played.... when they type in !trivia and the like...

The chatroom isnt a gaming room really, but... some ppl are rude and come in only to play the games....

Sooooo... when they type in the command to start the game... I would like it to automatically start a poll of the ppl in the room, in they dont vote its not a issue either... basically a timed response... no vote cast... no vote made.... it takes whomever voted and tallies the results .. if playing the game wins, the game starts automatically. If not... chatting continues.

After say... 5 mins the votes are reset, and ppl can vote again. If the game is stopped or they want to play another game...

SO.... HELP!!!

#113148 01/03/05 05:57 PM
Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Sorry, I kinda rushed this..

[18:09] <Vote> Type !result to view the poll results.
[18:09] <me> !result
[18:09] <Vote> 5 people voted...
[18:09] <Vote> Andy voted No
[18:09] <Vote> mairi voted Yes
[18:09] <Vote> me voted Yes
[18:09] <Vote> betty voted No
[18:09] <Vote> Donna voted Yes

Code:
alias votes {
  if ($group(#votes) == on) { 
    echo -a Voting game already on. 
  }
  elseif ($group(#votes) == off) { 
    if ($active ischan) {
      set %vote.chan $chan    
      set %vote.question $$1-
      .enable #votes
      msg %vote.chan Voting started.
      msg %vote.chan Question: %vote.question
      msg %vote.chan Type either !vote yes or !vote no.
      msg %vote.chan You have 5 minutes starting now!
      vote.init
    }
  }
}

alias vote.init {
  .timer 1 60 msg %vote.chan You have 4 minutes remaining.
  .timer 1 120 msg %vote.chan You have 3 minutes remaining.
  .timer 1 180 msg %vote.chan You have 2 minutes remaining.
  .timer 1 240 msg %vote.chan You have 1 minute remaining.  Hurry!!
  .timer 1 300 msg %vote.chan Your time is up!
  .timer 1 302 msg %vote.chan Type !result to view the poll results.
}

#votes off
on 1:Text:!vote *:%vote.chan: {
  if (!$hget(votes)) { hmake votes 1000 } 
  if (yes == $2) {
    if ($hfind(votes,$nick)) {
      .notice $nick You have already voted, don't be greedy. 
    }
    elseif (!$hfind(votes,$nick)) { 
      .notice $nick Your vote has been casted. 
      hadd votes $nick Yes 
    }
  }
  if (no == $2) {
    if ($hfind(votes,$nick)) {
      .notice $nick You have already voted, don't be greedy.
    }
    elseif (!$hfind(votes,$nick)) {
      .notice $nick Your vote has been casted. 
      hadd votes $nick No 
    }
  }
}

on 1:Text:!result*:%vote.chan: {
  var %result = $hget(votes,0).item
  msg %vote.chan %result people voted...
  while (%result) {
    msg %vote.chan $hget(votes,%result).item voted $hget(votes,%result).data
    dec %result
  }
  .hfree votes
  .disable #votes
  unset %vote.*
} 
#votes end

Last edited by SladeKraven; 01/03/05 06:11 PM.
#113149 01/03/05 06:07 PM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Hmm andy,

instead of doing:

if (v1 == v2) {
do things
}
elseif (v1 != v2) {
do other things
}

You could do:

if (v1 == v2) {
do things
}
else {
do other things
}

In other words, there's no point in checking the v1 != v2, since we know that already, otherwise the above if would have triggered instead. Since the parser made it to the elseif, the first if condition is false, or in other words v1 != v2

Greets


Gone.
#113150 01/03/05 06:14 PM
Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Cheers mate smile

It's just something I have always done, will be hard to stop myself from doing it now hehe.. grin

Code:
alias vote {
  if ($group(#votes) == on) { 
    echo -a Voting game already on. 
  }
  else { 
    if ($active ischan) {
      set %vote.chan $chan    
      set %vote.question $$1-
      .enable #votes
      msg %vote.chan Voting started.
      msg %vote.chan Question: %vote.question
      msg %vote.chan Type either !vote yes or !vote no.
      msg %vote.chan You have 5 minutes starting now!
      vote.init
    }
  }
}

alias vote.init {
  .timer 1 60 msg %vote.chan You have 4 minutes remaining.
  .timer 1 120 msg %vote.chan You have 3 minutes remaining.
  .timer 1 180 msg %vote.chan You have 2 minutes remaining.
  .timer 1 240 msg %vote.chan You have 1 minute remaining.  Hurry!!
  .timer 1 300 msg %vote.chan Your time is up!
  .timer 1 302 msg %vote.chan Type !result to view the poll results.
}

#votes off
on 1:Text:!vote *:%vote.chan: {
  if (!$hget(votes)) {
    hmake votes 1000
  } 
  if (yes == $2) {
    if ($hfind(votes,$nick)) {
      notice $nick You have already voted, don't be greedy.
    }
    else { 
      notice $nick Your vote has been casted. 
      hadd votes $nick Yes 
    }
  }
  elseif (no == $2) {
    if ($hfind(votes,$nick)) {
      notice $nick You have already voted, don't be greedy.
    }
    else {
      notice $nick Your vote has been casted. 
      hadd votes $nick No 
    }
  }
}

on 1:Text:!result*:%vote.chan: {
  var %result = $hget(votes,0).item
  msg %vote.chan %result people voted...
  while (%result) {
    msg %vote.chan $hget(votes,%result).item voted $hget(votes,%result).data
    dec %result
  }
  .hfree votes
  .disable #votes
  unset %vote.*
} 
#votes end


Last edited by SladeKraven; 01/03/05 07:07 PM.
#113151 02/03/05 04:15 AM
Joined: Feb 2005
Posts: 16
J
jkouzes Offline OP
Pikka bird
OP Offline
Pikka bird
J
Joined: Feb 2005
Posts: 16
This is what I came up with... it works but it doesnt work... that is... it doesnt start the game.... GRRRRRR

menu channel {
***Hangman***
.$iif($group(#hangman) == on,$style(2),$style(0)) On: .enable #hangman | echo -a 0,12Hangman Game ON $+ 0,95 On
.$iif($group(#handman) == off,$style(2),$style(0)) Off: .disable #hangman | echo -a 0,12Hangman Game OFF $+ 0,4 Off
}

#hangman on
;alias hc1 { return 03 }
;alias hc2 { return 12 }
; Remove ; to restore Hangman next two lines
;on *:Text:!hangman*:#:{ do.hang $1- }
on *:Text:!hangman*:#:{ startvote }
on *:Input:#:{ if ((.* iswm $1) || (!* iswm $1)) { do.hang ! $+ $right($1-,-1) } }

; Voting script...... start
on *:TEXT:(y):#: {
if (%voting == on) { yesvote $nick }
}
on *:TEXT:(n):#: {
if (%voting == on) { novote $nick }
}

alias startvote {
if (%voting != on) {
set %voting on
set %starter $1
set %result
msg $chan Voting started. Type (Y) if you want Hangman to start, or type (N) if you don't.
; msg $chan S $asc(1)Tahoma;0 !shang 
timer1 1 20 /stopvote
}
}

alias yesvote {
if ($1 isin %votedyes) {
notice $1 Multiple votes will not be counted.
}
else {
set %votedyes %votedyes $1
inc %yesvotes
if ($1 isin %votedno) {
set %votedno $remtok(%votedno,$1,32)
set %novotes $calc( %novotes - 1 )
notice $1 You changed your vote successfully.
}
notice $1 Thanks for voting!
}
}

alias novote {
if ($1 isin %votedno) {
notice $1 Multiple votes will not be counted.
}
else {
set %votedno %votedno $1
inc %novotes
if ($1 isin %votedyes) {
set %votedyes $remtok(%votedyes,$1,32)
set %yesvotes $calc( %yesvotes - 1 )
notice $1 You changed your vote successfully.
}
notice $1 Thanks for voting!
}
}

alias stopvote {
set %voting
if (%yesvotes == 0) && (%novotes == 0) {
set %result 2
set %comment No votes!
}
elseif (%novotes == 0) && (%yesvotes > 0) {
set %result 1
set %comment It's unanimous!
}
elseif (%novotes > 0) && (%yesvotes == 0) {
set %result -1
set %comment People here are trying to chat, %starter $+ !
}
elseif (%yesvotes == $calc( %novotes + 1 ) ) || (%yesvotes == $calc( %novotes - 1 ) ) {
set %comment It's a close one... want a recount?
if (%yesvotes > %novotes) { set %result 1 }
else { set %result -1 }
}
elseif (%yesvotes == %novotes) {
set %result 0
set %comment It's a draw!
}
elseif (%yesvotes > %novotes) {
set %result 1
set %comment
}
else {
set %result -1
set comment
}
ame counts the votes
amsg Ballot Result: (Y) = %yesvotes (N) = %novotes %comment
if (%starter !isin %votedyes) { amsg That was stupid, %starter $+ . You started it and didn't vote "(Y)" yourself! }
if (%result == 1) { do.hang $1- }
if (%result == 0) { amsg Only half want to start hangman - the other half are chatting. I won't start it - sorry! }
if (%result == -1) { amsg The majority don't want hangman. I won't start it - sorry! }
set %yesvotes 0
set %novotes 0
set %votedyes
set %votedno
set %result
}


; Voting script ..... end
alias do.hang {
if (($1 == !hangman) && (!$hget(hangman))) {
hmake hangman 10
hadd hangman word $read(hangman.txt)
hadd hangman chan $chan
hadd hangman man $iif($2 ison $chan, $2, $nick($chan, $rand(1,$nick($chan,0))))
hmsg $msg.hang.start
}
if (!$hget(hangman)) { return }
if ($1 == !shang) {
hmsg $msg.hang.stop
hfree hangman
halt
}
if ($1 == !solve) {
if ($2- == $hget(hangman,word)) Goto MazelTOV
hmsg Oy Vey are you WRONG!!!. Maybe I should just hang poor ol' $hget(hangman,man)
Return
:MazelTOV
hmsg $msg.hang.solve
hang.define
hfree hangman
halt
}
if ($1 == !hang) {
if (($2 !isalpha) || ($len($2) != 1)) {
hmsg Ya Schlemiel!! You gotta pick a letter! Sheesh!!!
return
}
elseif ($hget(hangman,Picked. $+ $2)) {
hmsg Sheesh Putz!!.. Try picking a letter that somebody else hasn't picked. :@
return
}
else {
hadd hangman Picked. $+ $2 1
if ($2 isin $hget(hangman,word)) {
hmsg $msg.hang.right
hang.checkwin
}
else {
var %hang.part = $hang.part
hmsg $msg.hang.wrong(%hang.part)
}
}
}
}
alias hang.part {
hadd hangman wrong $calc($hget(hangman, wrong) + 1)
if ($hang.partname($hget(hangman, wrong)) == hanging) {
hmsg $msg.hang.dead
hfree hangman
halt
}
return $hang.partname($hget(hangman, wrong))
}
alias hang.checkwin {
if ($hang.got != $hget(hangman,word)) { return }
hmsg $msg.hang.save
hang.define
hfree hangman
halt
}

; ****** Defination Starts
alias hang.define {
%dictword = $hget(hangman, word)
%dictlines = $readini %dictname %dictword lines
%dictline = 1
while ( %dictline <= %dictlines ) {
%dicttext = $readini %dictname %dictword %dictline
hmsg $msg.hang.define
inc %dictline
}
}

;******** End of Definations ***********


alias hang.partname { return $gettok(head;neck;torso;right arm;left arm;right hand;left hand;right leg;left leg;right foot;left foot;hanging, $1, $asc(;)) }
alias hang.got {
var %i = 1,%hang.got = $hget(hangman, word)
unset %hang.left
while (%i <= 26) {
if (!$hget(hangman, Picked. $+ $chr($calc(96 + %i)))) {
%hang.got = $replace(%hang.got, $chr($calc(96 + %i)), * )
set -u120 %hang.left %hang.left $+ $chr($calc(96 + %i))
}
inc %i
}
return %hang.got
}
alias hmsg { msg $$hget(hangman,chan) $1- }
alias msg.hang.clue { return Current clue: $hang.got Letters remaining: %hang.left }
alias msg.hang.save { return $hget(hangman,man) is saved! L'Chaim!! laugh You're the best Chaverim a person could want. Word: $hget(hangman,word) }
alias msg.hang.solve { return Mazel Tov!!!! laugh $nick $+ , You're guess the correct word, $hget(hangman,man) is saved! L'Chaim!! laugh Word: $hget(hangman,word) }
alias msg.hang.dead { return $hget(hangman,man) is DEAD, DOA, Rest in Peace! :'( With chaverim like these who needs enemies. Word: $hget(hangman,word) }
alias msg.hang.wrong { return Oy vey zmir! shocked $hget(hangman, man) $+ , is one step closer to death, the grim reaper. You just got $hget(hangman, man) $+ 's $1 $msg.hang.clue }
alias msg.hang.right { return Mazel Tov!!!! laugh $nick $+ , You picked a correct letter. laugh $msg.hang.clue }
alias msg.hang.start { return Get ready for some hangman... We are hanging $hget(hangman,man) $+ , unless you can prevent it. !hang <letter> to guess a letter. To stop hangman - !shang $msg.hang.clue }
alias msg.hang.define { return Meaning: %dicttext }
alias msg.hang.stop { return Game stopped by $nick $+ ,... To play again !hangman (for a random name leave blank, to specify a nick... !hangman <nick>) }

#hangman end

#113152 04/03/05 01:54 AM
Joined: Feb 2005
Posts: 16
J
jkouzes Offline OP
Pikka bird
OP Offline
Pikka bird
J
Joined: Feb 2005
Posts: 16
Can someone please help me figure out why the above script will not automatically start the hangman game.....

Please

#113153 04/03/05 11:08 PM
Joined: Aug 2003
Posts: 1,831
I
Hoopy frood
Offline
Hoopy frood
I
Joined: Aug 2003
Posts: 1,831
Just at a quick read...
  • timer1 1 20 /stopvote
...
...
...
  • if (%result == 1) { do.hang $1- }


You aren't passing any $1- on to the stopvote alias, so it in turn cannot pass anything on to /do.hang.

#113154 07/03/05 07:03 PM
Joined: Feb 2005
Posts: 16
J
jkouzes Offline OP
Pikka bird
OP Offline
Pikka bird
J
Joined: Feb 2005
Posts: 16
ok.... Soooo! How do I fix it??? I have no idea


Me stupid when comes to programming

confused


Link Copied to Clipboard