Author Topic: HOW-TO : Write your own Bot = Lesson 3  (Read 18915 times)

0 Members and 1 Guest are viewing this topic.

Offline pHaTTy

  • Forum Legend
  • ***
  • Posts: 1 916
  • Karma: +5/-1
(No subject)
« Reply #25 on: 22 October, 2003, 22:21:30 »
ok time to run thru it so you can see the mistakes and save for the next lesson

Code: [Select]

--you had this

Bot = "Keiko"
NEWCON = 1

function Main()
frmHub:RegBot(Bot)
end

function NewUserConnected(user)
if NEWCON then
user:SendData ("A User has connected")
else
end

function OpConnected()
if user.iprofile then
user:senddata(Bot,"Hello" ..user.sName.. "How are you")
return 1
else
SendToAll("A Op has entered")
end

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

if cmd == "!version" then
user:SendData(Bot,"This bot is Learn to write a bot version: "..version)
return 1
elseif cmd == "!help" then
user:SendData(Bot,"This is where the help text would go, but im not gonna waste my time :P")
return 1
end
end
end
end
end



ok


Code: [Select]

----this is fine
Bot = "Keiko"
NEWCON = 1

function Main()
frmHub:RegBot(Bot)
end
--------------------
function NewUserConnected(user)
if NEWCON==1 then  -- this needed to equal something
user:SendData (Bot,"A User has connected") --bot name/not important
else
end
end -- missing an end
-----------------------

function OpConnected(user)  -- missing user
if user.iprofile==0 then --the user profile for the profiles.dat file
user:SendData(Bot,"Hello " ..user.sName.. " How are you") --cap sensitive for senddata
return 1
else
SendToAll("A Op has entered")
end
end --another end
------------------------
function DataArrival(User,data)
if strsub(data, 1, 1) == "<" then
data=strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(data,"%b<>%s+(%S+)")

if cmd == "!version" then
user:SendData(Bot,"This bot is Learn to write a bot version: "..version)
return 1
elseif cmd == "!help" then
user:SendData(Bot,"This is where the help text would go, but im not gonna waste my time :P")
return 1
end
end
end
end


there ya go now you can study and learn from it, wait until next lesson i will start asap, and try make it alot better and longer ;)

-War3zMantis
Resistance is futile!

PtokaX forum

(No subject)
« Reply #25 on: 22 October, 2003, 22:21:30 »

Offline xokas

  • Double Ace
  • *
  • Posts: 133
  • Karma: +0/-0
(No subject)
« Reply #26 on: 22 October, 2003, 22:25:29 »
almost there yep :)))

Offline pHaTTy

  • Forum Legend
  • ***
  • Posts: 1 916
  • Karma: +5/-1
(No subject)
« Reply #27 on: 22 October, 2003, 22:27:15 »
yep ;) both doin good for only the third lesson, and this is the simple stuff, better to come yet ;)
Resistance is futile!

Offline xokas

  • Double Ace
  • *
  • Posts: 133
  • Karma: +0/-0
(No subject)
« Reply #28 on: 22 October, 2003, 22:28:38 »
let me have them let me have them :P i take them all out :) just kiding

Offline raz

  • Triple Ace
  • **
  • Posts: 176
  • Karma: +4/-0
(No subject)
« Reply #29 on: 22 October, 2003, 22:33:39 »
i admit dat i should of got "end" but i needed a bit of help on the other 2. which i didn't know

Offline pHaTTy

  • Forum Legend
  • ***
  • Posts: 1 916
  • Karma: +5/-1
(No subject)
« Reply #30 on: 22 October, 2003, 22:36:14 »
well has this helped you understadn it better? :)
Resistance is futile!

Offline raz

  • Triple Ace
  • **
  • Posts: 176
  • Karma: +4/-0
(No subject)
« Reply #31 on: 22 October, 2003, 22:38:02 »
this just shows that it ain't easy and u shouldn't try 2 get it done quickly cuz u might skip something. post next one up 2morrow. safe chat wid u 2morrrow.

