PtokaX forum

Development Section => HOW-TO's => Topic started by: pHaTTy on 22 October, 2003, 12:58:12

Title: HOW-TO : Write your own Bot = Lesson 3
Post by: pHaTTy on 22 October, 2003, 12:58:12
Lesson 3 ;)
Blocking the inbuilt functions,
Blocking the functions is using the data arrival as the data is arriving
example

function DataArrival(user,data)
   if (strfind(data, "$Kick")) then
   return 1
   end
end


the above will block kick, but remember it will on block the inbuilt right click
blocking a scripted kick is alot different, anyways, try and stop ban by yourself ;)
hint, it can be accomplished by blocking !ban


Start Learning now.......;)
Ok i have wrote a little task, i am gonna write a script then brake it so it doesnt work...
Then i want you to try fix it and post back, i will make it simple(only newbies please) ;)

Bot = Keiko

Main()
frmHub:RegBotName()
end

function NewUserConnected()
SendToAll ("A User has connected)
end

function OpConnected()
sendtoall("A Op has entered")
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+)")

if cmd == !version then
user:SendData(Bot,"This bot is Learn to write a bot version: "..version)
return 1
end
end
end


Ok i have made lots of common mistakes (on purpose) :P
So now i wait for you to try and fix them and post back ;)
Also include the mistakes you have found and fixed, tell me how you realised the mistake and how fixed
Remember im here to help, so if you follow this you will be writing your own scripts in no time ;)

l8rr,,

-phatty


PS : If you are a good scripter, and dying to post back, send me as pm :P

heheehe
Title:
Post by: raz on 22 October, 2003, 13:21:02
first mistake is u don't have a version. e.g. version = "0.2 by ".

Main()
frmHub:RegBotName()
end

the second is dat u can't start a script wid main u need 2 have function in front of it. e.g. functionMain(), and u can't have reg bot name because that won't know the name of the bot. so u will have 2 take "Name" off and put "bot" in brackets.e.g.


function Main()
frmHub:RegBot(Bot)
end
Title:
Post by: pHaTTy on 22 October, 2003, 14:18:18
yep thats it ur getting there, now for the rest, keep going :) wd

there is 2 more mistakes ;)
Title:
Post by: Skrollster on 22 October, 2003, 14:28:52
A realy good example, i think i'll have to write a lesson later on, then it get more complex ( then i get my comp up and running that is, i guess it has got quite complex by then)

:)
Title:
Post by: pHaTTy on 22 October, 2003, 14:52:30
hehehe :o)
Title:
Post by: servaks on 22 October, 2003, 15:40:58
Very nice...

/shipis
Title:
Post by: pHaTTy on 22 October, 2003, 15:43:31
QuoteOriginally posted by servaks
Very nice...

/shipis

ahh but have you spotted the other 2 common mistakes ;)
Title:
Post by: pHaTTy on 22 October, 2003, 15:44:58
ooops btw theres 3 more mistakes i forgot to say one lol ;)
Title:
Post by: servaks on 22 October, 2003, 16:03:53
lol  :D

/shipis
Title:
Post by: xokas on 22 October, 2003, 20:38:08
The others mistakes are:

1->

function Data Arrival(CurUser,data)

the correct sintax is :


function DataArrival(CurUser,data)


2->

if cmd == !version then

the correct sintax is:

if cmd == "!version" then






i guess it's pretty those! i hope i haven't missed any



xokas over&out
Title:
Post by: pHaTTy on 22 October, 2003, 21:12:36
youve missed one more ;)
Title:
Post by: raz on 22 October, 2003, 21:19:49
u r still missing out.

