egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Lottery

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
garfwen
Halfop


Joined: 12 Mar 2008
Posts: 61

PostPosted: Mon Dec 01, 2008 12:54 pm    Post subject: Lottery Reply with quote

Hello


Im looking for a simple script like:

Pvt eggdrop:
<GaRfWeN>!start 4
(4 is the number of max users)
<GaRfWeN>!prize CSS-Acount

Channel:
<Eggdrop>Lottery starting! Max users 4
<nick1>!reg
<nick2>!reg
<nick1>!regs
<Eggdrop>Regs atm 2/4: nick1 , nick2
<nick3>!reg
<nick4>!reg
<Eggdrop> Ok we have a winner ! $WinnerNick

The winner should be sorted

Can you do something like that ? Razz

Ty.
Back to top
View user's profile Send private message
tomekk
Master


Joined: 28 Nov 2008
Posts: 255
Location: Oswiecim / Poland

PostPosted: Mon Dec 01, 2008 4:07 pm    Post subject: Reply with quote

Code:
# Author: tomekk
# e-mail:  tomekk/@/oswiecim/./eu/./org
# home page: http://tomekk.oswiecim.eu.org/
#
# Version 0.1
#
# This file is Copyrighted under the GNU Public License.
# http://www.gnu.org/copyleft/gpl.html

bind pub - !start start_proc
bind pub - !prize prize_proc
bind pub - !reg reg_proc
bind pub - !regs regs_proc

set game_status 0
set game_prize ""
set reg_status 0
set max_players 0
set player_list [list]

proc start_proc { nick uhost hand chan arg } {
   global max_players game_status

   if {$game_status == 0} {
      set players_num [lindex [split $arg] 0]

      if {[regexp {^([0-9]+)$} $players_num]} {
         set max_players $players_num
         set game_status 1
      }
   }
}

proc prize_proc { nick uhost hand chan arg } {
   global game_status reg_status max_players game_prize

   if {$game_prize == ""} {
      if {$game_status == 1} {
         if {$arg != ""} {
            set game_prize $arg
            set reg_status 1

            putquick "PRIVMSG $chan :Lottery starting! Max users: $max_players (prize: $game_prize)"
         }
      }
   }
}

proc reg_proc { nick uhost hand chan arg } {
   global reg_status player_list max_players game_status game_prize

   if {$reg_status == 1} {
      set player_exists 0

      foreach new_player $player_list {
         set gimme_host [lindex [split $new_player ";"] 1]
         if {$gimme_host == $uhost} {
            set player_exists 1
            break
         }
      }

      if {$player_exists == 0} {
         lappend player_list "$nick;$uhost"

         if {[llength $player_list] == $max_players} {
            set lottery_winner [expr {int(rand() * $max_players)}]

            set the_winner_is [lindex [split [lindex $player_list $lottery_winner] ";"] 0]

            putquick "PRIVMSG $chan :Ok we have a winner ! $the_winner_is"

            set game_status 0
            set game_prize ""
            set reg_status 0
            set max_players 0
            set player_list [list]
         }
      }
   }
}

proc regs_proc { nick uhost hand chan arg } {
   global reg_status max_players game_prize player_list

   set current_in [llength $player_list]

   set rdy_player_list [list]

   foreach lt_player $player_list {
      if {$lt_player != ""} {
         set need_only_nick [lindex [split $lt_player ";"] 0]
         lappend rdy_player_list $need_only_nick
      }
   }

   if {$rdy_player_list == ""} {
      set rdy_player_list "-"
   } {
      set rdy_player_list [join $rdy_player_list ", "]
   }

   if {$reg_status == 1} {
      putquick "PRIVMSG $chan :Regs atm $current_in/$max_players: $rdy_player_list (prize: $game_prize)"
   }
}

putlog "lottery.tcl ver 0.1 by tomekk loaded"


try it Wink

there can't be two nicks with the same name in da lottery Smile (based on user host)