Offline pHaTTy

  • Forum Legend
  • ***
  • Posts: 1 916
  • Karma: +5/-1
(No subject)
« Reply #32 on: 22 October, 2003, 22:39:34 »
hehe well if i get time i will start a redo of lesson 4 but make better, as i did put 2 in one, i was in a rush so i will spreadt it out and make a better lesson 4 ;)
Resistance is futile!

Offline xokas

  • Double Ace
  • *
  • Posts: 133
  • Karma: +0/-0
(No subject)
« Reply #33 on: 22 October, 2003, 22:41:21 »
for me the next one can come anytime!let them cum to me! :P

Offline Skrollster

  • Lord
  • ***
  • Posts: 293
  • Karma: +3/-0
(No subject)
« Reply #34 on: 23 October, 2003, 00:11:15 »
if you use the tag [code ] and [/code] then it's much esier to read the code, use tab as well so the code looks like this:

Code: [Select]
Bot = "(Keiko)" -- missing "" to show that it is a string
NEWCON = 1

Main()
frmHub:RegBot(Bot) -- spelling misstake on Bot
end

function NewUserConnected(CurUser)
if NEWCON == 1 then -- use dubble equal signs then compareing
user:SendData ("A User has connected") -- missed a " at the end of the text string
else
end
end -- missing end

function OpConnected()
if user.iProfile == 0 then -- need duble '=' again and iProfile is case sensitive
user:SendData(Bot,"Hello..user.sName..How are you") --Case sensitive function call + missing ')' in the end
return 1
else
SendToAll(Bot,"A Op has entered") -- function name senttoall ned to be SendToAll, case sensitive
end
end -- missing end

function Data Arrival(CurUser,data)
if strsub(data, 1, 1) == "<" then
data=strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(data,"%b<>%s+(%S+)") -- regular exp. wasn't used correctly and missing cmd variable

if cmd == "!version" then -- missing one '=' again
user:SendData(Bot,"This bot is Learn to write a bot version: "..version) --misspelled bot again and missing a declaration of version before using it..
return 1
elseif cmd == "!help" then -- missing one '=' again
user:SendData(Bot,"This is where the help text wud go, bt im not gonna waste my time :P") -- misspelled bot again
return 1
end
end
end -- missing an end

and not like

Bot = "(Keiko)" -- missing "" to show that it is a string
NEWCON = 1

Main()
   frmHub:RegBot(Bot) -- spelling misstake on Bot
end

function NewUserConnected(CurUser)
   if NEWCON == 1 then -- use dubble equal signs then compareing
   user:SendData ("A User has connected") -- missed a " at the end of the text string
   else
   end
end -- missing end

function OpConnected()
   if user.iProfile == 0 then -- need duble '=' again and iProfile is case sensitive
      user:SendData(Bot,"Hello..user.sName..How are you") --Case sensitive function call + missing ')' in the end
      return 1
   else
      SendToAll(Bot,"A Op has entered") -- function name senttoall ned to be SendToAll, case sensitive
   end
end -- missing end

function Data Arrival(CurUser,data)
   if strsub(data, 1, 1) == "<" then
      data=strsub(data,1,strlen(data)-1)
      s,e,cmd = strfind(data,"%b<>%s+(%S+)") -- regular exp. wasn't used correctly and missing cmd variable

      if cmd == "!version" then -- missing one '=' again
         user:SendData(Bot,"This bot is Learn to write a bot version: "..version) --misspelled bot again and missing a declaration of version before using it..
         return 1   
      elseif cmd == "!help" then -- missing one '=' again
         user:SendData(Bot,"This is where the help text wud go, bt im not gonna waste my time :P") -- misspelled bot again
         return 1
      end
   end
end -- missing an end

//Skrollster
« Last Edit: 23 October, 2003, 23:25:05 by Skrollster »