1)
function NewUserConnected()
SendToAll ("A User has connected)
end

u r missing user which should be in barackets after newuser connected.which should be
function NewUserConnected(user)

and then u r missing Bot which should be in brackets.
SendToAll(Bot,.  and den in the brackets u have a user  has connected which should end in brackets and also have  "..user.sName..",  2 show the name of the user.
this is what it should look like.

function NewUserConnected(user)
SendToAll(Bot,"Welcome our new guest "..user.sName..", enyot your stay")
end
Title:
Post by: pHaTTy on 22 October, 2003, 21:21:05
yep well done for the last fixe function ;)

more to coem on next lesson
Title:
Post by: xokas on 22 October, 2003, 21:27:01
grrrr i have spoted that one but it missed me! maybe next time!
Title:
Post by: raz on 22 October, 2003, 21:30:01
the other 1 is in op connected in brackets u need user e.g. function OpConnected(user).
some of the letters in sendtoall have 2 be capital e.g. SendToAll.
and u need bot in bracketse.g. SendToAll(Bot,
it should all like something like this
function OpConnected(user)
SendToAll(Bot,"Welcome the op "..user.sName..", enjoy your stay")
end

shouldn't it be enjoy  not enjot.
Title:
Post by: pHaTTy on 22 October, 2003, 21:31:56
lol yep sure heheeh, well done
Title:
Post by: raz on 22 October, 2003, 21:37:56
so when  r u posting up the next step 2 creating a bot. the thing is i wnat 2 advance my skills. at the moment i don't know nothing about the sciprts not a lot.so dats y i want 2 learn dem.
Title:
Post by: pHaTTy on 22 October, 2003, 21:38:14
ok for a continue on this lesson i will write a bigger one for to let the other keep up here we go, i will make more mistakes, and try hiding a few ;)


Bot = (Keiko)
NEWCON == 1

Main()
frmHub:RegBot(Bos)
end

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

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

function Data Arrival(CurUser,data)
if strsub(data, 1, 1) == "<" then
data=strsub(data,1,strlen(data)-1)
s,e,= strfind(data,"%b<>%")

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


end
end


ok theres at least 15-16 erros on this one, good luck ;)
Title:
Post by: pHaTTy on 22 October, 2003, 21:39:42
btw, have a go, but paste the full thing with all the errors you spot fixed, and please use the [code ] brackets around the code please :o)
Title:
Post by: raz on 22 October, 2003, 22:08:04
i have done it is it right can u have a look.i am sorry but i don't know how 2 do the code thing.


Bot = (Keiko)
version = "0.2 by phatty"
NEWCON = 1

function Main()
frmHub:RegBot(Bot)
end

function NewUserConnected(user)
if NEWCON then
SendToAll(Bot, "A User has connected")
end

function OpConnected(user)
user.iprofile =
SendData(Bot, "Hello..user.sName..How are you")
SendToAll(Bot, "The 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<>%")

   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
end
Title:
Post by: raz on 22 October, 2003, 22:08:53
have a look is it right. if it is just give another 1 dat didn't look dat hard.
Title:
Post by: xokas on 22 October, 2003, 22:14:40
i have this! if some mistake or error tell me so i can learn ! tkhx



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







i just haven't figured out that one:

function OpConnected()
if user.iprofile  then
Title:
Post by: pHaTTy on 22 October, 2003, 22:15:52
QuoteOriginally posted by raz
have a look is it right. if it is just give another 1 dat didn't look dat hard.

i can see 5 mistakes
Title:
Post by: raz on 22 October, 2003, 22:18:53
wat is newcon? wat does it do?
Title:
Post by: xokas on 22 October, 2003, 22:20:37
grrrr one mistake! i missed this


version = "botversion"
Title:
Post by: pHaTTy 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


--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



