Time stamp
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

Time stamp

Started by BossiDeLeon, 20 October, 2004, 00:17:15

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

BossiDeLeon

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!



bolamix

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
Sharing is of the essence!

Live music >> Aiwadirock! live music hub
PtokaX knowledge >> The PtokaX Wiki

BossiDeLeon

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

bolamix

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)
Sharing is of the essence!

Live music >> Aiwadirock! live music hub
PtokaX knowledge >> The PtokaX Wiki

BossiDeLeon

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

BossiDeLeon

thanks Mutor!! your script works fine! but it displays a time stamp whenever i excute it. is there any way to remove it??

thanks!

bolamix

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.
Sharing is of the essence!

Live music >> Aiwadirock! live music hub
PtokaX knowledge >> The PtokaX Wiki

BossiDeLeon

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!

bastya_elvtars

its NewUserConnected

not NewUserConnect
Everything could have been anything else and it would have just as much meaning.

bolamix

It is indeed NewUserConnected ;)
Incidentally, you can check this out for a MOTD script.
Sharing is of the essence!

Live music >> Aiwadirock! live music hub
PtokaX knowledge >> The PtokaX Wiki

BossiDeLeon

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

SMF spam blocked by CleanTalk