Offline xokas

  • Double Ace
  • *
  • Posts: 133
  • Karma: +0/-0
(No subject)
« Reply #35 on: 23 October, 2003, 11:21:23 »
tkhx for the hint skrollster! gonna try to do better on the nexts times! tkhx a lot again

Offline AlwaysConnected

  • Lord
  • ***
  • Posts: 460
  • Karma: +2/-0
(No subject)
« Reply #36 on: 23 October, 2003, 11:47:40 »
Quote
Originally posted by xokas
tkhx for the hint skrollster! gonna try to do better on the nexts times! tkhx a lot again

Weclome back Xokas aka ...... :)
and phatty go on with the lessons :)

its great :D

Offline xokas

  • Double Ace
  • *
  • Posts: 133
  • Karma: +0/-0
(No subject)
« Reply #37 on: 23 October, 2003, 12:02:24 »
hey hey hey! is it a star? a plane?its superman? maybe a flying saucer? RUN PEOPLE IT'S AC!  





h? h? h?! im back indeed AC, nice to see ya around here too!  :]

Offline pHaTTy

  • Forum Legend
  • ***
  • Posts: 1 916
  • Karma: +5/-1
(No subject)
« Reply #38 on: 23 October, 2003, 12:43:00 »
Quote
Originally posted by Skrollster
if you use the tag [code ] and [/code] then it's much esier to read the code, use tab as well so the code looks like this:

Code: [Select]
Bot = "(Keiko)" -- missing "" to show that it is a string
NEWCON == 1

Main()
frmHub:RegBot(Bot) -- spelling misstake on Bot
end

function NewUserConnected(CurUser)
if NEWCON == 1 then -- use dubble equal signs then compareing
user:SendData ("A User has connected") -- missed a " at the end of the text string
else
end
end -- missing end

function OpConnected()
if user.iProfile == 0 then -- need duble '=' again and iProfile is case sensitive
user:SendData(Bot,"Hello..user.sName..How are you") --Case sensitive function call + missing ')' in the end
return 1
else
SendToAll(Bot,"A Op has entered") -- function name senttoall ned to be SendToAll, case sensitive
end
end -- missing end

function Data Arrival(CurUser,data)
if strsub(data, 1, 1) == "<" then
data=strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(data,"%b<>%s+(%S+)") -- regular exp. wasn't used correctly and missing cmd variable

if cmd == "!version" then -- missing one '=' again
user:SendData(Bot,"This bot is Learn to write a bot version: "..version) --misspelled bot again and missing a declaration of version before using it..
return 1
elseif cmd == "!help" then -- missing one '=' again
user:SendData(Bot,"This is where the help text wud go, bt im not gonna waste my time :P") -- misspelled bot again
return 1
end
end
end -- missing an end

and not like

Bot = "(Keiko)" -- missing "" to show that it is a string
NEWCON == 1

Main()
   frmHub:RegBot(Bot) -- spelling misstake on Bot
end

function NewUserConnected(CurUser)
   if NEWCON == 1 then -- use dubble equal signs then compareing
   user:SendData ("A User has connected") -- missed a " at the end of the text string
   else
   end
end -- missing end

function OpConnected()
   if user.iProfile == 0 then -- need duble '=' again and iProfile is case sensitive
      user:SendData(Bot,"Hello..user.sName..How are you") --Case sensitive function call + missing ')' in the end
      return 1
   else
      SendToAll(Bot,"A Op has entered") -- function name senttoall ned to be SendToAll, case sensitive
   end
end -- missing end

function Data Arrival(CurUser,data)
   if strsub(data, 1, 1) == "<" then
      data=strsub(data,1,strlen(data)-1)
      s,e,cmd = strfind(data,"%b<>%s+(%S+)") -- regular exp. wasn't used correctly and missing cmd variable

      if cmd == "!version" then -- missing one '=' again
         user:SendData(Bot,"This bot is Learn to write a bot version: "..version) --misspelled bot again and missing a declaration of version before using it..
         return 1   
      elseif cmd == "!help" then -- missing one '=' again
         user:SendData(Bot,"This is where the help text wud go, bt im not gonna waste my time :P") -- misspelled bot again
         return 1
      end
   end
