Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #-----------------------------------------------------------------------------------#
- # #
- # #
- # Slot_Machine #
- # #
- # #
- # #
- # Usage: #
- # Terminal: .chanset #channel +Slot_Machine #
- # Channel: !Slot_Machine Help #
- # #
- # #
- # #
- # TODO: #
- # - Multi Using #
- # - Message via: Channel, Query or. Notice #
- # - Multi Language #
- # #
- # #
- # ChangeLog: #
- # - MySQL #
- # - General Script #
- # #
- # #
- # Contakt: #
- # Copyright (C) 2012, Diamond85 #
- # E-Mail: Diamond85@gmx.de #
- # #
- # #
- #-----------------------------------------------------------------------------------#
- namespace eval S_M {
- #############################################################################
- # #
- # #
- # Config_Begins #
- # #
- # #
- #############################################################################
- namespace eval G_S {
- #############################################################################
- # General_Settings #
- #############################################################################
- # Set This To The Command Character You Want To Use
- # For The Binds ( ! ? . . . )
- variable gs_char "!"
- # Set These To Your Preferred Binds ( one two . . . )
- variable gs_bind "Slot_Machine Slot SM"
- # (Number Of Seconds) To Ignore Flooders,
- # 0 Will Disable Flood Protection
- variable gs_wait "60"
- # How Many Requests In How Many Seconds Is Considered Flooding?
- # By Default, This Allows 1 Queries In 60 Seconds, The 2th Being Ignored
- # And Ignoring The Flooder For 'variable gs_wait' Seconds
- variable gs_flood "1:60"
- # Add Here The Admin Flags ( m=Master / n=Owner / o=OP . . . )
- # To Enable Or Disable This Script On Channel Commands
- variable gs_flags "+mno|+mno"
- # Set Here The Slot Symbols
- variable gs_symbols {
- "¤"
- "¥"
- "X"
- }
- # Set Here The Slot Text
- variable gs_game_start_text {
- "\00314Spielt an der Slotmaschiene\003."
- "\00314Zieht den Hebel\003."
- "\00314Los gehts\003."
- "\00314Versucht sein Glück an der Slotmaschiene\003."
- "\00314Viel Glück\003."
- "\00314Jetzt Gewinnst du was\003."
- "\00314Alle guten Dinge sind 3\003."
- }
- # Set Here The Slot Text
- variable gs_game_lose_text {
- "\00314Vielleicht klappt es ja beim nächsten Mal\003."
- "\00314Das war leider Nix\003."
- "\00314Du Brauchst mehr Glück\003."
- "\00314So wird das nichts\003."
- "\00314Gib es Lieber auf\003."
- "\00314Ich hatte mal welche dia haben auch Gewonnen\003."
- "\00314Heute ist nicht dein Tag\003."
- }
- }
- namespace eval M_S {
- #############################################################################
- # MySQL_Settings #
- #############################################################################
- # Set Here The MySQL Host
- variable ms_host "localhost"
- # Set Here The MySQL User
- variable ms_user "eggdrop"
- # Set Here The MySQL User Pass
- variable ms_pass "eggdrop"
- # Set Here The MySQL Database
- variable ms_database "eggdrop"
- # Set Here The MySQL Table
- variable ms_table "Slot_Machine"
- }
- #############################################################################
- # #
- # #
- # Config_End #
- # #
- # #
- #############################################################################
- namespace eval M_S {
- #############################################################################
- # MySQL_Settings #
- #############################################################################
- variable ms_handle ""
- variable ms_namelast ""
- package require mysqltcl 3.0
- }
- namespace eval M_A {
- #############################################################################
- # MySQL_Action #
- #############################################################################
- bind evnt - prerehash S_M::M_A::ma_stop
- bind evnt - rehash S_M::M_A::ma_start
- bind evnt - loaded S_M::M_A::ma_start
- bind time - "00 * * * *" S_M::M_A::ma_dirtyhack
- proc ma_dirtyhack {args} {
- S_M::M_A::ma_change $S_M::M_S::ms_table; set xy [S_M::M_A::ma_query "SELECT * from $S_M::M_S::ms_table where 1=2"]
- }
- proc ma_start { args } {
- set S_M::M_S::ms_handle [mysqlconnect -host $S_M::M_S::ms_host -user $S_M::M_S::ms_user -password $S_M::M_S::ms_pass -encoding binary]
- }
- proc ma_stop { args } {
- if {$S_M::M_S::ms_handle != ""} { mysqlclose $S_M::M_S::ms_handle }
- }
- proc ma_change { ms_database } {
- if {$S_M::M_S::ms_namelast != $S_M::M_S::ms_database} {
- set S_M::M_S::ms_namelast $S_M::M_S::ms_database
- mysqluse $S_M::M_S::ms_handle $S_M::M_S::ms_database
- }
- }
- proc ma_query { sql } {
- if {[string toupper [lindex $sql 0]] == "SELECT"} {
- return [mysqlsel $S_M::M_S::ms_handle $sql -list]
- } else {
- mysqlexec $S_M::M_S::ms_handle $sql
- return 0
- }
- }
- }
- namespace eval B_B {
- #############################################################################
- # Bind_Bind #
- #############################################################################
- foreach bind [split $S_M::G_S::gs_bind " "] {
- bind pub -|- "${S_M::G_S::gs_char}$bind" S_M::F_C::fc_check
- }
- }
- namespace eval F_C {
- #############################################################################
- # Flood_Check #
- #############################################################################
- proc fc_check {nick host hand chan arg} {
- if {[matchattr $hand $S_M::G_S::gs_flags]} {
- S_M::S_A::sa_action $nick $host $hand $chan $arg
- return
- }
- if {[channel get $chan $S_M::S_I::si_name]} {
- if {[S_M::F_A::fa_flood $nick $host $hand $chan $arg]} {
- return
- }
- S_M::S_A::sa_action $nick $host $hand $chan $arg
- }
- }
- }
- namespace eval F_A {
- #############################################################################
- # Flood_Action #
- #############################################################################
- variable fa_data
- variable fa_array
- proc fa(init) {} {
- if {![string match *:* $S_M::G_S::gs_flood]} {
- putlog "\003\[\00304$S_M::S_I::si_name\003\] \00314variable \003\(\00309gs_flood\003: \00309$S_M::G_S::gs_flood\003) \00314wurde nicht richtig Eingestellt\003."
- return 1
- }
- set S_M::F_A::fa_data(flood_num) [lindex [split $S_M::G_S::gs_flood :] 0]
- set S_M::F_A::fa_data(flood_time) [lindex [split $S_M::G_S::gs_flood :] 1]
- set i [expr $S_M::F_A::fa_data(flood_num) - 1]
- while {$i >= 0} {
- set S_M::F_A::fa_array($i) 0
- incr i -1
- }
- }
- ; fa(init)
- proc fa_flood {nick host hand chan arg} {
- if {$S_M::F_A::fa_data(flood_num) == 0} {
- return 0
- }
- set i [expr ${S_M::F_A::fa_data(flood_num)} - 1]
- while {$i >= 1} {
- set S_M::F_A::fa_array($i) $S_M::F_A::fa_array([expr $i - 1])
- incr i -1
- }
- set S_M::F_A::fa_array(0) [unixtime]
- if {[expr [unixtime] - $S_M::F_A::fa_array([expr ${S_M::F_A::fa_data(flood_num)} - 1])] <= ${S_M::F_A::fa_data(flood_time)}} {
- S_M::W_A::wa_action $nick $host $hand $chan $arg
- return 1
- } else {
- return 0
- }
- }
- }
- namespace eval W_A {
- #############################################################################
- # Wait_Action #
- #############################################################################
- proc wa_action {nick host hand chan arg} {
- if {[set timeleft [S_M::W_A::wa_throttled $host,$chan $S_M::G_S::gs_wait]]} {
- putnow "PRIVMSG $chan :\003\[\00304$S_M::S_I::si_name\003\] \00309$nick \00314Du darfst erst wieder in \00304$timeleft \00314Sekunden\003!"
- } else {
- S_M::S_A::sa_action $nick $host $hand $chan $arg
- }
- }
- proc wa_throttled {id time} {
- global wa_throttled
- if {[info exists wa_throttled($id)]} {
- return [expr {($wa_throttled($id)+$time)-[clock sec]}]
- } {
- set wa_throttled($id) [clock sec]
- utimer $time [list unset wa_throttled($id)]
- return 0
- }
- }
- }
- namespace eval S_A {
- #############################################################################
- # Start_Action #
- #############################################################################
- proc sa_action {nick host hand chan arg} {
- set arg [split $arg]
- switch -exact -- [lindex $arg 0] {
- "on" {
- if {[matchattr $hand $S_M::G_S::gs_flags]} {
- if {[channel get $chan $S_M::S_I::si_name]} {
- putnow "PRIVMSG $chan :\003\[\00309$S_M::S_I::si_name\003\] \00314ist bereits \00309An\003."
- } else {
- channel set $chan +$S_M::S_I::si_name
- putnow "PRIVMSG $chan :\003\[\00309$S_M::S_I::si_name\003\] \00314ist nun \00309Aktiviert\003."
- }
- }
- }
- "off" {
- if {[matchattr $hand $S_M::G_S::gs_flags]} {
- if {[channel get $chan $S_M::S_I::si_name]} {
- channel set $chan -$S_M::S_I::si_name
- putnow "PRIVMSG $chan :\003\[\00304$S_M::S_I::si_name\003\] \00314ist nun \00304Deaktiviert\003."
- } else {
- putnow "PRIVMSG $chan :\003\[\00304$S_M::S_I::si_name\003\] \00314ist bereits \00304Aus\003."
- }
- }
- }
- "table" {
- if {[matchattr $hand $S_M::G_S::gs_flags]} {
- S_M::M_A::ma_change S_M::M_S::ms_database
- S_M::M_A::ma_query "CREATE TABLE $S_M::M_S::ms_table (Type varchar(10), Chan varchar(50), Nick varchar(50), Points int(10) Default 0, Count int(10) Default 0);"
- putnow "PRIVMSG $chan :\003\[\00309$S_M::S_I::si_name\003\] \00309$nick \00314Ich habe die Tabelle \00309$S_M::M_S::ms_table \003(\00309Type\00314, \00309Chan\00314, \00309Nick\00314, \00309Points, \00309Count\00314) \00314Zur \00309$S_M::M_S::ms_database \00314Datenbank Hinzugefügt\003."
- }
- }
- "version" {
- if {[channel get $chan $S_M::S_I::si_name]} {
- putnow "PRIVMSG $chan :\003\[\00309$S_M::S_I::si_name\003\] \00314Projekt Name\003: \00309$S_M::S_I::si_projektname \003\| \00314Version\003: \00309$S_M::S_I::si_version \003\| \00314Date\003: \00309$S_M::S_I::si_date \003\| \00314CopyRight\003: \00309$S_M::S_I::si_copyright $S_M::S_I::si_copyrightyear \00314by \00309$S_M::S_I::si_author \003\| \00314e\003-\00314Mail\003: \00309$S_M::S_I::si_contact \003\| \00314HomePage\003: \037\00309$S_M::S_I::si_web\037 \003(\00314Status\003: \00309Aktiviert\003)"
- } else {
- putnow "PRIVMSG $chan :\003\[\00304$S_M::S_I::si_name\003\] \00314Projekt Name\003: \00309$S_M::S_I::si_projektname \003\| \00314Version\003: \00309$S_M::S_I::si_version \003\| \00314Date\003: \00309$S_M::S_I::si_date \003\| \00314CopyRight\003: \00309$S_M::S_I::si_copyright $S_M::S_I::si_copyrightyear \00314by \00309$S_M::S_I::si_author \003\| \00314e\003-\00314Mail\003: \00309$S_M::S_I::si_contact \003\| \00314HomePage\003: \037\00309$S_M::S_I::si_web\037 \003(\00314Status\003: \00304Deaktiviert\003)"
- }
- }
- "help" {
- if {[matchattr $hand $S_M::G_S::gs_flags]} {
- if {[channel get $chan $S_M::S_I::si_name]} {
- putnow "PRIVMSG $chan :\003\[\00309$S_M::S_I::si_name\003\] \00314Verfügbare Befehle\003: $S_M::G_S::gs_char\00309$S_M::G_S::gs_bind \003\| \003(\00307Einsatz\003) \| \00309Points \003(\00307Nick\003) \003\| \003(\00307Jackpot\003) \| (\00307Version\003) \| \003(\00304Off\003)"
- } else {
- putnow "PRIVMSG $chan :\003\[\00309$S_M::S_I::si_name\003\] \00314Verfügbare Befehle\003: $S_M::G_S::gs_char\00309$S_M::G_S::gs_bind \003(\00307On\003)"
- }
- } else {
- if {[channel get $chan $S_M::S_I::si_name]} {
- putnow "PRIVMSG $chan :\003\[\00309$S_M::S_I::si_name\003\] \00314Verfügbare Befehle\003: $S_M::G_S::gs_char\00309$S_M::G_S::gs_bind \003\| \003(\00307Einsatz\003) \| \00309Points \003(\00307Nick\003) \003\| \003(\00307Jackpot\003) \| (\00307Version\003)"
- }
- }
- }
- "del" {
- if {[channel get $chan $S_M::S_I::si_name]} {
- if {[matchattr $hand $S_M::G_S::gs_flags]} {
- if {$arg == ""} {
- S_M::M_A::ma_query "DELETE FROM `$S_M::M_S::ms_table` WHERE `Nick` = '[mysqlescape $nick]';"
- putnow "PRIVMSG $chan :\00309$nick\003. \00314Du wurdest aus meiner datenbank \00304gelöscht\003."
- } else {
- if {[S_M::M_A::ma_query "SELECT Points FROM $S_M::M_S::ms_table WHERE Nick = '[mysqlescape $arg]'"] == ""} {
- putnow "PRIVMSG $chan :\00309$nick\003. \00314$arg \00304existierst nicht \00314in meiner Datenbank\003."
- } else {
- S_M::M_A::ma_query "DELETE FROM `$S_M::M_S::ms_table` WHERE `Nick` = '[mysqlescape $arg]';"
- putnow "PRIVMSG $chan :\00309$nick\003. \00314$arg wurde aus meiner datenbank \00304gelöscht\003."
- }
- }
- } else {
- if {[S_M::M_A::ma_query "SELECT Points FROM $S_M::M_S::ms_table WHERE Nick = '[mysqlescape $nik]'"] == ""} {
- putnow "PRIVMSG $chan :\00309$nick\003. \00314Du \00304existierst nicht \00314in meiner Datenbank\003."
- } else {
- S_M::M_A::ma_query "DELETE FROM `$S_M::M_S::ms_table` WHERE `Nick` = '[mysqlescape $nick]';"
- putnow "PRIVMSG $chan :\00309$nick\003. \00314Du wurdest aus meiner datenbank \00304gelöscht\003."
- }
- }
- }
- }
- "points" {
- if {[channel get $chan $S_M::S_I::si_name]} {
- putnow "PRIVMSG $chan :\003\[\00309$S_M::S_I::si_name\003\] \00309$nick \00314Du hast \00309[S_M::S_R::sr_read User $chan $nick]\003\$"
- }
- }
- "jackpot" {
- if {[channel get $chan $S_M::S_I::si_name]} {
- putnow "PRIVMSG $chan :\003\[\00309$S_M::S_I::si_name\003\] \00309$nick \00314Im Jackpot sind \00309[S_M::S_R::sr_read Global $chan ${S_M::S_I::si_name}_Jackpot]\003\$"
- }
- }
- default {
- if {[matchattr $hand $S_M::G_S::gs_flags]} {
- if {![channel get $chan $S_M::S_I::si_name]} {
- putnow "PRIVMSG $chan :\003\[\00304$S_M::S_I::si_name\003\] \00314ist \00304Deaktiviert\003! \00314Benutze Bitte \003$S_M::G_S::gs_char\00309$S_M::G_S::gs_bind \003(\00307On\003)"
- }
- }
- if {[channel get $chan $S_M::S_I::si_name]} {
- if {$arg == ""} {
- S_M::S_W::sw_write User $chan $nick [expr int([S_M::S_R::sr_read User $chan $nick] - 10)]
- S_M::S_W::sw_write Global $chan ${S_M::S_I::si_name}_Jackpot [expr int([S_M::S_R::sr_read Global $chan ${S_M::S_I::si_name}_Jackpot] + 10)]
- putnow "PRIVMSG $chan :\003\[\00309$S_M::S_I::si_name\003\] \00309$nick [lindex $S_M::G_S::gs_game_start_text [rand [llength $S_M::G_S::gs_game_start_text]]]"
- set slot1 [lindex $S_M::G_S::gs_symbols [rand [llength $S_M::G_S::gs_symbols]]]
- putnow "PRIVMSG $chan :\003( \00309$slot1 \003) \003( \00304X \003) \003( \00304X \003)"
- set slot2 [lindex $S_M::G_S::gs_symbols [rand [llength $S_M::G_S::gs_symbols]]]
- putnow "PRIVMSG $chan :\003( \00309$slot1 \003) \003( \00309$slot2 \003) \003( \00304X \003)"
- set slot3 [lindex $S_M::G_S::gs_symbols [rand [llength $S_M::G_S::gs_symbols]]]
- putnow "PRIVMSG $chan :\003( \00309$slot1 \003) \003( \00309$slot2 \003) \003( \00309$slot3 \003)"
- if {$slot1 == "X"} {
- if {$slot2 == "X"} {
- if {$slot3 == "X"} {
- S_M::S_W::sw_write User $chan $nick [expr int([S_M::S_R::sr_read User $chan $nick] + [S_M::S_R::sr_read Global $chan ${S_M::S_I::si_name}_Jackpot])]
- putnow "PRIVMSG $chan :\003\[\00309$S_M::S_I::si_name\003\] \002\00309Jackpot\002 \00314Du hast \00309[S_M::S_R::sr_read Global $chan ${S_M::S_I::si_name}_Jackpot]\003\$ \00314Gewonnen\003!"
- S_M::S_W::sw_write Global $chan ${S_M::S_I::si_name}_Jackpot 0
- return 1
- }
- }
- }
- if {$slot1 == $slot2} {
- if {$slot2 == $slot3} {
- S_M::S_W::sw_write User $chan $nick [expr int([S_M::S_R::sr_read User $chan $nick] + 100)]
- putnow "PRIVMSG $chan :\003\[\00309$S_M::S_I::si_name\003\] \00314Herzlichen Glückwunsch\003. \00314Du hast \00309100\003\$ \00314Gewonnen\003."
- return 1
- }
- }
- if {$slot1 == $slot2} {
- S_M::S_W::sw_write User $chan $nick [expr int([S_M::S_R::sr_read User $chan $nick] + 25)]
- putnow "PRIVMSG $chan :\003\[\00309$S_M::S_I::si_name\003\] \00314Herzlichen Glückwunsch\003. \00314Du hast \0030925\003\$ \00314Gewonnen\003."
- return 1
- }
- if {$slot2 == $slot3} {
- S_M::S_W::sw_write User $chan $nick [expr int([S_M::S_R::sr_read User $chan $nick] + 25)]
- putnow "PRIVMSG $chan :\003\[\00309$S_M::S_I::si_name\003\] \00314Herzlichen Glückwunsch\003. \00314Du hast \0030925\003\$ \00314Gewonnen\003."
- return 1
- }
- if {$slot1 == "X"} {
- if {$slot3 == "X"} {
- S_M::S_W::sw_write User $chan $nick [expr int([S_M::S_R::sr_read User $chan $nick] + 10)]
- putnow "PRIVMSG $chan :\003\[\00309$S_M::S_I::si_name\003\] \00314Herzlichen Glückwunsch\003. \00314Du hast \0030910\003\$ \00314Gewonnen\003."
- return 1
- }
- }
- putnow "PRIVMSG $chan :\003\[\00309$S_M::S_I::si_name\003\] [lindex $S_M::G_S::gs_game_lose_text [rand [llength $S_M::G_S::gs_game_lose_text]]] \00314Dir wurden \0030910\003\$ \00314Abgezogen\003!"
- return 1
- }
- }
- }
- }
- }
- }
- namespace eval S_W {
- #############################################################################
- # Start_Write #
- #############################################################################
- proc sw_write {Type Chan Nick Points} {
- S_M::M_A::ma_change $S_M::M_S::ms_database
- S_M::M_A::ma_query "Delete FROM $S_M::M_S::ms_table WHERE Nick = '[mysqlescape $Nick]'"
- S_M::M_A::ma_query "INSERT $S_M::M_S::ms_table SET Type = '[mysqlescape $Type]' , Chan = '[mysqlescape $Chan]' , Nick = '[mysqlescape $Nick]' , Points = '[mysqlescape $Points]'"
- return 1
- }
- }
- namespace eval S_R {
- #############################################################################
- # Start_Read #
- #############################################################################
- proc sr_read {Type Chan Nick} {
- S_M::M_A::ma_change $S_M::M_S::ms_database
- return [S_M::M_A::ma_query "SELECT Points FROM $S_M::M_S::ms_table WHERE Type = '[mysqlescape $Type]' and Chan = '[mysqlescape $Chan]' and Nick = '[mysqlescape $Nick]'"]
- }
- }
- namespace eval S_I {
- #############################################################################
- # Script_Info #
- #############################################################################
- variable si_name "Slot_Machine"
- variable si_projektname "SM"
- variable si_author "Diamond85"
- variable si_contact "Diamond85@gmx.de"
- variable si_web "Coming Soon"
- variable si_copyright "(c)"
- variable si_copyrightyear "2012"
- variable si_version "0.3"
- variable si_date "21.12.2012"
- }
- namespace eval S_S {
- #############################################################################
- # Setudef_Settings #
- #############################################################################
- setudef flag $S_M::S_I::si_name
- }
- putlog "\003\[\00309$S_M::S_I::si_name\003\] \00314Projekt Name\003: \00309$S_M::S_I::si_projektname \003\| \00314Version\003.\00309$S_M::S_I::si_version \003(\00314Status\003: \00309Loaded\003)."
- }
- # EOF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement