Development Section > HOW-TO's

HOW-TO: Write your own bot = Lesson 8

(1/5) > >>

pHaTTy:
Ok we will be dealing with tables a bit later on but first gonna add a few things and make this script abit better

from lesson 7 we had:


--- Code: ---Bot = "Keiko"

version = "0.7"
NEWCON = 1
prefix = "!"
TimeMins = 5  --set it to 5 mins
SendC = SendToAll

MessageTimer = 1

function Main()
frmHub:RegBot(Bot)
SetTimer(TimeMins*60000)
StartTimer()
end

function OnTimer()
if MessageTimer == 1 then
randomtimer = random(2) --only 2 data's
if randomtimer == 1 then
SendC(Bot,"-------------------------------")
SendC(Bot,"--Write your own bot lesson "..version.."--")
SendC(Bot,"-------------------------------")
elseif randomtimer == 2 then
SendC(Bot,"-----------------------------------------")
SendC(Bot,"--This lesson bot was created by Phatty--")
SendC(Bot,"-----------------------------------------")
end
end
end

function NewUserConnected(user)
if NEWCON == 1 then
user:SendData (Bot,"A User has connected")
end
end

function OpConnected(user)
Pillock = GetProfileName(user.iProfile)
thisisthevariable = random(5)
if thisisthevariable == 1 then
SendC(Bot,user.sName.." has entered the hub")

elseif thisisthevariable == 2 then
SendC(Bot,Pillock.." "..user.sName..",has entered, feel his wrath")  

elseif thisisthevariable == 3 then
SendC(Bot,user.sName.." is one of the big bosses, who just entered")

elseif thisisthevariable == 4 then
SendC(Bot,user.sName.." has sneaked into the hub")  

elseif thisisthevariable == 5 then
SendC(Bot,user.sName.." has just kicked down the door")
end
end



function DataArrival(user,data)
if strsub(data, 1, 1) == "

pHaTTy:
now that was checking a table, now we are going to store data in a table, we will accomplish this by the badwords, we will count each badword that is said by the users and after 3 times it will disconnect them


--- Code: ---BadWord={}

--- End code ---


and now the code


--- Code: ---function DataArrival(user,data)
if strsub(data, 1, 1) == "

pHaTTy:
someone finally spotted the error hahaha

pillock = user

pillock:Disconnect() ahahahah

user:Disconnect()



well done SaintSinner

plop:
there is another bug.
what happens when a user says 3x a bad word and comes back in the hub and says 1 more bad word ???

plop

Intel:
i know i am weeks late to this lesson but...cant we say
user:Kick("Too many Bad Words")

Navigation

[0] Message Index

[#] Next page

Go to full version