PtokaX forum

Archive => Archived 4.0 boards => Help with Lua 4 scripts => Topic started by: Typhoon on 04 January, 2004, 21:15:30

Title: Fun-Script-V.1.lua
Post by: Typhoon on 04 January, 2004, 21:15:30
this is quite funny but it also affects Ops.
i would like some help or some info of how to fix it so it
only affect users...



-- Open for all users.
-- by solian, 13.9.03 almost rewriten by c h i l l e r, why? to much time :).
-- I made it open for all users. Can be changed easily.

--Name of the script
scriptname = "Fun-Script-V.1.lua"

-- Name of the Script Bot
bot = "[bot]"

-- Name of the bot that handles the beer truck.
beerbot = "Brewer-Bot"

-- The Joke-Bot
tcbot = "Joker"

-- You need this Folder in your scripts Folder
Folder = "funscript"

-- This is the time in minutes a user is gagged, kennied etc.
Max1 = 1

-- To add Trigs simply add them to the files bellow in the txt folder.

assert(dofile(Folder.."/DrunkTriggs.txt"),Folder.."/DrunkTriggs.txt for "..scriptname.." not found")
assert(dofile(Folder.."/KennyTriggs.txt"),Folder.."/KennyTriggs.txt for "..scriptname.." not found")
assert(dofile(Folder.."/TcJokes.txt"),Folder.."/TcJokes.txt for "..scriptname.." not found")
assert(dofile(Folder.."/SlapTriggs.txt"),Folder.."/SlapTriggs.txt for "..scriptname.." not found")

-- This Command turns the script on and off, +funmode [on/off], only for Op's.
cmd1 = "+funmode"

cmd2 = "+funhelp"

cmd3 = "+tc"

cmd4 = "+kenny"

cmd5 = "+gag"

cmd6 = "+drunk"

cmd7 = "+slap"

cmd8 = "+beer"

FunnyMode = "on"

KennyUsers = {}
GaggedUsers = {}
DrunkUsers = {}
TaggedUsers = {}

sec = 1000
min = 60 * sec

function Main()
SetTimer( 1 * min)
StartTimer()
end

function OnTimer()
for i,v in TaggedUsers do
if v == Max1 then
if KennyUsers[i] then
KennyUsers[i] = nil
elseif GaggedUsers[i] then
GaggedUsers[i] = nil
elseif DrunkUsers[i] then
DrunkUsers[i] = nil
end
TaggedUsers[i] = nil
else
v = v + 1
end
end
end

function DataArrival(user,data)
if (strsub(data, 1, 1) == "<") then
data = strsub(data,1,strlen(data)-1)
_,_,cmd = strfind( data, "%b<>%s+(%S+)" )

if strlower(cmd) == strlower(cmd1) and user.bOperator then
onoff = Get1Arg(data)
if onoff then
if onoff == "on" then
FunnyMode = "on"
SendToAll(bot, "Yiepieeeee let the party begin. type "..cmd2.." for help.")
elseif onoff == "off" then
FunnyMode = "off"
KennyUsers = {}
GaggedUsers = {}
DrunkUsers = {}
TaggedUsers = {}
SendToAll(bot, "Parties over ! :(.")
else
user:SendData(bot, "To start/stop FunnyMode type "..cmd1.." [on/off].")
end
else
user:SendData(bot, "To start/stop FunnyMode type "..cmd1.." [on/off].")
end
return 1
end

if FunnyMode == "on" then

if strlower(cmd) == strlower(cmd2) then
user:SendData(bot," Fun Script Help!\r\n\r\n"..
"\t"..cmd3.."\tSends Jokes!\r\n"..
"\t"..cmd4.."\tSets the User in Kenny Mode. "..cmd4.." [on/off] [nick]\r\n"..
"\t"..cmd5.."\tGags the User. "..cmd5.." [on/off] [nick]\r\n"..
"\t"..cmd6.."\tSets the User in Drunk Mode. "..cmd6.." [on/off] [nick]\r\n"..
"\t"..cmd7.."\tSlaps the user. "..cmd7.." [nick]\r\n"..
"\t"..cmd8.."\tThe BeerTruck. "..cmd8.." [BEER]\r\n"..
"\t"..cmd2.."\tShows this text.\r\n")
return 1

elseif strlower(cmd) == strlower(cmd3) and TaggedUsers[user.sName]==nil then
if getn(TcJokes) == 1 then
SendToAll(tcbot,"\r\n"..
TcJokes[1])
dofile(Folder.."/TcJokes.txt")
else
num = random(1,getn(TcJokes))
SendToAll(tcbot,"\r\n"..
TcJokes[num])
tremove ( TcJokes, num)
end
return 1

elseif strlower(cmd) == strlower(cmd4) and TaggedUsers[user.sName]==nil then
onoff,nick = Get2Arg(data)
if onoff then
if onoff == "on" and GetItemByName(nick) and TaggedUsers[nick]==nil then
who = GetItemByName(nick)
KennyUsers[nick]=1
if not who.bOperator then
TaggedUsers[nick]=0
end
user:SendData(bot,"User "..nick.." is now in Kenny-Mode")
elseif onoff == "off" and KennyUsers[nick] then
KennyUsers[nick]=nil
TaggedUsers[nick]=nil
user:SendData(bot,"User "..nick.." is now removed from Kenny-Mode")
elseif onoff == "off" and strlower(nick) == "all" and user.bOperator then
for i,v in KennyUsers do
TaggedUsers[i]=nil
end
KennyUsers = {}
user:SendData(bot,"All Users have been removed from Kenny-Mode")
else
user:SendData(bot, "To set/remove a user in/from Kenny-Mode type "..cmd4.." [on/off] [nick].\r\n"..
"\tOr the user is already tagged, or wasn't in Kenny-Mode.")
end
else
user:SendData(bot, "To set/remove a user in/from Kenny-Mode type "..cmd4.." [on/off] [nick].")
end
return 1