----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
Title:
Post by: xokas on 22 October, 2003, 22:25:29
almost there yep :)))
Title:
Post by: pHaTTy 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 ;)
Title:
Post by: xokas on 22 October, 2003, 22:28:38
let me have them let me have them :P i take them all out :) just kiding
Title:
Post by: raz 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
Title:
Post by: pHaTTy on 22 October, 2003, 22:36:14
well has this helped you understadn it better? :)
Title:
Post by: raz 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.
Title:
Post by: pHaTTy 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 ;)
Title:
Post by: xokas on 22 October, 2003, 22:41:21
for me the next one can come anytime!let them cum to me! :P
Title:
Post by: Skrollster 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:

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
Title:
Post by: xokas 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
Title:
Post by: AlwaysConnected on 23 October, 2003, 11:47:40
QuoteOriginally 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
Title:
Post by: xokas 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!  :]
Title:
Post by: pHaTTy on 23 October, 2003, 12:43:00
QuoteOriginally 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:

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
Title:
Post by: pHaTTy on 23 October, 2003, 12:44:05
QuoteOriginally posted by AlwaysConnected
QuoteOriginally 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
Title:
Post by: xokas on 23 October, 2003, 12:46:30
Phatty move ya phatty ass! c'mon! ehehehhe
just kidding
Title:
Post by: pHaTTy on 23 October, 2003, 12:50:53
QuoteOriginally 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
Title:
Post by: raz 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.
Title:
Post by: Skrollster on 23 October, 2003, 23:27:05
QuoteOriginally 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
Title:
Post by: pHaTTy on 24 October, 2003, 00:05:00
where?
Title:
Post by: Skrollster on 24 October, 2003, 10:17:42
this is your fix:

----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:

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..
Title:
Post by: raz on 24 October, 2003, 13:10:31
so when is the next lesson coming. put it up 2day  :D
Title:
Post by: pHaTTy 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
Title:
Post by: Optimus 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
Title:
Post by: Optimus 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
Title:
Post by: klownietklowniet on 24 October, 2003, 16:32:19
In some programming languages one '=' is enough for an if test... *offtopic comment*
Title:
Post by: Optimus on 24 October, 2003, 16:38:16
YW  :]
Title:
Post by: raz on 25 October, 2003, 14:23:24
so when is write you own bot = lesson 4 coming. been waiting 4 a little while now. ?(
Title:
Post by: pHaTTy on 25 October, 2003, 14:37:22
When i het some time, might be today, still sorting linux, its been a tw@ been told my modem not got the linux drivers for it out, so im getting someone to write some now, shud be done soon i hope :o)

Then i will start with lesson 4, as i got some plans for it ;)
Title:
Post by: pHaTTy on 25 October, 2003, 14:39:29
btw heres a little extra


Bot = "Keiko"

version = "0.3"
NEWCON = 1
prefix = "!"

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 == prefix.."version" then
user:SendData(Bot,"This bot is Learn to write a bot version: "..version)
return 1
elseif cmd == prefix.."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


but ill explain more on next lesson ;)

not so tired now :o)
Title:
Post by: raz on 25 October, 2003, 14:40:17
i wish it gets done quickly, so i can create my own bot sooon. :P
Title:
Post by: SaintSinner on 12 November, 2003, 20:50:49

Bot = "Keiko"
version = "voltron"

function Main()
frmHub:RegBot(Bot)
end

function NewUserConnected(user)
SendToAll(Bot, "A User has connected, welcome "..user.sName.." stand up and cheer.")
end

function OpConnected(user)
SendToAll(Bot,"Master of all that is peersharing "..user.sName.." has entered the hub.")
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
end
end
end

 

ok i got some of it right off hand but the protions i was having problems with are
this is what i used:

if cmd == "!version" then
user:SendData(Bot,"This bot is Learn to write a bot version: "..version)
return 1
end
end
end
 

this was your nonworkingone:

if cmd == !version then
user:SendData(Bot,"This bot is Learn to write a bot version: "..version)
return 1
end


 

i added the "" to the version

i cant see the diffrence is the two functions.
can you point it out.
Title:
Post by: pHaTTy on 12 November, 2003, 21:02:01
Look at the ends
Title:
Post by: SaintSinner on 12 November, 2003, 21:09:48
QuoteOriginally posted by (uk-kingdom)pH?tt?
Look at the ends



AAHHHHH
how could i have missed that
Title:
Post by: SaintSinner on 12 November, 2003, 22:05:25
what is the diffrence of
=
and
==

and when would you use them.
Title:
Post by: pHaTTy on 12 November, 2003, 22:16:58
user = 2