script is working in "memory", after restart u need to start lottery again etc.. Smile
Back to top
View user's profile Send private message Visit poster's website
garfwen
Halfop


Joined: 12 Mar 2008
Posts: 61

PostPosted: Fri Dec 05, 2008 4:36 pm    Post subject: Reply with quote

its working Razz

thanks !!! Very Happy
Back to top
View user's profile Send private message
tomekk
Master


Joined: 28 Nov 2008
Posts: 255
Location: Oswiecim / Poland

PostPosted: Sun Dec 27, 2015 1:44 pm    Post subject: Reply with quote

added: !stop, !lottery commands, setup commands for ops or everyone (configured in script)
fixed: some logic in the script

Update on request.

Code:
# Author: tomekk
# e-mail:  tomekk/@/tomekk/./org
# home page: http://tomekk.org/
#
# Version 0.2
#
# This file is Copyrighted under the GNU Public License.
# http://www.gnu.org/copyleft/gpl.html

# lottery setup (stop/start/prize) only for channel ops?
# 1 - only ops
# 0 - everyone
set lottery_setup_for_ops 1

bind pub - !start start_proc
bind pub - !stop stop_proc
bind pub - !prize prize_proc
bind pub - !lottery lottery_proc
bind pub - !reg reg_proc
bind pub - !regs regs_proc

proc set_defaults {} {
   global game_status game_prize reg_status max_players player_list started_by

   set game_status 0
   set game_prize ""
   set reg_status 0
   set max_players 0
   set player_list [list]
   set started_by ""
}

set_defaults

proc start_proc { nick uhost hand chan arg } {
   global max_players game_status started_by lottery_setup_for_ops

   if {$lottery_setup_for_ops == 1} {
      if {[isop $nick $chan] == 0} {
         putquick "PRIVMSG $chan :Sorry, @ needed."
         return
      }
   }

   if {$game_status == 0} {
      set players_num [lindex [split $arg] 0]

      if {[regexp {^([0-9]+)$} $players_num]} {
         set max_players $players_num
         set game_status 1
         set started_by "$nick <$uhost>"
      }
   } else {
      putquick "PRIVMSG $chan :Lottery already started by: $started_by"
   }
}

proc stop_proc { nick uhost hand chan arg } {
   global game_status lottery_setup_for_ops

   if {$lottery_setup_for_ops == 1} {
      if {[isop $nick $chan] == 0} {
         putquick "PRIVMSG $chan :Sorry, @ needed."
         return
      }
   }

   if {$game_status == 1} {
      putquick "PRIVMSG $chan :Lottery wiped."

      set_defaults
   } else {
      putquick "PRIVMSG $chan :Lottery not started."
   }
}

proc prize_proc { nick uhost hand chan arg } {
   global game_status reg_status max_players game_prize lottery_setup_for_ops

   if {$lottery_setup_for_ops == 1} {
      if {[isop $nick $chan] == 0} {
         putquick "PRIVMSG $chan :Sorry, @ needed."
         return
      }
   }

   if {$game_prize == ""} {
      if {$game_status == 1} {
         if {$arg != ""} {
            set game_prize $arg
            set reg_status 1

            putquick "PRIVMSG $chan :Lottery starting! Max users: $max_players (prize: $game_prize)"
         }
      } else {
         putquick "PRIVMSG $chan :Lottery not started."
      }
   } else {
      putquick "PRIVMSG $chan :Prize already set: $game_prize"
   }
}

proc lottery_proc { nick uhost hand chan arg } {
   global game_status game_prize max_players started_by

   if {$game_status == 1} {
      if {$game_prize != ""} {
         putquick "PRIVMSG $chan :Lottery started by: $started_by, max players: $max_players, prize: $game_prize"
      } else {
         putquick "PRIVMSG $chan :Lottery started by: $started_by, max players: $max_players, prize: *not set*"
      }
   } else {
      putquick "PRIVMSG $chan :Lottery not started."
   }
}