elseif strlower(cmd) == strlower(cmd5) and TaggedUsers[user.sName]==nil then
onoff,nick = Get2Arg(data)
if onoff then
if onoff == "on" and GetItemByName(nick) and TaggedUsers[nick]==nil then
who = GetItemByName(nick)
GaggedUsers[nick]=1
if not who.bOperator then
TaggedUsers[nick]=0
end
user:SendData(bot,"User "..nick.." is now in Gagged.")
elseif onoff == "off" and GaggedUsers[nick] then
GaggedUsers[nick]=nil
TaggedUsers[nick]=nil
user:SendData(bot,"User "..nick.." has now been UnGagged.")
elseif noff == "off" and strlower(nick) == "all" and user.bOperator then
for i,v in GaggedUsers do
TaggedUsers[i]=nil
end
GaggedUsers = {}
user:SendData(bot,"All Users have been UnGagged")
else
user:SendData(bot, "To set/remove a user in/from beeing Gagged type "..cmd5.." [on/off] [nick].\r\n"..
"\tOr the user is already tagged, or wasn't gagged.")
end
else
user:SendData(bot, "To set/remove a user in/from beeing Gagged type "..cmd5.." [on/off] [nick].")
end
return 1

elseif strlower(cmd) == strlower(cmd6) and TaggedUsers[user.sName]==nil then
onoff,nick = Get2Arg(data)
if onoff then
if onoff == "on" and GetItemByName(nick) and TaggedUsers[nick]==nil then
who = GetItemByName(nick)
DrunkUsers[nick]=1
if not who.bOperator then
TaggedUsers[nick]=0
end
user:SendData(bot,"User "..nick.." is now in Drunk-Mode.")
elseif onoff == "off" and DrunkUsers[nick] then
DrunkUsers[nick]=nil
TaggedUsers[nick]=nil
user:SendData(bot,"User "..nick.." is now sober again.")
elseif noff == "off" and strlower(nick) == "all" and user.bOperator then
for i,v in DrunkUsers do
TaggedUsers[i]=nil
end
DrunkUsers = {}
user:SendData(bot,"All Users are sober again.")
else
user:SendData(bot, "To set/remove a user in/from beeing Drunk type "..cmd6.." [on/off] [nick].\r\n"..
"\tOr the user is already tagged, or wasn't in Drunk-Mode.")
end
else
user:SendData(bot, "To set/remove a user in/from beeing Drunk type "..cmd6.." [on/off] [nick].")
end
return 1

elseif strlower(cmd) == strlower(cmd7) and TaggedUsers[user.sName]==nil then
who = Get1Arg(data)
if GetItemByName(who) then
if getn(SlapTriggs) == 1 then
msg = gsub(SlapTriggs[1], "%b[]", who)
SendToAll(user.sName, msg)
dofile(Folder.."/SlapTriggs.txt")
else
num = random(1,getn(SlapTriggs))
msg = gsub(SlapTriggs[num], "%b[]", who)
SendToAll(user.sName, msg)
tremove ( SlapTriggs, num)
end
else
user:SendData(bot, "To slap a user type "..cmd7.." [nick]")
end
return 1

elseif strlower(cmd) == strlower(cmd8) and TaggedUsers[user.sName]==nil then
_,_,_,msg = strfind( data, "%b<>%s+(%S+)%s+(.*)")
if msg and strlen(msg) < 60 then
local line = strrep("_", strlen(msg))
local line2 = strrep("  ", strlen(msg))
SendToAll(beerbot, "\r\n"..
"\r\n"..
"                                  ________________"..line.."\r\n"..
"                    _____ff\r\n"..
"        ,_____] ?__l   '                "..msg.."\r\n"..
"        l __,__   ---      '________________"..line.."\r\n"..
"       =/(  o )\=====----( o )-( o )\         "..line2.."( o )-( o )\  \r\n"..
"\r\n")
else
user:SendData(beerbot, "No Beer for you!")
end
return 1

elseif GaggedUsers[user.sName] then
user:SendData(bot, "You are Gagged, funny ha! ;)")
return 1

elseif KennyUsers[user.sName] then
_,_,msg= strfind(data,"%b<>%s(.+)")
t = {}
local msg2 = ""
gsub(msg, "(%S+)", function (w) tinsert (%t, "X") end)
for i = 1,getn(t) do
msg2 = msg2.." "..KennyTriggs[random(1,getn(KennyTriggs))]
end
SendToAll(user.sName,msg2)
t = {}
return 1

elseif DrunkUsers[user.sName] then
if getn(DrunkTriggs) == 1 then
SendToAll(user.sName, DrunkTriggs[1])
dofile(Folder.."/DrunkTriggs.txt")
else
num = random(1,getn(DrunkTriggs))
SendToAll(user.sName,DrunkTriggs[num])
tremove ( DrunkTriggs, num)
end
return 1

end
end
end
end


function Get2Arg(data)
_,_,_,onoff,nick= strfind(data,"%b<>%s(%S+)%s(%S+)%s(%S+)")
if onoff then
return strlower(onoff),nick
end
end

function Get1Arg(data)
_,_,_,onoff= strfind(data,"%b<>%s(%S+)%s(%S+)")
if onoff then
return strlower(onoff)
end
end




***Typhoon?