end -- missing an end

//Skrollster


hehehe Skrollster :P

whats this

NEWCON == 1 :P

NEWCON = 1
Resistance is futile!

Offline pHaTTy

  • Forum Legend
  • ***
  • Posts: 1 916
  • Karma: +5/-1
(No subject)
« Reply #39 on: 23 October, 2003, 12:44:05 »
Quote
Originally posted by AlwaysConnected
Quote
Originally posted by xokas
tkhx for the hint skrollster! gonna try to do better on the nexts times! tkhx a lot again

Weclome back Xokas aka ...... :)
and phatty go on with the lessons :)

its great :D


yep sure course i will m8, just installing linux for the next few hours, bloody drivers brrrrrrrrrrrrrr
Resistance is futile!

Offline xokas

  • Double Ace
  • *
  • Posts: 133
  • Karma: +0/-0
(No subject)
« Reply #40 on: 23 October, 2003, 12:46:30 »
Phatty move ya phatty ass! c'mon! ehehehhe
just kidding

Offline pHaTTy

  • Forum Legend
  • ***
  • Posts: 1 916
  • Karma: +5/-1
(No subject)
« Reply #41 on: 23 October, 2003, 12:50:53 »
Quote
Originally posted by xokas
Phatty move ya phatty ass! c'mon! ehehehhe
just kidding

You cheeky tw@ :P

nah have liux to install, seems bill wants to be a tw@ iand i dont like windows, so fk it, goodbye windows ehehehehe
Resistance is futile!

Offline raz

  • Triple Ace
  • **
  • Posts: 176
  • Karma: +4/-0
(No subject)
« Reply #42 on: 23 October, 2003, 17:25:32 »
yes phatty so whens the next lesson coming i am ready for this time i was in a hurry last time cuz i had 2 go 2 my otha house. put lesson 4 on. i am waiting for it.

Offline Skrollster

  • Lord
  • ***
  • Posts: 293
  • Karma: +3/-0
(No subject)
« Reply #43 on: 23 October, 2003, 23:27:05 »
Quote
Originally posted by (uk-kingdom)pH?tt?
hehehe Skrollster :P

whats this

NEWCON == 1 :P

NEWCON = 1

i still corrected more buggs then you knew where there :P

Offline pHaTTy

  • Forum Legend
  • ***
  • Posts: 1 916
  • Karma: +5/-1
(No subject)
« Reply #44 on: 24 October, 2003, 00:05:00 »
where?
Resistance is futile!

Offline Skrollster

  • Lord
  • ***
  • Posts: 293
  • Karma: +3/-0
(No subject)
« Reply #45 on: 24 October, 2003, 10:17:42 »
this is your fix:

Code: [Select]
----this is fine
Bot = "Keiko"
NEWCON = 1

function Main()
frmHub:RegBot(Bot)
end

--------------------

function NewUserConnected(user)
if NEWCON==1 then  -- this needed to equal something
user:SendData (Bot,"A User has connected") --bot name/not important
else
end
end -- missing an end

-----------------------

function OpConnected(user)  -- missing user
if user.iprofile==0 then --the user profile for the profiles.dat file
user:SendData(Bot,"Hello " ..user.sName.. " How are you") --cap sensitive for senddata
return 1
else
SendToAll("A Op has entered")
end
end --another end

------------------------

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

if cmd == "!version" then
user:SendData(Bot,"This bot is Learn to write a bot version: "..version)
return 1
elseif cmd == "!help" then
user:SendData(Bot,"This is where the help text would go, but im not gonna waste my time :P")
return 1
end
end
end
end

and this is mine:

Code: [Select]
Bot = "(Keiko)" -- missing "" to show that it is a string
NEWCON = 1

