Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --UniteamBot made by Tryton
- --27/07/2011
- ----------------------------------------------
- --Functions--
- --Auto op function
- --BadWords List
- --Poll function (for another mod)
- --Login gui
- ----------------------------------------------
- --To Do--
- --Speak if a player got decaped
- ------------------------------------------------
- ------------------------------------------------
- serverip = "66.230.224.162"
- serverport = 20184
- defaultuser = "UniteamBOT"
- defaultpass = "Uniteambottest"
- OpList = {"Tryton", "name1", "name2", "name3", "name4",}--Enter the people who can be opped
- BadWords = {"nigger", "bitch", "asshole", "fag", "fuck",}--Enter all bad words you want
- ------------------------------------------------------
- --Dont chnge this if u dont know what you are doing!--
- ------------------------------------------------------
- dofile("scripts/BaseBot.lua")
- function Say(text)
- text = string.gsub(text, "#time", os.date("%X"))
- Send("SAY " .. text)
- end
- Connect(serverip,serverport)
- Login(user,pass)
- Say(".:UniteamBot Connected:.")
- Spec("")
- PollNames = {}
- PollVotes = {}
- VoteNo = 0
- VoteYes = 0
- Voted = nil
- --Mute and unmute players
- muteTimers = { }
- currTimer = 1
- function muteFor(name,time)
- Send("mute " .. name)
- muteTimers[currTimer] = timer()
- muteTimers[currTimer].Interval = time*1000
- muteTimers[currTimer].Enabled = true
- muteTimers[currTimer].Tick:Add(
- function()
- Send("unmute " .. name)
- end)
- currTimer = currTimer + 1
- end
- --Anti Ping-Out
- timer1 = timer()
- timer1.Interval = 5000
- timer1.Enabled = true
- timer1.Tick:Add(
- function()
- Send("PING")
- end)
- --Get Chat
- function LineChanged(Line)
- if(Line:sub(0,3) == "SAY") then
- A = Line:find(";")
- B = Line:find(" ",A+1)
- print("> " ..Line:sub(A+1))
- if(B ~= nil) then
- Chat = Line:sub(B+1)
- MsgOwnerEnd = Line:find("> ")
- end
- if MsgOwnerEnd ~= nil then
- MsgOwner = Line:sub(A+8, MsgOwnerEnd-4)
- --Op a Player
- if Chat == "!op" then
- for n=0, #OpList do
- if OpList[n] == MsgOwner then
- Op = 1
- end
- end
- if Op == 1 then
- Send("op " ..MsgOwner)
- Say("You are now opped " ..MsgOwner.."!")
- Op = 0
- elseif Op == nil then
- Say("Dont try to get opped if you arent allowed "..MsgOwner.."! <muted for 60 seconds>")
- muteFor(MsgOwner, 30)
- Op = nil
- end
- end
- --Find badwords
- for w=1, #BadWords do
- Word = string.lower(BadWords[w])
- if Chat:find(Word) ~= nil then
- Say("Don't say such bad words! <muted for 60 seconds>")
- muteFor(MsgOwner, 60)
- end
- end
- --Vote system
- --Mod
- IfModPoll = Chat:sub(0, 5)
- if IfModPoll == "!Mod " and Poll == nil and MsgOwner ~= user or IfModPoll == "!mod " and Poll == nil and MsgOwner ~= user then
- PollObject = Chat:sub(6)
- Poll = "set mod"
- PollNames[0] = MsgOwner
- PollVotes[0] = "yes"
- PollStartTime = os.time(sec)
- Say(MsgOwner.." Started a poll to change the mod to "..PollObject.."!")
- Say("Type !yes or !no to vote. The poll will end in 40 seconds")
- elseif IfModPoll == "!Mod " and Poll ~= nil and MsgOwner ~= user or IfModPoll == "!mod " and Poll ~= nil and MsgOwner ~= user then
- Say("There can be only one active poll")
- end
- --Ban
- if IfModPoll == "!Ban " and Poll == nil and MsgOwner ~= user or IfModPoll == "!ban " and Poll == nil and MsgOwner ~= user then
- PollObject = Chat:sub(6)
- Poll = "ban"
- PollNames[0] = MsgOwner
- PollVotes[0] = "yes"
- PollStartTime = os.time(sec)
- Say(MsgOwner.." Started a poll to ban the player "..PollObject.."!")
- Say("Type !yes or !no to vote. The poll will end in 40 seconds")
- elseif IfModPoll == "!Ban " and Poll ~= nil and MsgOwner ~= user or IfModPoll == "!ban " and Poll ~= nil and MsgOwner ~= user then
- Say("There can be only one active poll")
- end
- --Kick
- if IfModPoll == "!Kick" and Poll == nil and MsgOwner ~= user or IfModPoll == "!kick" and Poll == nil and MsgOwner ~= user then
- PollObject = Chat:sub(6)
- Poll = "kick"
- PollNames[0] = MsgOwner
- PollVotes[0] = "yes"
- PollStartTime = os.time(sec)
- Say(MsgOwner.." Started a poll to kick the player "..PollObject.."!")
- Say("Type !yes or !no to vote. The poll will end in 40 seconds")
- elseif IfModPoll == "!Kick" and Poll ~= nil and MsgOwner ~= user or IfModPoll == "!kick" and Poll ~= nil and MsgOwner ~= user then
- Say("There can be only one active poll")
- end
- if Poll ~= nil and Chat == "!yes" and MsgOwner ~= user or Poll ~= nil and Chat == "!Yes" and MsgOwner ~= user then
- for Num=0, #PollNames do
- if PollNames[Num] == MsgOwner then
- VoteNumber = Num
- end
- end
- if VoteNumber == nil then
- Num = #PollNames+1
- PollNames[Num] = MsgOwner
- PollVotes[Num] = "yes"
- VoteNumber = nil
- else
- Say("You can vote only once")
- VoteNumber = nil
- end
- elseif Poll ~= nil and Chat == "!no" and MsgOwner ~= user or Poll ~= nil and Chat == "!No" and MsgOwner ~= user then
- for Num=0, #PollNames do
- if PollNames[Num] == MsgOwner then
- VoteNumber = Num
- end
- end
- if VoteNumber == nil then
- Num = #PollNames+1
- PollNames[Num] = MsgOwner
- PollVotes[Num] = "no"
- VoteNumber = nil
- else
- Say("You can vote only once")
- VoteNumber = nil
- end
- end
- end
- end
- if Line:sub(0,6) == "BOUT 0" then
- Clients = 0
- if Line:sub(0,4) == "BOUT" then
- Bouts = Line:sub(5, 6)-1
- end
- end
- end
- --FAQ commands
- --Get poll end
- Ti.Tick:Add(function()
- if Poll ~= nil then
- if PollStartTime+40 <= os.time(sec) or Clients/2-1 > #PollVotes then
- for v=0, #PollVotes do
- if PollVotes[v] == "yes" then
- VoteYes=VoteYes+1
- elseif PollVotes[v] == "no" then
- VoteNo=VoteNo+1
- end
- end
- if VoteYes <= VoteNo then
- Say("Vote: Failed("..VoteNo..":"..VoteYes..").")
- else
- Say("Vote: Passed("..VoteYes..":"..VoteNo..").")
- Send(Poll.." "..PollObject)
- end
- Poll = nil
- PollNames = {}
- PollVotes = {}
- VoteYes = 0
- VoteNo = 0
- end
- end
- end)
- function setServer()
- serverSettings = io.open("Scripts/serversettings.txt")
- if(serverSettings == nil) then
- print("Failed to load serversettings.txt")
- else
- line = serverSettings:read("*l")
- i=1
- while(line ~= nil) do
- Send("" .. line)
- print("Set \"" .. line .. "\" at line " .. i)
- line = serverSettings:read("*l")
- i = i + 1
- end
- end
- end
- --Open the Gui
- --Main Gui
- form1 = form()
- form1.Height = 125
- form1.Width = 250
- button1 = button()
- button1.Text = "Disconnect"
- button1.Dock = dockStyle.Bottom
- button1.Click:Add(function() Disconnect(); form1:Close() end)
- inputBox1 = textBox()
- inputBox1.Text = "hi"
- inputBox1.Dock = dockStyle.Bottom
- button2 = button()
- button2.Text = "Say"
- button2.Dock = dockStyle.Bottom
- button2.Click:Add(function() Say(inputBox1.Text) end)
- button3 = button()
- button3.Text = "Send"
- button3.Dock = dockStyle.Bottom
- button3.Click:Add(function() Send(inputBox1.Text) end)
- button4 = button()
- form1.Controls:Add(inputBox1)
- form1.Controls:Add(button2)
- form1.Controls:Add(button3)
- form1.Controls:Add(button1)
- --Login Gui
- LoginForm = form()
- LoginForm.Text = "Login"
- LoginForm.Height = 105
- LoginForm.Width = 250
- Username = textBox()
- Username.Text = defaultuser
- Username.Dock = dockStyle.Bottom
- Passwd = textBox()
- Passwd.Text = defaultpass
- Passwd.PasswordChar = "*"
- Passwd.Dock = dockStyle.Bottom
- LoginButton = button()
- LoginButton.Text = "Login"
- LoginButton.Dock = dockStyle.Bottom
- LoginButton.Click:Add(function() user=Username.Text; pass=Passwd.Text Connect(serverip,serverport); Login(user,pass); Spec(); LoginForm:Close(); form1.Text = user.."Server"; form1:Show(); setServer() end)
- LoginForm.Controls:Add(Username)
- LoginForm.Controls:Add(Passwd)
- LoginForm.Controls:Add(LoginButton)
- LoginForm:Show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement