Author Topic: Why the time is not changin  (Read 2820 times)

0 Members and 1 Guest are viewing this topic.

Offline satya

  • Fulll Member
  • ****
  • Posts: 64
  • Karma: +3/-5
Why the time is not changin
« on: 03 July, 2008, 11:15:26 »
Hey guys take a look at the following code

Code: [Select]
--bot name
local bot="User Alert"
local desc="I give ops alert about user login"

OnStartup = function()
Core.RegBot(bot,desc,"user@domain.com",true)
end

UserConnected = function(user)
local time=os.date("%B %d %Y %I:%m %p")
local msg="\r\n\r\n\t\t\t\t\t\t\tUSER ALERT\r\n"
msg=msg.."\t\t\t\t\t\tUser "..user.sNick.." logged in the hub at "..time.."\r\n"
msg=msg.."\t\t\t\t\t\twith the IP "..user.sIP.."\r\n"
Core.SendToOpChat("<"..bot.."> "..msg.."|")
end


Its a simple script wich i wanted and i tried on it myself. its a simple script where the scripts sends a message to the ops.

now the problem here is in the message the Date wich i retrieve with the function
Code: [Select]
local time=os.date("%B %d %Y %I:%m %p")this time remains static
it never changess
And also it runs only for one user the first to login the hub..
can ne1 tell me the reason n also how to correct it!.

thanks in advance
« Last Edit: 03 July, 2008, 12:03:08 by satya »

Eyes says everything,
Its on you how u read em...

PtokaX forum

Why the time is not changin
« on: 03 July, 2008, 11:15:26 »

Offline CrazyGuy

  • Viking
  • ****
  • Posts: 506
  • Karma: +83/-20
    • ?????=-_The NightHawk_-=?????
Re: Why the time is not changin
« Reply #1 on: 03 July, 2008, 12:42:33 »
Can you give an example of the formatted time as the user sees it ? I'm not familiar with all the parameters.
Mind you that you use only UserConnected, therefor this script is only triggered when unregistered users enter, this seems to be your purpose, just making sure.

What you could try is the table returned by os.date("*t")
For that I'd suggest the following changes:

Change
Code: [Select]
local time=os.date("%B %d %Y %I:%m %p")

to
Code: [Select]
local tTime = os.date("*t")

and change
Code: [Select]
msg=msg.."\t\t\t\t\t\tUser "..user.sNick.." logged in the hub at "..time.."\r\n"

to
Code: [Select]
msg=msg.."\t\t\t\t\t\tUser "..user.sNick.." logged in the hub at "..Ttime.hour..":"..tTime.min..":"..tTime.sec.."\r\n"

The default format for os.date() without parameters is date + time


Offline satya

  • Fulll Member
  • ****
  • Posts: 64
  • Karma: +3/-5
Re: Why the time is not changin
« Reply #2 on: 03 July, 2008, 13:16:26 »
Here is the message wich the ops used to get with the earlier script

Code: [Select]
                                                               USER ALERT
User asshole logged in the hub at July 03 2008 04:07 PM
with the IP **.**.***.***

and after doin the changes as u said the script aint displayin any message at alll


so wat change do i need to do to make this work for all users (registered n unregistered)
« Last Edit: 03 July, 2008, 13:23:55 by satya »

Eyes says everything,
Its on you how u read em...

Offline Madman

  • Scripter
  • Emperor
  • ******
  • Posts: 1 316
  • Karma: +75/-1
Re: Why the time is not changin
« Reply #3 on: 03 July, 2008, 15:49:22 »
Typo by CG

it says Ttime.hour insted of tTime.hour
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

Offline satya

  • Fulll Member
  • ****
  • Posts: 64
  • Karma: +3/-5
Re: Why the time is not changin
« Reply #4 on: 04 July, 2008, 09:44:39 »
thanks guys

workin like a charm........


i will b back with more queries as i know started to know the lua scripting basics!  :P

Eyes says everything,
Its on you how u read em...

Offline CrazyGuy

  • Viking
  • ****
  • Posts: 506
  • Karma: +83/-20
    • ?????=-_The NightHawk_-=?????
Re: Why the time is not changin
« Reply #5 on: 04 July, 2008, 14:41:08 »
Typo by CG

it says Ttime.hour insted of tTime.hour

thnx :)

As an addition for satya, the tTime table holds more values if you would want them.

Quote from: http://www.lua.org/manual/5.1/manual.html
if format is the string "*t", then date returns a table with the following fields: year (four digits), month (1--12), day (1--31), hour (0--23), min (0--59), sec (0--61), wday (weekday, Sunday is 1), yday (day of the year), and isdst (daylight saving flag, a boolean).


PtokaX forum

Re: Why the time is not changin
« Reply #5 on: 04 July, 2008, 14:41:08 »