PtokaX forum

Lua 5.3/5.2/5.1 Scripts (for PtokaX 0.4.0.0 and newer) => Finished Scripts => Topic started by: Cêñoßy†ê on 28 March, 2008, 14:44:17

Title: Current time as Bot [API2]
Post by: Cêñoßy†ê on 28 March, 2008, 14:44:17

--[[
Small script to show hubs current time as user API2 by  C??o?y?? 28.03.2008
v1
-- Updates every 1 min
-- Chars $|<>:?*"/\ and space not allowed in nick, $| not allowed in Description and Email, max length 64 chars per string.
v2 -- Added seperate date & time requested by ResidentEvil
-- Few what you might want to use ;)
%a abbreviated weekday name (e.g., Wed)
%A full weekday name (e.g., Wednesday)
%b abbreviated month name (e.g., Sep)
%B full month name (e.g., September)
%d day of the month (16) [01-31]
%H hour, using a 24-hour clock (23) [00-23]
%I hour, using a 12-hour clock (11) [01-12]
%M minute (48) [00-59]
%m month (09) [01-12]
%p either "am" or "pm" (pm)
%S second (10) [00-61]
%w weekday (3) [0-6 = Sunday-Saturday]
%Y full year (1998)
%y two-digit year (98) [00-99]
%% the character `%?
]]--

gmt = "GMT+02.00"
description = "?Hub Time?"
description2 = "?Hub Date?"
mail = "bot@hub.com"

function OnStartup()
TmrMan.AddTimer(1*60000)
end

function OnTimer()
if tmp then Core.UnregBot(tmp) end
Core.RegBot(os.date("?[%H.%M]["..gmt.."]?"),description,mail,true)
tmp = os.date("?[%H.%M]["..gmt.."]?")
if tmp2 then Core.UnregBot(tmp2) end
Core.RegBot(os.date("?[%d.%m.%Y]?"),description2,mail,true)
tmp2 = os.date("?[%d.%m.%Y]?")
end
Title: Re: Current time as Bot [API2]
Post by: ResidentEvil on 28 March, 2008, 16:07:08
I want to separate this script in two scripts : time and date bot's.
Is is it possible ?

C??o?y??  ==>> +1 karma :)
Title: Re: Current time as Bot [API2]
Post by: Cêñoßy†ê on 28 March, 2008, 16:26:13
Quote from: ResidentEvil on 28 March, 2008, 16:07:08
I want to separate this script in two scripts : time and date bot's.
Is is it possible ?

C??o?y??  ==>> +1 karma :)

File updated with your request ;)
Title: Re: Current time as Bot [API2]
Post by: ResidentEvil on 28 March, 2008, 16:36:25
   Core.RegBot(os.date("?[%H.%M]["..gmt.."]?"),description,mail,true)
   tmp = os.date("?[%H.%M]["..gmt.."]?[%d.%m.%Y]?")

Delete bolded or bot will start a new time bot every minute  :D
Title: Re: Current time as Bot [API2]
Post by: Cêñoßy†ê on 28 March, 2008, 16:45:04
 :o Sorry was my mistake (happens when you do something little to fast) thx for reporting it  ::)
Bug fixed in first post
Title: Re: Current time as Bot [API2]
Post by: ResidentEvil on 30 March, 2008, 03:47:30
And a little advice. Change TmrMan.AddTimer(1*60000) to time period to 1000 ~ 5000ms, cause when bot starts for example at 9min 59 seconds, time in few seconds is 10 min, but bot still show's 9 min (bot drop's behind in 59 seconds)