if user == 1 then
Title:
Post by: SaintSinner on 14 November, 2003, 15:16:04
ok guys i know im behind
i was left back in prekindergarden.....heeheee :D  :D

but i cannot get
!version or
!help to show what is in the script
!version show errors and !help
shows the ptokax inbuilt commands
with error
"Syntax Error: attempt to index global `user' (a nil value)"
 so the return1
is not working and i tried it with my script and
skrollster's

function DataArrival(CurUser,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
Title:
Post by: NightLitch on 14 November, 2003, 15:28:38
your problem lies here:

function DataArrival(CurUser ,data)
(by the way this line is wrong, it should be:

function DataArrival(curUser ,data)

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

user :SendData(Bot,"This is where the help text wud go, bt im not gonna waste my time :P")

looking at various scripts you notice some use user
and some curUser...

in your case, you have in your function curUser
so all user Data sending should be entered with (curUser not user try that...

/NightLitch
Title:
Post by: SaintSinner on 14 November, 2003, 16:04:51
@NightLitch
yup that got it working
thanks

so for any new funtion
if you define the function with curUser
every string has to have curUser?
if yes
then curUser and user are basically the same thing?
except when in a function.
Title:
Post by: pHaTTy on 14 November, 2003, 16:07:19
ok for example if i make

function DataArrival(user,data)

then its

user:SendPM

if i made

function DataArrival(Num,Nuts)

then it wud be

Num:SendPM

hope that helps ;)
Title:
Post by: SaintSinner on 14 November, 2003, 20:15:29
i dont think i ever caught what
NEWCON =1
means, im guessing if stands for new connection,
but why have that when you already have a
function for:
function NewUserConnected(user)
Title:
Post by: pHaTTy on 14 November, 2003, 20:25:16
NEWCON = 1 is not a function is a variable

look for if NEWCON == 1 then

then watch what it does, then try change NEWCON = 1 to NEWCON = 0 also check the first ever lesson it is explained somewhere along the lines.

you must be skipping because tere is alot you dont understand, and asking questions on things that is in the last lessons ;)

go back and read slowly and carefully ;)

-phatty
Title:
Post by: SaintSinner on 14 November, 2003, 21:03:27
QuoteOriginally posted by (uk-kingdom)pH?tt?
NEWCON = 1 is not a function is a variable

look for if NEWCON == 1 then

then watch what it does, then try change NEWCON = 1 to NEWCON = 0 also check the first ever lesson it is explained somewhere along the lines.

you must be skipping because tere is alot you dont understand, and asking questions on things that is in the last lessons ;)

go back and read slowly and carefully ;)

-phatty



lol i am reading slowly and carefully
and i go over the lessons over and over and over
again "..user.sName.." has the time to learn this
while i am at work.
the there is no explanation of what NEWCON is
it only shows up on one of the bots in lesson three
and then some butting heads between you and skrollster.

I enjoy your lessons and i appreciate that you do this, you really tailor it for nobbies like myself but you have to be prepared for questions. :D  :]  :))
i just dont want to write the code
i want to understand what it does?
Title:
Post by: pHaTTy on 14 November, 2003, 21:11:31
hahah ok, :o)

i will make a lesson of it, lesson 7 will be on them ;)
Title: Two variable ?
Post by: Tarokkk on 20 December, 2003, 14:10:45
--Welcomes
   -- Users
   welcome_users = "Hi ?s ?rezd j?l magad"
   -- OPs
   welcome_op_1 = ""
   welcome_op_2 = ""
   welcome_op_3 = ""
   welcome_op_4 = ""
   welcome_op_5 = ""


function NewUserConnected(user)
if Connectusermess == 1 then
SendToAll(Bot, user.sName..""..welcome_users)
end
end
----------------
if ConnectOpmess == 1 then
   function OpConnected(user)
   Pillock = GetProfileName(user.iProfile)
        MessOp = random(5)
        SendToAll(Bot,_________) --<--This is the qestion  ?( ... What I have to write there ? welcome_op_(??? this is the number Mess OP)
        end
   end
end


----Thx