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 

bar script help (again)

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
ComputerTech
Master


Joined: 22 Feb 2020
Posts: 393

PostPosted: Sun Jul 26, 2020 11:40 pm    Post subject: bar script help (again) Reply with quote

so trying to add the option to give a beer to a user like !beer john

bot gives john a beer

this is the code I have so far Rolling Eyes

Code:

#################################################################################################################################################################
# Bar.tcl 1.0.5
#################################################################################################################################################################
#ComputerTech
#Irc     irc.technet.xi.ht #ComputerTech123
#Email   ComputerTech312@Gmail.com
#GitHub  https://github.com/computertech312
#Website http://tcl3.webnode.co.uk
#################################################################################################################################################################
#START OF SETTINGS#
#Set trigger

set barcmd ""

#Set the maxium amount the tab can be

set max "100"


#END OF SETTINGS#
#################################################################################################################################################################
   
namespace eval ::beer {

   variable barcmd ";"
    variable beer
   array set bills {}

   array set drinks {
      heineken 6
      wine   25
      water   2
      coke   5
      orange   4
      vodka    10
      brandy   30
      whiskey   9
      budwiser 7
      guinness 14
      carlsberg 8
      redbull   6
      fanta     5
      tea       4
      coffee    6
   }
   
   foreach dr [array names drinks] {
      bind pubm - "*$::beer::barcmd$dr*" ::beer::do_drink
   }
   
   bind pub - "${barcmd}pay" ::beer::do_the_pay
    bind pub - "${barcmd}menu" ::beer::do_the_menu

    proc do_drink {nick uhost handle chan text} {
      set args [split $text " "]
      set key [stripcodes abcgru [lindex $args 0]]
      set key [string range $key 1 end]

      set cost $::beer::drinks($key)
      if {[array names ::beer::bills -exact $nick] ne ""} {
         set bill $::beer::bills($nick)
         if {$bill >= 50} {
            putserv "PRIVMSG $chan : $nick Your Tab is full With the amount of \$$bill Please pay before ordering more drink"   
            return  0           
         }
      } else {
         set ::beer::bills($nick) 0
      }
      incr ::beer::bills($nick) $cost
         if {[lindex [split $text] 0 ]} {
       set dnick "[lindex [split $text] 0 ]"
       putserv "privmsg $chan : here ya go go $dnick some $key"
    }  else {
        putserv "PRIVMSG $chan :\001ACTION Fills up the glass with $key\001"
        putserv "PRIVMSG $chan :\001ACTION Gives the $key to $nick\001"
        putserv "PRIVMSG $chan : Enjoy your $key $nick, Your Total Bill Amount Is \$$::beer::bills($nick)"
   
}     
}

    proc do_the_pay {nick uhost handle chan text} {
       set loaded [array names ::beer::bills -exact $nick]
       if {$loaded eq ""} {
          putserv "PRIVMSG $chan :$nick Your Already Payed Your Bill"
          return
       }
        putserv "PRIVMSG $chan :$nick Thank You For Paying Your Bill, Here's your receipt"
        putserv "NOTICE $nick : -------------------  "
        putserv "NOTICE $nick :|Bar receipt                    "   
        putserv "NOTICE $nick :| \$$::beer::bills($nick)  "
        putserv "NOTICE $nick :| $nick       "
        putserv "NOTICE $nick :| $chan"
        putserv "NOTICE $nick : ------------------- "
        unset ::beer::bills($nick)
    }
     

   proc do_the_menu {nick uhost handle chan text} {
      putserv "NOTICE $nick :Welcome $nick This is our Menu"
      foreach {drink cost} [array get ::beer::drinks] {
      putserv "NOTICE $nick :$::beer::barcmd$drink : \$$cost"
      }
   }
   

   putlog "Barman 1.0.1 loaded"
}   

putlog "Bar 1.0.5 Loaded"
#################################################################################################################################################################

_________________
ComputerTech
Back to top
View user's profile Send private message Send e-mail Visit poster's website
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1032
Location: France

PostPosted: Mon Jul 27, 2020 4:27 am    Post subject: Reply with quote

You can try the following:
Code:
#################################################################################################################################################################
# Bar.tcl 1.0.5
#################################################################################################################################################################
#ComputerTech
#Irc     irc.technet.xi.ht #ComputerTech123
#Email   ComputerTech312@Gmail.com
#GitHub  https://github.com/computertech312
#Website http://tcl3.webnode.co.uk
#################################################################################################################################################################
#START OF SETTINGS#
#Set trigger

set barcmd ""

#Set the maxium amount the tab can be

set max "100"


#END OF SETTINGS#
#################################################################################################################################################################
   
namespace eval ::beer {

   variable barcmd ";"
    variable beer
   array set bills {}

   array set drinks {
      heineken 6
      wine   25
      water   2
      coke   5
      orange   4
      vodka    10
      brandy   30
      whiskey   9
      budwiser 7
      guinness 14
      carlsberg 8
      redbull   6
      fanta     5
      tea       4
      coffee    6
   }
   
