Development Section > HOW-TO's

HOW-TO : Write your own Bot = Lesson 1

(1/7) > >>

pHaTTy:
First of all you need to have an idea of what its gonna do, for this example we'll make a little welcome msg's for connecting users



For the functions

--function --all functions must begin with this

function NewUserConnected(user) --this is a ptokax standard
SendToAll("J???","Welcome our new guest "..user.sName..", enyot your stay") --SendToAll --remember cap sensitive, sendtoall is differ to SendToAll
end -- function

function OpConnected(user)
SendToAll("J???","WElcome our Op "..user.sName" hope he enjoys his stay")
end --function

now we have a little script, keep awaiting lesson 2 ;)

the script without comments


--- Code: ---


function NewUserConnected(user)
SendToAll("J???","Welcome our new guest "..user.sName..", enyot your stay")
end

function OpConnected(user)
SendToAll("J???","WElcome our Op "..user.sName" hope he enjoys his stay")
end


--- End code ---


now why write so much for the bots name, lets make it easier


--- Code: ---
Bot = "J???"


function NewUserConnected(user)
SendToAll(Bot,"Welcome our new guest "..user.sName..", enyot your stay")
end

function OpConnected(user)
SendToAll(Bot,"WElcome our Op "..user.sName" hope he enjoys his stay")
end


--- End code ---


-phatty

SaintSinner:
hello proffesor phatty
is school still in session :D
i tried writing this bot but i only get this
Syntax Error: attempt to call field `sName' (a string value)
even when i copy and paste your script to see if i was doing something wrong i get the same error

pHaTTy:
nope this is perfect :P


--- Code: ---
Bot = "J???"


function NewUserConnected(user)
SendToAll(Bot,"Welcome our new guest "..user.sName..", enyot your stay")
end

function OpConnected(user)
SendToAll(Bot,"WElcome our Op "..user.sName" hope he enjoys his stay")
end



--- End code ---


well keep going there is 5 lessons so far ;)

SaintSinner:
yes proffesor i fixed it
the error came from


--- Code: ---

function OpConnected(user)
SendToAll(Bot,"WElcome our Op "..user.sName" hope he enjoys his stay")
end


--- End code ---

there are no dots after the "..user.sName" so when i tried to logon with as operator it gave me the error message, and no greeting, but when i added .. it works with no errors and the welcome message.

whadathink?  :]

pHaTTy:
very good ;)

Navigation

[0] Message Index

[#] Next page

Go to full version