proc reg_proc { nick uhost hand chan arg } {
   global reg_status player_list max_players game_status game_prize

   if {$reg_status == 1} {
      set player_exists 0

      foreach new_player $player_list {
         set gimme_host [lindex [split $new_player ";"] 1]
         if {$gimme_host == $uhost} {
            set player_exists 1
            break
         }
      }

      if {$player_exists == 0} {
         lappend player_list "$nick;$uhost"

         if {[llength $player_list] == $max_players} {
            set lottery_winner [expr {int(rand() * $max_players)}]

            set the_winner_is [lindex [split [lindex $player_list $lottery_winner] ";"] 0]

            putquick "PRIVMSG $chan :Ok we have a winner ! $the_winner_is"

            set_defaults   
         }
      }
   } else {
      putquick "PRIVMSG $chan :Prize not set, can't register - sorry."
   }
}

proc regs_proc { nick uhost hand chan arg } {
   global reg_status max_players game_prize player_list

   if {$reg_status == 1} {
      set current_in [llength $player_list]

      set rdy_player_list [list]

      foreach lt_player $player_list {
         if {$lt_player != ""} {
            set need_only_nick [lindex [split $lt_player ";"] 0]
            lappend rdy_player_list $need_only_nick
         }
      }

      if {$rdy_player_list == ""} {
         set rdy_player_list "-"
      } {
         set rdy_player_list [join $rdy_player_list ", "]
      }

      if {$current_in > 0} {
         putquick "PRIVMSG $chan :Regs atm $current_in/$max_players: $rdy_player_list (prize: $game_prize)"
      } else {
         putquick "PRIVMSG $chan :No regs atm."
      }
   } else {
      putquick "PRIVMSG $chan :Prize not set, so no regs stats."
   }
}

putlog "lottery.tcl ver 0.2 by tomekk loaded"
Back to top
View user's profile Send private message Visit poster's website
asL_pLs
Voice


Joined: 02 May 2016
Posts: 18

PostPosted: Wed Apr 28, 2021 2:03 am    Post subject: Reply with quote

!start not working .. its not showing in the channel
Back to top
View user's profile Send private message AIM Address
CrazyCat
Owner


Joined: 13 Jan 2002
Posts: 877
Location: France

PostPosted: Wed Apr 28, 2021 11:10 am    Post subject: Reply with quote

Don't double-post, don't do thread-necrophilia
_________________
https://www.eggdrop.fr
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
asL_pLs
Voice


Joined: 02 May 2016
Posts: 18

PostPosted: Wed Apr 28, 2021 1:05 pm    Post subject: Reply with quote

DasBrain wrote:
The documentation for the script is essentially:

Quote:
#well just read the script, you'll understand :p


sorry my bad..
see here what i mean..
Code:
https://pasteboard.co/JZrJCsh.jpg

already set for everyone..
Code:
https://pasteboard.co/JZrK1ov.jpg

nothing to show in the channel..

one more thing, if the bot join multiple channels.. it will enable the game to all channels.

please help, i don't know how to do scripts, i only test and use it.. im using eggdrop1.6.21

thanks in advance.
Back to top
View user's profile Send private message AIM Address
CrazyCat
Owner


Joined: 13 Jan 2002
Posts: 877
Location: France

PostPosted: Thu Apr 29, 2021 10:40 am    Post subject: Reply with quote

The script lacks an error message.
The command is !start <nb players>
_________________
https://www.eggdrop.fr
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
asL_pLs
Voice


Joined: 02 May 2016
Posts: 18

PostPosted: Thu Apr 29, 2021 11:25 am    Post subject: Reply with quote

i tried that option already.. but still no luck..
Back to top
View user's profile Send private message AIM Address
CrazyCat
Owner


Joined: 13 Jan 2002
Posts: 877
Location: France

PostPosted: Thu Apr 29, 2021 12:00 pm    Post subject: Reply with quote