   foreach dr [array names drinks] {
      bind pubm - "*$::beer::barcmd$dr*" ::beer::do_drink
   }
   
   bind pub - "${barcmd}pay" ::beer::do_the_pay
   bind pub - "${barcmd}menu" ::beer::do_the_menu

    proc do_drink {nick uhost handle chan text} {
      set args [split $text " "]
      set key [stripcodes abcgru [lindex $args 0]]
      set key [string range $key 1 end]
      if { [llength $args]==2 } {
         set vict [stripcodes abcgru [lindex $args 1]]
         if {![onchan $vict $chan]} {
            putserv "PRIVMSG $chan :$nick, you can't afford a $key to $vict, she/he is not here"
            return 0
         }
      } else {
         set vict $nick
      }
      set cost $::beer::drinks($key)
      if {[array names ::beer::bills -exact $nick] ne ""} {
         set bill $::beer::bills($nick)
         if {$bill >= 50} {
            putserv "PRIVMSG $chan : $nick Your Tab is full With the amount of \$$bill Please pay before ordering more drink"   
            return  0           
         }
      } else {
         set ::beer::bills($nick) 0
      }
      incr ::beer::bills($nick) $cost
      putserv "PRIVMSG $chan :\001ACTION Fills up the glass with $key\001"
      putserv "PRIVMSG $chan :\001ACTION Gives the $key to $vict\001"
      putserv "PRIVMSG $chan : Enjoy your $key $nick, Your Total Bill Amount Is \$$::beer::bills($nick)"
   }

    proc do_the_pay {nick uhost handle chan text} {
      set loaded [array names ::beer::bills -exact $nick]
      if {$loaded eq ""} {
         putserv "PRIVMSG $chan :$nick Your Already Payed Your Bill"
         return
      }
      putserv "PRIVMSG $chan :$nick Thank You For Paying Your Bill, Here's your receipt"
      putserv "NOTICE $nick : -------------------  "
      putserv "NOTICE $nick :|Bar receipt                    "   
      putserv "NOTICE $nick :| \$$::beer::bills($nick)  "
      putserv "NOTICE $nick :| $nick       "
      putserv "NOTICE $nick :| $chan"
      putserv "NOTICE $nick : ------------------- "
      unset ::beer::bills($nick)
    }
     

   proc do_the_menu {nick uhost handle chan text} {
      putserv "NOTICE $nick :Welcome $nick This is our Menu"
      foreach {drink cost} [array get ::beer::drinks] {
         putserv "NOTICE $nick :$::beer::barcmd$drink : \$$cost"
      }
   }
   
   putlog "Barman 1.0.6 loaded"
}

_________________
https://www.eggdrop.fr - French IRC network
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
ComputerTech
Master


Joined: 22 Feb 2020
Posts: 393

PostPosted: Mon Jul 27, 2020 9:13 am    Post subject: Reply with quote

Haha, Cheers CrazyCat Wink

I'll give it a go Razz

*ComputerTech Gives CrazyCat A Beer
_________________
ComputerTech


Last edited by ComputerTech on Mon Jul 27, 2020 9:16 am; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1032
Location: France

PostPosted: Mon Jul 27, 2020 9:14 am    Post subject: Reply with quote

Code:
cd /pub/ && more beer

_________________
https://www.eggdrop.fr - French IRC network
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
ComputerTech
Master


Joined: 22 Feb 2020
Posts: 393

PostPosted: Mon Jul 27, 2020 4:06 pm    Post subject: Reply with quote

Hmm, it works good, but this part

Code:

 putserv "PRIVMSG $chan :\001ACTION Fills up the glass with $key\001"
      putserv "PRIVMSG $chan :\001ACTION Gives the $key to $vict\001"
      putserv "PRIVMSG $chan : Enjoy your $key $nick, Your Total Bill Amount Is \$$::beer::bills($nick)"


if i change $nick to $vict ,will that make it if i just type !beer it will say giving to me?

and for this part.
Code:

  putserv "PRIVMSG $chan :$nick Thank You For Paying Your Bill, Here's your receipt"
      putserv "NOTICE $nick : -------------------  "
      putserv "NOTICE $nick :|Bar receipt                    "   
      putserv "NOTICE $nick :| \$$::beer::bills($nick)  "
      putserv "NOTICE $nick :| $nick       "
      putserv "NOTICE $nick :| $chan"
      putserv "NOTICE $nick : ------------------- "
      unset ::beer::bills($nick)
    }


is there a way to make the receipt show each drink the user ordered on the receipt?
_________________
ComputerTech
Back to top
View user's profile Send private message Send e-mail Visit poster's website
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1032
Location: France

PostPosted: Mon Jul 27, 2020 6:47 pm    Post subject: Reply with quote

