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

0 Members and 2 Guests are viewing this topic.

Offline klownietklowniet

  • Forum Ace
  • *****
  • Posts: 77
  • Karma: +0/-0
(No subject)
« Reply #50 on: 24 October, 2003, 16:32:19 »
In some programming languages one '=' is enough for an if test... *offtopic comment*
[ > DC - UniteD < ]

PtokaX forum

(No subject)
« Reply #50 on: 24 October, 2003, 16:32:19 »

Offline Optimus

  • Emperor
  • **
  • Posts: 1 474
  • Karma: +13/-1
(No subject)
« Reply #51 on: 24 October, 2003, 16:38:16 »
YW  :]

Offline raz

  • Triple Ace
  • **
  • Posts: 176
  • Karma: +4/-0
(No subject)
« Reply #52 on: 25 October, 2003, 14:23:24 »
so when is write you own bot = lesson 4 coming. been waiting 4 a little while now. ?(

Offline pHaTTy

  • Forum Legend
  • ***
  • Posts: 1 916
  • Karma: +5/-1
(No subject)
« Reply #53 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 ;)
Resistance is futile!

Offline pHaTTy

  • Forum Legend
  • ***
  • Posts: 1 916
  • Karma: +5/-1
(No subject)
« Reply #54 on: 25 October, 2003, 14:39:29 »
btw heres a little extra

Code: [Select]

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)
Resistance is futile!

Offline raz

  • Triple Ace
  • **
  • Posts: 176
  • Karma: +4/-0
(No subject)
« Reply #55 on: 25 October, 2003, 14:40:17 »
i wish it gets done quickly, so i can create my own bot sooon. :P

Offline SaintSinner

  • Lord
  • ***
  • Posts: 293
  • Karma: +1/-0
(No subject)
« Reply #56 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(data11) == "<" 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 

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 

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.
« Last Edit: 12 November, 2003, 20:53:06 by SaintSinner »
   


Offline pHaTTy

  • Forum Legend
  • ***
  • Posts: 1 916
  • Karma: +5/-1
(No subject)
« Reply #57 on: 12 November, 2003, 21:02:01 »
Look at the ends
Resistance is futile!

Offline SaintSinner

  • Lord
  • ***
  • Posts: 293
  • Karma: +1/-0
(No subject)
« Reply #58 on: 12 November, 2003, 21:09:48 »
Quote
Originally posted by (uk-kingdom)pH?tt?
Look at the ends



AAHHHHH
how could i have missed that
   


Offline SaintSinner

  • Lord
  • ***
  • Posts: 293
  • Karma: +1/-0
(No subject)
« Reply #59 on: 12 November, 2003, 22:05:25 »
what is the diffrence of
=
and
==

and when would you use them.
   


Offline pHaTTy

  • Forum Legend
  • ***
  • Posts: 1 916
  • Karma: +5/-1
(No subject)
« Reply #60 on: 12 November, 2003, 22:16:58 »
user = 2


if user == 1 then
Resistance is futile!

Offline SaintSinner

  • Lord
  • ***
  • Posts: 293
  • Karma: +1/-0
(No subject)
« Reply #61 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

Code: [Select]
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
   


Offline NightLitch

  • Emperor
  • **
  • Posts: 1 455
  • Karma: +16/-0
(No subject)
« Reply #62 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
//NL

Offline SaintSinner

  • Lord
  • ***
  • Posts: 293
  • Karma: +1/-0
(No subject)
« Reply #63 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.
   


Offline pHaTTy

  • Forum Legend
  • ***
  • Posts: 1 916
  • Karma: +5/-1
(No subject)
« Reply #64 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 ;)
Resistance is futile!

Offline SaintSinner

  • Lord
  • ***
  • Posts: 293
  • Karma: +1/-0
(No subject)
« Reply #65 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)
   


Offline pHaTTy

  • Forum Legend
  • ***
  • Posts: 1 916
  • Karma: +5/-1
(No subject)
« Reply #66 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
Resistance is futile!

Offline SaintSinner

  • Lord
  • ***
  • Posts: 293
  • Karma: +1/-0
(No subject)
« Reply #67 on: 14 November, 2003, 21:03:27 »
Quote
Originally 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?
   


Offline pHaTTy

  • Forum Legend
  • ***
  • Posts: 1 916
  • Karma: +5/-1
(No subject)
« Reply #68 on: 14 November, 2003, 21:11:31 »
hahah ok, :o)

i will make a lesson of it, lesson 7 will be on them ;)
Resistance is futile!

Offline Tarokkk

  • Member
  • ***
  • Posts: 37
  • Karma: +0/-0
Two variable ?
« Reply #69 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

PtokaX forum

Two variable ?
« Reply #69 on: 20 December, 2003, 14:10:45 »