Replace the actual start_proc:
Code:
proc start_proc { nick uhost hand chan arg } {
   global max_players game_status started_by lottery_setup_for_ops

   if {$lottery_setup_for_ops == 1} {
      if {[isop $nick $chan] == 0} {
         putquick "PRIVMSG $chan :Sorry, @ needed."
         return
      }
   }

   if {$game_status == 0} {
      set players_num [lindex [split $arg] 0]

      if {[regexp {^([0-9]+)$} $players_num]} {
         set max_players $players_num
         set game_status 1
         set started_by "$nick <$uhost>"
      }
   } else {
      putquick "PRIVMSG $chan :Lottery already started by: $started_by"
   }
}


with this one:
Code:
proc start_proc { nick uhost hand chan arg } {
   global max_players game_status started_by lottery_setup_for_ops
   if {$lottery_setup_for_ops == 1} {
      if {[isop $nick $chan] == 0} {
         putquick "PRIVMSG $chan :Sorry, @ needed."
         return
      }
   }
   putserv "PRIVMSG $chan :ok, tryin' to start"
   if {$game_status == 0} {
      set players_num [lindex [split $arg] 0]
      if {[regexp {^([0-9]+)$} $players_num]} {
         set max_players $players_num
         set game_status 1
         set started_by "$nick <$uhost>"
      } else {
         putserv "PRIVMSG $chan :Syntax is !start <nb players>"
      }
   } else {
      putquick "PRIVMSG $chan :Lottery already started by: $started_by"
   }
}

_________________
https://www.eggdrop.fr
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
asL_pLs
Voice


Joined: 02 May 2016
Posts: 18

PostPosted: Thu Apr 29, 2021 2:37 pm    Post subject: Reply with quote

thank you CrazyCat for the reply.. i have added the code as you posted.

see below;


Code:
# Author: tomekk
# e-mail:  tomekk/@/tomekk/./org
# home page: http://tomekk.org/
#
# Version 0.2
#
# This file is Copyrighted under the GNU Public License.
# http://www.gnu.org/copyleft/gpl.html

# lottery setup (stop/start/prize) only for channel ops?
# 1 - only ops
# 0 - everyone
set lottery_setup_for_ops 0

bind pub - !start start_proc
bind pub - !stop stop_proc
bind pub - !prize prize_proc
bind pub - !lottery lottery_proc
bind pub - !reg reg_proc
bind pub - !regs regs_proc

proc set_defaults {} {
   global game_status game_prize reg_status max_players player_list started_by

   set game_status 0
   set game_prize "0"
   set reg_status 0
   set max_players 0
   set player_list [list]
   set started_by ""
}

set_defaults

proc start_proc { nick uhost hand chan arg } {
   global max_players game_status started_by lottery_setup_for_ops
   if {$lottery_setup_for_ops == 1} {
      if {[isop $nick $chan] == 0} {
         putquick "PRIVMSG $chan :Sorry, @ needed."
         return
      }
   }
   putserv "PRIVMSG $chan :ok, tryin' to start"
   if {$game_status == 0} {
      set players_num [lindex [split $arg] 0]
      if {[regexp {^([0-9]+)$} $players_num]} {
         set max_players $players_num
         set game_status 1
         set started_by "$nick <$uhost>"
      } else {
         putserv "PRIVMSG $chan :Syntax is !start <nb players>"
      }
   } else {
      putquick "PRIVMSG $chan :Lottery already started by: $started_by"
   }
}

proc stop_proc { nick uhost hand chan arg } {
   global game_status lottery_setup_for_ops

   if {$lottery_setup_for_ops == 1} {
      if {[isop $nick $chan] == 0} {
         putquick "PRIVMSG $chan :Sorry, @ needed."
         return
      }
   }

   if {$game_status == 1} {
      putquick "PRIVMSG $chan :Lottery wiped."

      set_defaults
   } else {
      putquick "PRIVMSG $chan :Lottery not started."
   }
}