ComputerTech wrote:
Hmm, it works good, but this part
Code:

 putserv "PRIVMSG $chan :\001ACTION Fills up the glass with $key\001"
      putserv "PRIVMSG $chan :\001ACTION Gives the $key to $vict\001"
      putserv "PRIVMSG $chan : Enjoy your $key $nick, Your Total Bill Amount Is \$$::beer::bills($nick)"

if i change $nick to $vict ,will that make it if i just type !beer it will say giving to me?

Read the beginning of the code, $vict is depending on the second part of the command:
Code:
if { [llength $args]==2 } {
         set vict [stripcodes abcgru [lindex $args 1]]
         if {![onchan $vict $chan]} {
            putserv "PRIVMSG $chan :$nick, you can't afford a $key to $vict, she/he is not here"
            return 0
         }
      } else {
         set vict $nick
      }


ComputerTech wrote:
and for this part.
Code:

  putserv "PRIVMSG $chan :$nick Thank You For Paying Your Bill, Here's your receipt"
      putserv "NOTICE $nick : -------------------  "
      putserv "NOTICE $nick :|Bar receipt                    "   
      putserv "NOTICE $nick :| \$$::beer::bills($nick)  "
      putserv "NOTICE $nick :| $nick       "
      putserv "NOTICE $nick :| $chan"
      putserv "NOTICE $nick : ------------------- "
      unset ::beer::bills($nick)
    }


is there a way to make the receipt show each drink the user ordered on the receipt?

Wasn't in the previous question, and it's more elaborate than a simple bill counter.
I can do it, but managing bills and payments needs more things than "I want a bar script for fun"
_________________
https://www.eggdrop.fr - French IRC network
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
ComputerTech
Master


Joined: 22 Feb 2020
Posts: 393

PostPosted: Mon Jul 27, 2020 7:08 pm    Post subject: Reply with quote

Yeah, but when i did
Code:

!heineken john

it responded with
Code:

*Fills up the glass with heineken
*Gives the heineken to j9hn
*Enjoy your heineken ComputerTech, Your Total Bill Amount Is $6
 


so i guess this >> *Enjoy your heineken ComputerTech, Your Total Bill Amount Is $6
is the problem, perhaps if it checked if i specified a person to say a different sentence

Cool perhaps like this

Code:

if {[llength [split $text] 0]}
putserv "privmsg $chan :here ya go john"
} else {
putserv "privmsg $chan :here ya go computertech"


something like that perhaps?
_________________
ComputerTech
Back to top
View user's profile Send private message Send e-mail Visit poster's website
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1032
Location: France

PostPosted: Tue Jul 28, 2020 12:49 am    Post subject: Reply with quote

Sorry, I didn't read totaly the last putserv which is used to speak to the "victim" and the afforder.

So, you have 2 choices:
- use separate lines to say "enjoy" and to give the total amount of the bill
- compare $vict and $nick and then choose an appropriate sentence.

First way:
Code:
putserv "PRIVMSG $chan :: Enjoy your $key $vict, it's a gift from $nick"
putserv "PRIVMSG $chan: $nick, your Total Bill Amount is \$$::beer::bills($nick)"


Second way:
Code:
if {$vict eq $nick} {
   putserv "PRIVMSG $chan :Enjoy your $key $nick, Your Total Bill Amount Is \$$::beer::bills($nick)"
} else {
   putserv "PRIVMSG $chan :Enjoy your $key $vict, the Total Bill Amount for $nick is \$$::beer::bills($nick)"
}

_________________
https://www.eggdrop.fr - French IRC network
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
ComputerTech
Master


Joined: 22 Feb 2020
Posts: 393

PostPosted: Tue Jul 28, 2020 6:36 am    Post subject: Reply with quote

Second Choice looks good Very Happy

Thanks CrazyCat, i'll go add it right away Wink

Cheers Razz
_________________
ComputerTech
Back to top
View user's profile Send private message Send e-mail Visit poster's website
ComputerTech
Master


Joined: 22 Feb 2020
Posts: 393

PostPosted: Wed Jul 29, 2020 11:27 pm    Post subject: Reply with quote

Cool, worked a treat CrazyCat Very Happy

i was thinking of anothr feature, a tip service, could we work with this perhaps?


!tip $amount

and this adds to the receipt as a seperate line or array

but some how make a total amount of both the drinks and the tip

would this be possibly easy? or quite difficult to do?
All help appreciated as always Very Happy
_________________
ComputerTech
Back to top
View user's profile Send private message Send e-mail Visit poster's website
ComputerTech
Master


Joined: 22 Feb 2020
Posts: 393

PostPosted: Wed Aug 26, 2020 4:03 pm    Post subject: Reply with quote

Hmm, little problem with the bar script, if a user changes nick it clears their bar tab, is there a way to associate the variable with the user's hostmask?

Thanks in advanced Razz
_________________
ComputerTech
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help 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