Author Topic: Drunkbot help  (Read 2005 times)

0 Members and 1 Guest are viewing this topic.

Offline ZandPilooT

  • Junior Member
  • **
  • Posts: 16
  • Karma: +1/-0
    • P2P4all
Drunkbot help
« on: 28 October, 2007, 21:37:46 »
Hi, I use drunkbot 3 script and I was wondering if it's possible to have "the drunk" not listed with a key. So it looks like a normal user.

Code of the script:
Code: [Select]
-- Drunk Bot
-- A Drunk and Dissorderly Bot
-- Thanks 2 Chaggydawg 4 makeing the orginal version
-- Version 3.0 by Madman
-- Rewritten code
-- Moved files to a seperate folder
-- Changed Setup to table layout
-- Merged userdrink.lua
-- Removed Sleep command, He's a drunk.. he don't need to be put to sleep ;)
-- Fixed bug with showing nr when sleeping
-- Version 3.1
-- Lua 5.1 Compatble

-- Setup
tConfig = {
["DrunkName"] = "Dude", -- Drunk Bots name
["BuddyName"] = frmHub:GetHubBotName(), -- Drunk Bots buddy
["OffOn"] = 1, -- Is Drunk Bot on or off @ script start (0=off, 1=on)
["AbuseInterval"] = 15, -- Time interval between abuse, Deafult 15 Min (15)
["Tolerance"] = 100, -- Time to work of one drink (###*AbuseInterval)
["SleepMumble"] = 10, -- How often Drunk bot mumelse while sleeping, Time in min
["SendMenu"] = 1, -- Send rightclick? (1=yes, 0=off)
["MenuName"] = "Dude", -- Menu namme for the rightclick
--[[-- Do not change variables below here! Do so on own risk! --]]--
["DrunkLevel"] = 1, -- How Many Drinks Does Drunk Have In Him to Start (Default 1)
["BuddyLevel"] = 1, -- How Many Drinks Does Buddy Have In Him to Start (Default 1)
["SleepingTime"] = 8, ---How Long To Sleep to be sober [#*sleepMumble] (Default 2 hours)
["isSleeping"] = 0, -- 0=Awake  1=Asleep (Default is Awake)
["TolerenceLevel"] = 0,
["SleepTemp"] = 0,
--[[-- Do not change variabled abowe here! Do so on own risk --]]--
}

-- The people to abuse as standard
TheAbused = {
"Bartender",
frmHub:GetHubBotName(),
}

dofile("DrunkBot/drunktriggs.txt")

function Main()
SetTimer(1000*60*tConfig.AbuseInterval)
StartTimer()
frmHub:RegBot(tConfig.DrunkName)
end

function ChatArrival(curUser, data)
local data = string.sub(data, 1, -2)
local s,e,cmd = string.find(data, "%b<>%s+[%!%+%?%#](%S+)")
if cmd then
local tCmds = {
["drunk.drink"] = function(curUser, data)
DrunkDrink(curUser) return 1
end,
["buddy.drink"] = function(curUser, data)
BuddyDrink(curUser) return 1
end,
["drunk.howmany"] = function(curUser, data)
DrunkHowMany() return 1
end,
["buddy.howmany"] = function(curUser, data)
BuddyHowMany() return 1
end,
["drunk.on"] = function(curUser, data)
if curUser.bOperator then
tConfig.OffOn = 1
end
end,
["drunk.off"] = function(curUser, data)
if curUser.bOperator then
tConfig.OffOn = 0
end
end,
["user.drink"] = function(curUser, data)
local s,e,vic = string.find(data, "%b<>%s+%S+%s+(%S+)")
if vic == nil then
curUser:SendData(tConfig.DrunkName, "Syntax: !user.drink <nick>") return 1
end
vUser = GetItemByName(vic)
if not vUser then
curUser:SendData(tConfig.DrunkName, " *** " ..vic.. " is not online") return 1
end
SendToAll("Bartender", curUser.sName.. " buys " ..vUser.sName.. " a drink")
SendToAll(vUser.sName, "Thanks " ..curUser.sName.. " !! I love drinks") return 1
end,
["drunk.help"] = function(curUser, data)
SendToNick(curUser.sName," Commands For The Drunk Bot:")
SendToNick(curUser.sName,"!drunk.drink Give the " ..tConfig.DrunkName " a drink")
SendToNick(curUser.sName,"!drunk.howmany Ask how many drinks " ..tConfig.DrunkName.. " has had")
SendToNick(curUser.sName,"!drunk.off Turn off " ..tConfig.DrunkName)
SendToNick(curUser.sName,"!drunk.on Turn On " ..tConfig.DrunkName)
SendToNick(curUser.sName,"!drunk.help Display this Help Screen")
SendToNick(curUser.sName,"!buddy.drink Give " ..tConfig.BuddyName.. " a drink")
SendToNick(curUser.sName,"!buddy.howmany Ask how many drinks " ..tConfig.BuddyName.. " has had")
SendToNick(curUser.sName,"!user.drink <nick> Gives nick a drink") return 1
end,
}
if tCmds[cmd] then
return tCmds[cmd](curUser, data)
end
end
end

function OnTimer()
if (tConfig.OffOn ~= 0) and (tConfig.isSleeping ~= 1) then
if tConfig.DrunkLevel > 30 then
Sleep()
elseif tConfig.DrunkLevel > 20 and tConfig.DrunkLevel <= 30 then
AbusePhrase = string.gsub(abuse6[math.random(table.maxn(abuse6))], "%b[]", TheAbused[math.random(table.maxn(TheAbused))] )
SendToAll(tConfig.DrunkName, AbusePhrase)
elseif tConfig.DrunkLevel > 16 and tConfig.DrunkLevel <= 20 then
AbusePhrase = string.gsub(abuse5[math.random(table.maxn(abuse5))], "%b[]", TheAbused[math.random(table.maxn(TheAbused))] )
SendToAll(tConfig.DrunkName, AbusePhrase)
elseif tConfig.DrunkLevel > 12 and tConfig.DrunkLevel <= 16 then
AbusePhrase = string.gsub(abuse4[math.random(table.maxn(abuse4))], "%b[]", TheAbused[math.random(table.maxn(TheAbused))] )
SendToAll(tConfig.DrunkName, AbusePhrase)
elseif tConfig.DrunkLevel > 8 and tConfig.DrunkLevel <= 12 then
AbusePhrase = string.gsub(abuse3[math.random(table.maxn(abuse3))], "%b[]", TheAbused[math.random(table.maxn(TheAbused))] )
SendToAll(tConfig.DrunkName, AbusePhrase)
elseif tConfig.DrunkLevel > 4 and tConfig.DrunkLevel <= 8 then
AbusePhrase = string.gsub(abuse2[math.random(table.maxn(abuse2))], "%b[]", TheAbused[math.random(table.maxn(TheAbused))] )
SendToAll(tConfig.DrunkName, AbusePhrase)
elseif tConfig.DrunkLevel > 0 and tConfig.DrunkLevel <= 4 then
AbusePhrase = string.gsub(abuse1[math.random(table.maxn(abuse1))], "%b[]", TheAbused[math.random(table.maxn(TheAbused))] )
SendToAll(tConfig.DrunkName, AbusePhrase)
end
end
if tConfig.OffOn == 1 then
tConfig.TolerenceLevel = tConfig.TolerenceLevel+1
if tConfig.TolerenceLevel >= tConfig.TolerenceLevel then
tConfig.TolerenceLevel = 0
if tConfig.DrunkLevel > 1 then
tConfig.DrunkLevel = tConfig.DrunkLevel-1
end
end
end
if (tConfig.OffOn == 1) and (tConfig.isSleeping == 1) then
tConfig.SleepTemp = tConfig.SleepTemp+1
if tConfig.SleepTemp > tConfig.SleepingTime then
SendToAll(tConfig.DrunkName, abuse7[math.random(table.maxn(abuse7))])
elseif tConfig.SleepTemp >= tConfig.SleepingTime then
tConfig.isSleeping = 0
SendToAll(tConfig.DrunkName, "*Yawn* I feel so Refreshed!! *Cracks open a Beer*")
SendToAll(tConfig.DrunkName, "*Drinks down the Beer* Alrighty, Who's got another beer for me?")
tConfig.DrunkLevel = 1
SetTimer(1000*60*tConfig.AbuseInterval)
end
end
end

function Sleep()
if tConfig.isSleeping ~= 1 then
SetTimer(1000*60*tConfig.SleepMumble)
SendToAll(tConfig.DrunkName, "*Falls over on floor and passes out*")
AbusePhrase = string.gsub(abuse7[math.random(table.maxn(abuse7))],"%b[]", TheAbused[math.random(table.maxn(TheAbused))])
SendToAll(tConfig.DrunkName, AbusePhrase)
tConfig.isSleeping = 1
end
end

function BuddyHowMany()
SendToAll(tConfig.BuddyName, "I only been drinking " ..math.random(1, tConfig.DrunkLevel).. " drinks")
SendToAll("Bartender", "*Slips you a note that says " ..tConfig.BuddyLevel.. " drinks on it*")
end

function DrunkHowMany()
SendToAll(tConfig.DrunkName, "I've only had " ..math.random(1, tConfig.DrunkLevel).. " drinks")
SendToAll("Bartender", "*Slips you a note that says " ..tConfig.DrunkLevel.. " drinks on it*")
end

function BuddyDrink(curUser)
tConfig.BuddyLevel = tConfig.BuddyLevel+1
SendToAll("Bartender", curUser.sName.. " buys " ..tConfig.BuddyName.. " a drink")
SendToAll(tConfig.BuddyName, "Sweeet, I love drinks!")
end

function DrunkDrink(curUser)
tConfig.DrunkLevel = tConfig.DrunkLevel+1
tConfig.BuddyLevel = tConfig.BuddyLevel+1
local Drink = {
function (curUser)
SendToAll("Bartender", curUser.sName.. " buys " ..tConfig.DrunkName.. " a drink")
SendToAll(tConfig.DrunkName, "Thanx " ..curUser.sName.."!! I love drinks!")
end,
function (curUser)
SendToAll("Bartender", curUser.sName.. " buys " ..tConfig.DrunkName.. " a beer")
SendToAll(tConfig.DrunkName, "I love a really  cold beer")
end,
function (curUser)
SendToAll("Bartender", curUser.sName.. " buys " ..tConfig.DrunkName.. " and " ..tConfig.BuddyName.. " a drink")
SendToAll(tConfig.DrunkName, "WhooHoo! Thank you " ..curUser.sName)
SendToAll(tConfig.BuddyName, "Thanks " ..curUser.sName.. "! I love drinks")
end,
function (curUser)
SendToAll("Bartender", tConfig.DrunkName.. " got an tequila by " ..curUser.sName)
SendToAll(tConfig.DrunkName, "Sweet! So " ..curUser.sName.. " how about an tequila race?")
SendToAll(tConfig.BuddyName, "Right on! Bring it on, and i'll beat you all!")
end,
function (curUser)
SendToAll("Bartender", curUser.sName.. " buys " ..tConfig.BuddyName.. " a beer")
SendToAll(tConfig.BuddyName, "Thanks " ..curUser.sName.. ". Hey " ..tConfig.DrunkName.. " you want some to?")
SendToAll(tConfig.DrunkName, "Hell yeah!")
end,
function (curUser)
SendToAll("Bartender", curUser.sName.. " orders a gin and tonic to" ..tConfig.DrunkName)
SendToAll(tConfig.DrunkName, "Thanks " ..curUser.sName)
end,
function (curUser)
SendToAll("Bartender", curUser.sName.. " gets " ..tConfig.DrunkName.. " a white russian")
SendToAll(tConfig.DrunkName, "Some mike to the drink")
end,
function (curUser)
SendToAll("Bartender", curUser.sName.. " buys " ..tConfig.DrunkName.. " some wine")
SendToAll(tConfig.DrunkName, "Thanx " ..curUser.sName.. "! I like wine, my favo is red")
end,
function (curUser)
SendToAll("Bartender", curUser.sName.. " buys " ..tConfig.DrunkName.. " a butel of Famous Grouse Whiskey")
SendToAll(tConfig.DrunkName, "I love whiskey!")
end,
}
return Drink[math.random(table.maxn(Drink))](curUser)
end


-- The rightclick menu
function Menu(curUser)
curUser:SendData("$UserCommand 1 3 " ..tConfig.MenuName.. "\\Give Drunk a drink$<%[mynick]> !drunk.drink&#124;") --Dude drink
curUser:SendData("$UserCommand 1 3 " ..tConfig.MenuName.. "\\Give Buddy drink$<%[mynick]> !buddy.drink&#124;") --Buddy drink
curUser:SendData("$UserCommand 1 3 " ..tConfig.MenuName.. "\\Howmany Drunk?$<%[mynick]> !drunk.howmany&#124;") --Dude Howmany
curUser:SendData("$UserCommand 1 3 " ..tConfig.MenuName.. "\\Howmany Buddy?$<%[mynick]> !buddy.howmany&#124;") --Buddy Howmany
curUser:SendData("$UserCommand 1 2 " ..tConfig.MenuName.. "\\Drink 2 User$<%[mynick]> !user.drink %[nick]&#124;") --Drink User
end

function NewUserConnected(curUser)
AddUser(TheAbused,curUser)
if tConfig.SendMenu == 1 then
Menu(curUser)
end
end

OpConnected = NewUserConnected

-- This function is fired when an user disconnects
function UserDisconnected(curUser)
RemoveUser(TheAbused,curUser)
end

OpDisconnected = UserDisconnected

--
-- RabidWombat's binarysearch function
-- With not-very-Modified Bonki add/remove user Script
--
function RemoveUser(tTable, uUser)
local iFind = BinarySearch(tTable, uUser.sName);
if(iFind ~= -1) then
table.remove(tTable, iFind);
return 1;
else
return 0;
end;
end

function AddUser(tTable, uUser)
local iFind, iInsert = BinarySearch(tTable, uUser.sName);
if(iFind == -1) then
table.insert(tTable, iInsert, uUser.sName);
return 1;
else
return 0;
end;
end

function BinarySearch(tTable, SearchVar)
assert(tTable and SearchVar);
local iBot, iMid, iTop = 1, nil, table.maxn(tTable);
local CompVal = nil;
if(table.maxn(tTable) == 0) then return -1, 1; end
while(iBot <= iTop) do
iMid = math.floor((iTop + iBot) / 2);
CompVal = tTable[iMid];
if(CompVal == nil) then return -1, -1; end
if(SearchVar < CompVal) then
iTop = iMid - 1;
elseif(SearchVar > CompVal) then
iBot = iMid + 1;
else
return iMid, -1;
end
end
if(SearchVar > CompVal) then
iMid = iMid + 1;
end
return -1, iMid;
end
DC: mordor.zandpiloot.nl:411
OpenNap: mordor.zandpiloot.nl:4444

PtokaX forum

Drunkbot help
« on: 28 October, 2007, 21:37:46 »

Offline Rincewind

  • Scripter
  • Lord
  • ******
  • Posts: 403
  • Karma: +60/-7
    • Rincewind's Scripts
Re: Drunkbot help
« Reply #1 on: 28 October, 2007, 22:00:57 »
Change
Code: [Select]
frmHub:RegBot(tConfig.DrunkName) to
Code: [Select]
frmHub:RegBot(tConfig.DrunkName, 0, "", "")

Offline ZandPilooT

  • Junior Member
  • **
  • Posts: 16
  • Karma: +1/-0
    • P2P4all
Re: Drunkbot help
« Reply #2 on: 28 October, 2007, 22:30:27 »
Thanks for your help.
DC: mordor.zandpiloot.nl:411
OpenNap: mordor.zandpiloot.nl:4444

PtokaX forum

Re: Drunkbot help
« Reply #2 on: 28 October, 2007, 22:30:27 »