PtokaX forum

Archive => Archived 5.0 boards => Finished Scripts => Topic started by: Dessamator on 22 March, 2005, 12:34:29

Title: Restartimer
Post by: Dessamator on 22 March, 2005, 12:34:29

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

Title:
Post by: aL1en on 25 March, 2005, 13:38:57
can you make a timer bot for execute the command '!restartscripts' ?

just to restart scripts if no masters are there to do it ;)
Title:
Post by: Dessamator on 25 March, 2005, 14:04:42
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 !
Title:
Post by: Dessamator on 25 March, 2005, 15:17:58
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!
Title:
Post by: Dessamator on 24 April, 2005, 14:35:14
--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,  ;)
Title:
Post by: Dessamator on 24 April, 2005, 17:21:40
-- 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
Title: New idea
Post by: Snoris on 11 August, 2005, 01:27:49
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??
Title:
Post by: Dessamator on 11 August, 2005, 12:45:00
Well, theres nothing in the api to allow that, so i guess theres no way .
Title: Thats baaaad =(
Post by: Snoris on 11 August, 2005, 20:42:28
Damit  =p
Thx for the reply tough...
Title:
Post by: Dessamator on 12 August, 2005, 10:52:34
ur welcome