Restartimer
 

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

Restartimer

Started by Dessamator, 22 March, 2005, 12:34:29

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Dessamator

--lua5 version
--made by Dessamator borrowing some ideas from timebot

sBot = frmHub:GetHubBotName()
sec = 1000
min = sec*60
botDesc = "" 
botSpeed = "" 
botEmail = "" 
botShare = 0
startchars ="•"  -- shows before 
endchrs = "•"       -- shows after 
--------------------------------------------------------
function Main() 
	SetTimer(sec)
end 
--------------------------------------------------------
function OnTimer()
	if time > 0 then
frmHub:UnregBot(startchars..time..endchrs)
	time = time - 1
frmHub:RegBot(startchars..time..endchrs)
	else
frmHub:UnregBot(startchars..time..endchrs)
frmHub:Restart()
	end
end
--------------------------------------------------------
--------------------------------------------------------
function ChatArrival(user, data)
	data = string.sub(data,1,string.len(data)-1)
		s,e,cmd = string.find(data, "%b<>%s+(%S+)")
		if (string.lower(cmd) == "!restartimer") then
		timer(user, data)
		return 1
			
		end
end
ToArrival=ChatArrival

function timer(user,data)
Nick = user
local s,e,input = string.find(data, "%b<>%s+%S+%s+(.+)")

if input== nil or tonumber(input)==nil then
SendPmToNick(user.sName,sBot, "Syntax error, the correct syntax is: !restartimer ")
elseif user.iProfile==5 or user.iProfile==0 then
time=tonumber(input)
	StartTimer() 
	SendToAll(sBot,"• THE HUB WILL RESTART IN "..time.." SECS •")
	frmHub:RegBot(startchars..time..endchrs)
else
user:SendData(sBot,"You Cant restart the hub")
return 1
	end
end
Ignorance is Bliss.

aL1en

can you make a timer bot for execute the command '!restartscripts' ?

just to restart scripts if no masters are there to do it ;)

Dessamator

#2
QuoteOriginally posted by aL1en
can you make a timer bot for execute the command '!restartscripts' ?

just to restart scripts if no masters are there to do it ;)

hmm,ok ill c if its possible, workin on it !
Ignorance is Bliss.

Dessamator

here u go :

--by Dessamator

sBot = frmHub:GetHubBotName()
sec = 1000
min = sec*60
hour = min*60
time =12*hour

--------------------------------------------------------

function Main()
dofile("test1.lua") -- write here the name of ur script between the quotations, ps it must b the exact name!!!!
dofile("test2.lua") --
SetTimer(time)
StartTimer() 
	
end 
--------------------------------------------------------
function OnTimer()
SendPmToOps(sBot,"Scripts restarted automatically!!")	
OnExit()
Main()
end
--------------------------------------------------------
--------------------------------------------------------
function OnExit()
end

ps. u have to write the name of each script,
ex.:dofile("trivia.lua").

ptokax doesnt seem to have an option to restartscripts without the using the server, at least i couldnt find it!!

hope it helps!
Ignorance is Bliss.

Dessamator

--for ptokax 17.02 and above
--by Dessamator

sBot = frmHub:GetHubBotName()

-----------------------------------------------------------
sec = 1000
min = sec*60
hour = min*60
time =12*hour

--------------------------------------------------------

function Main()
SetTimer(time)
StartTimer() 
end 
--------------------------------------------------------
function OnTimer()
SendPmToOps(sBot,"Scripts restarted automatically!!")	
frmHub:RestartScripts()
end
--------------------------------------------------------
--------------------------------------------------------

new way of doing it, in new ptokax,  ;)
Ignorance is Bliss.

Dessamator

#5
-- small mod now shows  countdown in topic also
--lua5 version
--made by Dessamator borrowing some ideas from timebot
HubName= frmHub:GetHubName()
sBot = frmHub:GetHubBotName()
sec = 1000
min = sec*60
botDesc = "" 
botSpeed = "" 
botEmail = "" 
botShare = 0
startchars ="?"  -- shows before 
endchrs = "?"       -- shows after 
--------------------------------------------------------
function Main() 
	SetTimer(sec)
end 
--------------------------------------------------------
function OnTimer()
	if time > 0 then
frmHub:UnregBot(startchars..time..endchrs)
	time = time - 1
SendToAll("$HubName "..HubName.." ? - THE HUB WILL RESTART IN "..startchars..time..endchrs.." SECS ?")
frmHub:RegBot(startchars..time..endchrs)
	else
SendToAll("$HubName "..HubName.." ? - THE HUB WILL RESTART IN "..startchars..time..endchrs.." SECS ?")
frmHub:UnregBot(startchars..time..endchrs)
frmHub:Restart()
	end
end
--------------------------------------------------------
--------------------------------------------------------
function ChatArrival(user, data)
	data = string.sub(data,1,string.len(data)-1)
		s,e,cmd = string.find(data, "%b<>%s+(%S+)")
		if (string.lower(cmd) == "!restartimer") then
		timer(user, data)
		return 1
			
		end
end
ToArrival=ChatArrival

function timer(user,data)
Nick = user
local s,e,input = string.find(data, "%b<>%s+%S+%s+(.+)")

if input== nil or tonumber(input)==nil then
SendPmToNick(user.sName,sBot, "Syntax error, the correct syntax is: !restartimer ")
elseif user.iProfile==5 or user.iProfile==0 then
time=tonumber(input)
	StartTimer() 
	SendToAll(sBot,"? THE HUB WILL RESTART IN "..time.." SECS ?")
	SendToAll("$HubName "..HubName.." ? - THE HUB WILL RESTART IN "..startchars..time..endchrs.." SECS ?")
	frmHub:RegBot(startchars..time..endchrs)
else
user:SendData(sBot,"You Cant restart the hub")
return 1
	end
end
Ignorance is Bliss.

Snoris

First of all..Very nice script..
Second...

Is there any way to close the hub withthis script??
Like !shutdown so the hub will be shutdown totally??

Dessamator

Well, theres nothing in the api to allow that, so i guess theres no way .
Ignorance is Bliss.

Snoris

Damit  =p
Thx for the reply tough...

Dessamator

Ignorance is Bliss.

SMF spam blocked by CleanTalk