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
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
now why write so much for the bots name, lets make it easier
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
-phatty
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
nope this is perfect :P
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
well keep going there is 5 lessons so far ;)
yes proffesor i fixed it
the error came from
function OpConnected(user)
SendToAll(Bot,"WElcome our Op "..user.sName" hope he enjoys his stay")
end
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? :]
very good ;)
thank you
how come you write
function OpConnected(user)<----(user)
and the ptokax scripting text show that the function is
function OpConnected(curUser),<---(curUser)
any diffrence in the functions, must not be huh
i did finished my first bot....YAAYY
Bot = "Archangel"
function NewUserConnected(user)
SendToAll(Bot, "Hello there jerkynuts "..user.sName.." how are you today")
end
function OpConnected(user)
SendToAll(Bot, "Bow before the "..user.sName.." feel his wrath!!!")
end
one question though how can i add the users profile in the SendToAll message? ie
Bow before the "..profile here.." "..user.sName.." feel his wrath!!!
i tried looking at the scripting text
and i tried
GetProfileIdx(profile_name)
that gives me
Bow before the -1saintsinner feel his wrath!!!
am i jumping ahead of myself?
will that be left for the next lesson, ok off to try a few more welcome messages and im off to lesson two.
i will include that in lesson 6
there is 4 more lessons atm for you ;)
QuoteOriginally posted by (uk-kingdom)pH?tt?
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
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
now why write so much for the bots name, lets make it easier
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
-phatty
Hi patty im trying to create ma one script but i always get an error. I've tried the script full (posted by u) but it still givin an error Syntax Error: attempt to call field `sName' (a string value)
heres the script
Bot = "1st"
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
Best regards
Bot = "1st"
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[COLOR=red]..[/COLOR] " hope he enjoys his stay")
end
add the .. to concat the string after that.
QuoteOriginally posted by [NL]Pur
Bot = "1st"
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[COLOR=red]..[/COLOR] " hope he enjoys his stay")
end
add the .. to concat the string after that.
Thnks!!! It worked great, now im going to lesson 2 :-)
Cheers...
i want the message to be like
Welcome to XXX hub.
when u join hub [ mesage only for ur eyes]
for both newuserconnected and opconnected
and wat to replace for sendtoall ??
better some1 post a simple code :P
thank u
user:SendData(Bot,"Welcome our new guest "..user.sName..", enyot your stay")
thank u
Cool works well thanks :D Is there a place where I can find other commands so I can finish writing my little bot?
have a peek in the ScriptingInterface.txt that comes along with PtokaX ;)
that first, otherwise you could also search through the scripts here or in the PtokaX Scriptdb and pick out certain functions from other scripts to use in your own one.
If you run into probs you can post what you have, along with its error and i'm sure someone would be able to help you along :D
Thanks I'll give that a whirl :D
MP
Quote from: bastya_elvtars on 04 November, 2005, 20:10:56
user:SendData(Bot,"Welcome our new guest "..user.sName..", enyot your stay")
If I want to display my hub name in tht message, thn wat shud I do??
like:
Welcome To Paradise Hub Mr.<username>, enjoy ur stay
Quote from: speedX on 12 November, 2006, 20:50:24
If I want to display my hub name in tht message, thn wat shud I do??
like:
Welcome To Paradise Hub Mr.<username>, enjoy ur stay
You can write anything between the quotation marks
Example
user:SendData(Bot,"Welcome To Paradise Hub Mr. "..user.sName..", enjoy ur stay")
Or maybe you can pull this from your hub:
user:SendData(Bot,"Welcome To "..frmHub:GetHubName().." Mr. "..user.sName..", enjoy ur stay")
Thx Naithif
And If I want to show the profile name also thn??
like:
Welcome Reg User <username>
Hi
That's only a little bit from there
Let's check PtokaX Scripting-Interface.txt
QuoteUser.
-----
..
iProfile
..
'i' means it's an integer, but we need it as a text, so let's find another command in the text file
QuoteProfiles
-------
..
GetProfileName(ProfileNumber) - Return ProfileName or nil for failed
..
This should do the trick
However it will return "nil" for User so another addition is needed
Let's add a variable called 'rank'. We need it because we want to modify it's value if it comes as 'nil'
rank = GetProfileName(user.iProfile)
if rank == nil then rank = "User"; end
First line makes rank equal to the profile's name that we got the number to
The second line makes rank = 'User' if it returns as nil because of the above
So this (Welcome Reg User <username>) would be
rank = GetProfileName(user.iProfile); if rank == nil then rank = "User"; end
user:SendData(Bot,"Welcome "..rank.." User "..user.sName)
This should be under the
function NewUserConnected(user)
Part because we added 'User' into the text (So it would became 'Welcome Reg User <username> and Welcome VIP User <username>)
Operators and masters shouldn't be called like that (OP User? ;D), but I believe you can mod their part ;)
Edit: Oops made a mistake, this way a User gets 'User User'
Check this bit for correction
Use this one
rank = GetProfileName(user.iProfile)
if rank == nil then rank = "User"; user:SendData(Bot,"Welcome "..rank.." "..user.sName)
else user:SendData(Bot,"Welcome "..rank.." User "..user.sName); end
That would mean that we create a different case if the user's a User to do not show 'User' extension (like with OPs ;) )
You could do it short as
(Don't use this one)
rank = GetProfileName(user.iProfile)
if rank == nil then rank = ""; end
user:SendData(Bot,"Welcome "..rank.." User "..user.sName)
This would only leave one 'User' word, but f**** up spaces and it looks bad for me
Cheers
This whole series of HOW-TO should really really be moved to the wiki (http://www.ptxwiki.psycho-chihuahua.net/);)
My guess would be that more people read these here than in the wiki - but they would be nice there too
And I like these tutorials, they're good for newbies (like me) :)
Hello Teachers
What is the
function to Register a Bot?
Quote from: JueLz on 13 November, 2006, 13:46:53
Hello Teachers
What is the
function to Register a Bot?
Please take a look at the Scripting-interface inside the PtokaX folder...
frmHub
------
RegBot(BotName) - Chars $|<>:?*"/\ and space not allowed, max length 64 chars. Here hub not create myinfo, you need for compatibility with some clients (DC2) to send bot myinfo by script !
RegBot(BotName, bIsOP, Description, Email) - Chars $|<>:?*"/\ and space not allowed in nick, $| not allowed in Description and Email, max length 64 chars per string. IsOP is number, 1 = have key, 0 = not have key. With this is created $MyINFO for bot !!! If you want $MyINFO without key/description/email use for example RegBot("botname", 0, "", "")
use like frmHub:RegBot(...)
Teachers LOL - would be funny :D
Jut don't forget to put it into "function Main()" function for example as it would be weird that the bot gets regged only on userconnect for example :)
function Main()
frmHub:RegBot(Bot)
end
Just don't forget do define your bot's name previously
Bot = "Write_any_name_here"
Anyway I don't understand why the inbuilt 1 bot isn't enough in PtokaX :)
Bot = frmHub:GetHubBotName()
And you get a 'Bot' called bot who's name equals the what you've set in your hub, no need to register it, and it should be capable of doing anything :D
Thx for the help Naithif
Quote from: Naithif on 13 November, 2006, 07:57:44
My guess would be that more people read these here than in the wiki
Yup even I agree to this :)
You're welcome :)
Quote from: Naithif on 13 November, 2006, 07:01:20
rank = GetProfileName(user.iProfile)
if rank == nil then rank = "User"; user:SendData(Bot,"Welcome "..rank.." "..user.sName)
else user:SendData(Bot,"Welcome "..rank.." User "..user.sName); end
or like this:
user:SendData(Bot,"Welcome "..(GetProfileName(user.iProfile) or "User").." "..user.sName)
Nice idea :D
I could have shorten it too (not this much though :D), but he asked for "Reg User" and this extension should go only to Reg and VIP
And wat code to show Welcome Operator speedX or Master speedX?
You can use any of them
rank = GetProfileName(user.iProfile)
user:SendData(Bot,"Welcome "..rank.." "..user.sName)
(No chance for nil because operator on login can't be user :D)
C??o?y??'s code is good as he pasted it there above
user:SendData(Bot,"Welcome "..(GetProfileName(user.iProfile) or "User").." "..user.sName)
is tat possible to add color in words if yes then in this script some error
[21:21] Syntax ... and Settings\SWAGAT.JAGIRDAR\Desktop\New Folder (3)\scripts\welcome.lua:15: ']' expected near '='
Bot = "1st"
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
no you cannot add colors by scripting
Hi does anyone know how I can get into the chat room?
Thank you