Main()
frmHub:RegBot(Bot) -- spelling misstake on Bot
end

function NewUserConnected(CurUser)
if NEWCON == 1 then -- use dubble equal signs then compareing
user:SendData ("A User has connected") -- missed a " at the end of the text string
else
end
end -- missing end

function OpConnected()
if user.iProfile == 0 then -- need duble '=' again and iProfile is case sensitive
user:SendData(Bot,"Hello..user.sName..How are you") --Case sensitive function call + missing ')' in the end
return 1
else
SendToAll(Bot,"A Op has entered") -- function name senttoall ned to be SendToAll, case sensitive
end
end -- missing end

function Data Arrival(CurUser,data)
if strsub(data, 1, 1) == "<" then
data=strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(data,"%b<>%s+(%S+)") -- regular exp. wasn't used correctly and missing cmd variable

if cmd == "!version" then -- missing one '=' again
user:SendData(Bot,"This bot is Learn to write a bot version: "..version) --misspelled bot again and missing a declaration of version before using it..
return 1
elseif cmd == "!help" then -- missing one '=' again
user:SendData(Bot,"This is where the help text wud go, bt im not gonna waste my time :P") -- misspelled bot again
return 1
end
end
end -- missing an end

you have one end too much, haven't declared version, using iprofile instead of iProfile.. probably more, but i don't have time..

Offline raz

  • Triple Ace
  • **
  • Posts: 176
  • Karma: +4/-0
(No subject)
« Reply #46 on: 24 October, 2003, 13:10:31 »
so when is the next lesson coming. put it up 2day  :D

Offline pHaTTy

  • Forum Legend
  • ***
  • Posts: 1 916
  • Karma: +5/-1
(No subject)
« Reply #47 on: 24 October, 2003, 15:34:20 »
well i have an excuse, im tired, not slept in 4 days agen brrrrrrrrrrrrrrrrr, my big 2 day sleep coming up lol
Resistance is futile!

Offline Optimus

  • Emperor
  • **
  • Posts: 1 474
  • Karma: +13/-1
(No subject)
« Reply #48 on: 24 October, 2003, 16:06:07 »
mmm, testing this bot and still giving errorssss

gone give a update

btw,

function NewUserConnected(CurUser)  --// mmm (CurUser)

user:SendData ("A User has connected") --// mm (user)

---- some 1 forgot the part (function)

Main()
must be
function Main()

---- And a other 1

function Data Arrival(user,data)
must be
function DataArrival(user,data)

---- you are asking for a version?

user:SendData(Bot,"This bot is Learn to write a bot version: "..version)

Syntax Error: attempt to concat global `version' (a nil value)

so there needs to be something like: version = "0.3"

----- Last 1, function OpConnected()    -    must be function OpConnected(user)

bla bla  :D

Offline Optimus

  • Emperor
  • **
  • Posts: 1 474
  • Karma: +13/-1
(No subject)
« Reply #49 on: 24 October, 2003, 16:21:24 »
New try....


Bot = "(Keiko)"

version = "0.3"
NEWCON = 1

function Main()
   frmHub:RegBot(Bot)
end

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

function OpConnected(user)
   if user.iProfile == 0 then
      user:SendData(Bot,"Hello Master "..user.sName.." How are you")
      return 1
   else
      SendToAll(Bot,"A Op has entered")
   end
end

function DataArrival(user,data)
   if strsub(data, 1, 1) == "<" then
      data=strsub(data,1,strlen(data)-1)
      s,e,cmd = strfind(data,"%b<>%s+(%S+)")
      if cmd == "!version" then
         user:SendData(Bot,"This bot is Learn to write a bot version: "..version)
         return 1   
      elseif cmd == "!help" then
         user:SendData(Bot,"This is where the help text wud go, bt im not gonna waste my time :P")
         return 1
      end
   end
end

PtokaX forum

(No subject)
« Reply #49 on: 24 October, 2003, 16:21:24 »