2 scripts in to 1
 

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

2 scripts in to 1

Started by QuikThinker, 08 June, 2004, 03:44:48

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

QuikThinker

Hey guys,
I'm runnin 2 scripts exactly the same apart from just 2 differences (bot name & txt file).

bot = "PHH Hub Radio"
mins = 20 
file = "MsgAll.txt" 

function Main() 
SetTimer(mins*60000) 
StartTimer() 
end 

function OnTimer() 
local handle = openfile(file, "r") 
if (handle ~= nil) then 
local line = read(handle) 
while line do 
SendToAll(bot,line) 
line = read(handle) 
end 
closefile(handle) 
end 
end
And.....

bot = "Pure Network" 
mins = 58 
file = "MsgAll2.txt" 

function Main() 
SetTimer(mins*60000) 
StartTimer() 
end 

function OnTimer() 
local handle = openfile(file, "r") 
if (handle ~= nil) then 
local line = read(handle) 
while line do 
SendToAll(bot,line) 
line = read(handle) 
end 
closefile(handle) 
end 
end
Just wondered if these could be made in 2 one script rather than runnin 2? Or would it make no real difference?

Thanx in advance,
Quik.

nErBoS

#1
Hi,

Made some little changes, try out this one...

--Little changed by nErboS

bot = "PHH Hub Radio"

sec = 60
 
fMsgAll = "MsgAll.txt" 
sMsgAll = ""

fMsgAll2 = "MsgAll2.txt" 
sMsgAll2 = ""

tClock = {
	["tMsgAll"] = clock() + 20*sec,		-- Time to show in minutes
	["tMsgAll2"] = clock() + 58*sec,	-- Time to show in minutes
}

function Main()
	sMsgAll = Readtext(fMsgAll)
	sMsgAll2 = Readtext(fMsgAll2)
	StartTimer() 
end 

function OnTimer() 
	if (tClock["tMsgAll"] <= clock() and sMsgAll~= "") then
		tClock["tMsgAll"] = clock() + 20*sec
		SendToAll(bot, sMsgAll)
	end
	if (tClock["tMsgAll2"] <= clock() and sMsgAll2~= "") then
		tClock["tMsgAll2"] = clock() + 58*sec
		SendToAll(bot, sMsgAll2)
	end
end

function Readtext(file)
	local sTmp = ""
	if (readfrom(file) ~= nil) then	
		readfrom(file)
		while 1 do
			local sLine = read()
			if (sLine == nil) then
				break
			else
				sTmp = sTmp..sLine.."\r\n"
			end
		end
		readfrom()
	end
	return sTmp
end

Best regards, nErBoS
--## nErBoS Spot ##--

QuikThinker

hmmmm nErBoS the only thing is the 2 bots have different names and u only accounted 4 one?
bot = "PHH Hub Radio"
bot = "Pure Network"

Or is that gonna be a problem havin 2 different named bots in the same script? :s

Herodes

QuoteOriginally posted by QuikThinker
hmmmm nErBoS the only thing is the 2 bots have different names and u only accounted 4 one?
bot = "PHH Hub Radio"
bot = "Pure Network"

Or is that gonna be a problem havin 2 different named bots in the same script? :s

It will be a problem ...
You can have as many variables as u want as long as they are not the same ...
botA =  "PHH Hub Radio"
botB = "Pure Network"

But I think u don't need them ,,,
Notice that the variable that nErBoS is using is used in the script in the following ...
Line 40 :  SendToAll(bot, sMsgAll)
Line 44: SendToAll(bot, sMsgAll2)

QuikThinker

The problem is tho that the bot name is not kept in msgall or msgall2, that info is in the script itself so surely even tho its being told 2 read 2 different txt files they will still have the same bot name "PHH Hub Radio" ?

Herodes

QuoteOriginally posted by QuikThinker
The problem is tho that the bot name is not kept in msgall or msgall2, that info is in the script itself so surely even tho its being told 2 read 2 different txt files they will still have the same bot name "PHH Hub Radio" ?
yes ... indeed ..

[UK]Madman

Slight ammendment .. 2 bot names.....

--Little changed by nErboS

bot = "PHH Hub Radio"
[B]bot2 = "Pure Network"[/B] 
sec = 60
 
fMsgAll = "MsgAll.txt" 
sMsgAll = ""

fMsgAll2 = "MsgAll2.txt" 
sMsgAll2 = ""

tClock = {
	["tMsgAll"] = clock() + 20*sec,		-- Time to show in minutes
	["tMsgAll2"] = clock() + 58*sec,	-- Time to show in minutes
}

function Main()
	sMsgAll = Readtext(fMsgAll)
	sMsgAll2 = Readtext(fMsgAll2)
	StartTimer() 
end 

function OnTimer() 
	if (tClock["tMsgAll"] <= clock() and sMsgAll~= "") then
		tClock["tMsgAll"] = clock() + 20*sec
		SendToAll(bot, sMsgAll)
	end
	if (tClock["tMsgAll2"] <= clock() and sMsgAll2~= "") then
		tClock["tMsgAll2"] = clock() + 58*sec
		[B]SendToAll(bot2, sMsgAll2)[/B] 
	end
end

function Readtext(file)
	local sTmp = ""
	if (readfrom(file) ~= nil) then	
		readfrom(file)
		while 1 do
			local sLine = read()
			if (sLine == nil) then
				break
			else
				sTmp = sTmp..sLine.."\r\n"
			end
		end
		readfrom()
	end
	return sTmp
end

Herodes

Bravo Madman ,,,
I wanted to do that but I was a bit bored to ..  ;(
Sorry, lazy day  2day ...

SMF spam blocked by CleanTalk