PtokaX forum

Archive => Archived 4.0 boards => Finished Lua 4 scripts => Topic started by: BossiDeLeon on 20 October, 2004, 00:17:15

Title: Time stamp
Post by: BossiDeLeon on 20 October, 2004, 00:17:15
i'm very new to this and i basically only want this one script to work.

i'm looking for a way to display the time and some text when i type a string in the main chat. i would aslo like the string that i type not to be displayed and be able to call a different function for each string that i type.

ex:
i type "\r" and it displays some text and the time
i type "\t" and it displays some different text and the time

thanks!


Title:
Post by: bolamix on 20 October, 2004, 06:49:36
Here you go. I haven't tested it but it should work.

--Requested by BossiDeLeon
--Taken by bolamix out of a bot
--made by Piglja(Just learning;P )
--"\" does not work for a command, so I used "+"

botname = "YourBotsName"
current = date("%H:%M")

Text1 = "the text for +r command"
Text2 = "the text for +t command"
--you can add more in the same fashion


function DataArrival(user, data)
if (strsub(data, 1, 1) == "<") then
data = strsub(data,1,strlen(data)-1)
local s,e,cmd = strfind(data,"%b<>%s+(%S+)")
if (cmd=="+r") then
user:SendData(botname, ""..Text1.." - The time now is: "..current)
return1
end
if (cmd=="+t") then
user:SendData(botname, ""..Text2.." - The time now is: "..current)
return1
end
end
end
Title:
Post by: BossiDeLeon on 20 October, 2004, 19:19:02
wow that was really fast, thanks a lot bolamix!! this script looks very nice!! but when i put it through the syntax check it gives me an error on the first return1 saying it was expecting an '='.

also, i know this is gonna sound very newbie but how do you activate scripts?! i'm using PtokaX 0.3.2.6

thanks again!!--Requested by BossiDeLeon
--Taken by bolamix out of a bot
--made by Piglja(Just learning;P )
--"\" does not work for a command, so I used "+"

botname = "YourBotsName"
current = date("%H:%M")

Text1 = "the text for +r command"
Text2 = "the text for +t command"
--you can add more in the same fashion

function DataArrival(user, data)
if (strsub(data, 1, 1) == "<") then
data = strsub(data,1,strlen(data)-1)
local s,e,cmd = strfind(data,"%b<>%s+(%S+)")
if (cmd=="+r") then
user:SendData(botname, ""..Text1.." - The time now is: "..current)
return1 --error
end
if (cmd=="+t") then
user:SendData(botname, ""..Text2.." - The time now is: "..current)
return1
end
end
end
Syntax Error: `=' expected;  last token read: `end' at line 20 in string "--Requested by BossiDeLeon..."
Title:
Post by: bolamix on 20 October, 2004, 23:20:28
Sorry, that was a stoopid mistake... forgot a space between "return" and "1"...

Here goes:--Requested by BossiDeLeon
--Taken by bolamix out of a bot
--made by Piglja(Just learning;P )
--"\" does not work for a command, so I used "+"

botname = "YourBotsName"
current = date("%H:%M")

Text1 = "the text for +r command"
Text2 = "the text for +t command"
--you can add more in the same fashion

function DataArrival(user, data)
if (strsub(data, 1, 1) == "<") then
data = strsub(data,1,strlen(data)-1)
local s,e,cmd = strfind(data,"%b<>%s+(%S+)")
if (cmd=="+r") then
user:SendData(botname, ""..Text1.." - The time now is: "..current)
return 1
end
if (cmd=="+t") then
user:SendData(botname, ""..Text2.." - The time now is: "..current)
return 1
end
end
end

To activate scripts:
1) Copy paste the code in a new txt file with a text editor.
2) Save the txt file with a .lua extension (if you use Notepad, select "All files" from the "Save as type" drop-down menu) in the "scripts" folder inside your Ptokax folder.
3) Click on "Restart scripts" in the Script editor (that's if your hub is running, otherwise it's grayed-out)
Title:
Post by: BossiDeLeon on 22 October, 2004, 03:17:06
cool! works great man!! thanks a lot!!

now if only i could figure how to print text from a text file into the main chat....
Title:
Post by: BossiDeLeon on 24 October, 2004, 17:54:47
thanks Mutor!! your script works fine! but it displays a time stamp whenever i excute it. is there any way to remove it??

thanks!
Title:
Post by: bolamix on 24 October, 2004, 23:16:47
Thx Mutor, that's a nice and simple one ;)

@BossiDeLeon: as far as I can see, Mutor's script doesn't add a time stamp, so it must be set in your client's preferences. Assuming you're using dc++ or one of its variations, typing /ts in mainchat should toggle the timestamp on/off.
Title:
Post by: BossiDeLeon on 25 October, 2004, 01:40:47
well i knew the client was adding the time stamps, i guess i should of asked this question then: it is possible to change your MOTD in a script?

i've tried using the new user connect function but it doesn't seem to work:function NewUserConnect(curUser)
curUser:SendData("bot", "hello")
end
i get no message when i connect to the hub...but i know i'm doing something wrong!

thanks again!
Title:
Post by: bastya_elvtars on 25 October, 2004, 02:42:57
its NewUserConnected

not NewUserConnect
Title:
Post by: bolamix on 25 October, 2004, 07:54:21
It is indeed NewUserConnected ;)
Incidentally, you can check this out (http://board.univ-angers.fr//thread.php?threadid=2293&boardid=12&sid=88c0faa2eab0241a7d7fc02bf856f16d) for a MOTD script.
Title:
Post by: BossiDeLeon on 25 October, 2004, 21:05:38
*smacks forehead* ops! i guess i should work on my copy and paste skills too huh!

thanks for all the info people! the MOTD script is working great, bolamix.

well i think i've asked enough questions for now!

thanks again everybody!