proc prize_proc { nick uhost hand chan arg } {
   global game_status reg_status max_players game_prize lottery_setup_for_ops

   if {$lottery_setup_for_ops == 1} {
      if {[isop $nick $chan] == 0} {
         putquick "PRIVMSG $chan :Sorry, @ needed."
         return
      }
   }

   if {$game_prize == ""} {
      if {$game_status == 1} {
         if {$arg != ""} {
            set game_prize $arg
            set reg_status 1

            putquick "PRIVMSG $chan :Lottery starting! Max users: $max_players (prize: $game_prize)"
         }
      } else {
         putquick "PRIVMSG $chan :Lottery not started."
      }
   } else {
      putquick "PRIVMSG $chan :Prize already set: $game_prize"
   }
}

proc lottery_proc { nick uhost hand chan arg } {
   global game_status game_prize max_players started_by

   if {$game_status == 1} {
      if {$game_prize != ""} {
         putquick "PRIVMSG $chan :Lottery started by: $started_by, max players: $max_players, prize: $game_prize"
      } else {
         putquick "PRIVMSG $chan :Lottery started by: $started_by, max players: $max_players, prize: *not set*"
      }
   } else {
      putquick "PRIVMSG $chan :Lottery not started."
   }
}

proc reg_proc { nick uhost hand chan arg } {
   global reg_status player_list max_players game_status game_prize

   if {$reg_status == 1} {
      set player_exists 0

      foreach new_player $player_list {
         set gimme_host [lindex [split $new_player ";"] 1]
         if {$gimme_host == $uhost} {
            set player_exists 1
            break
         }
      }

      if {$player_exists == 0} {
         lappend player_list "$nick;$uhost"

         if {[llength $player_list] == $max_players} {
            set lottery_winner [expr {int(rand() * $max_players)}]

            set the_winner_is [lindex [split [lindex $player_list $lottery_winner] ";"] 0]

            putquick "PRIVMSG $chan :Ok we have a winner ! $the_winner_is"

            set_defaults   
         }
      }
   } else {
      putquick "PRIVMSG $chan :Prize not set, can't register - sorry."
   }
}

proc regs_proc { nick uhost hand chan arg } {
   global reg_status max_players game_prize player_list

   if {$reg_status == 1} {
      set current_in [llength $player_list]

      set rdy_player_list [list]

      foreach lt_player $player_list {
         if {$lt_player != ""} {
            set need_only_nick [lindex [split $lt_player ";"] 0]
            lappend rdy_player_list $need_only_nick
         }
      }

      if {$rdy_player_list == ""} {
         set rdy_player_list "-"
      } {
         set rdy_player_list [join $rdy_player_list ", "]
      }

      if {$current_in > 0} {
         putquick "PRIVMSG $chan :Regs atm $current_in/$max_players: $rdy_player_list (prize: $game_prize)"
      } else {
         putquick "PRIVMSG $chan :No regs atm."
      }
   } else {
      putquick "PRIVMSG $chan :Prize not set, so no regs stats."
   }
}

putlog "lottery.tcl ver 0.2 by tomekk loaded"



but then, this script need to be modified after all.


Code:

<@JohnDoe> !start
<@Janebot> ok, tryin' to start
<@Janebot> Syntax is !start <nb players>
<@JohnDoe> !start 10
<@Janebot> ok, tryin' to start
<@JohnDoe> !lottery
<@Janebot> Lottery started by: JohnDoe <jd@[censored].happens>, max players: 10, prize: 1000000


Another...

Code:

<@JohnDoe> !start 4
<@Janebot> ok, tryin' to start
<@testers> !prize 1000000000
<@Janebot> Prize already set: 1000000
<@testers> !regs
<@Janebot> Prize not set, so no regs stats.
<@testers> !reg
<@Janebot> Prize not set, so no regs stats.




Thank you for the help CrazyCat..
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber