Лог текста с временем его добавления

турбодизельный унитаз2012

Участник
Автор темы
129
9
Версия MoonLoader
.026-beta
Здарова.
Нашёл я кодик один, который логирует нужный мне текст, но есть одно но.. Мне нужно узнать время этой логировки, пример:
(как нужно) [12:00:50] Администратор nick_name выдал Вам дилдо.
(как на данный момент) Администратор nick_name выдал Вам дилдо.

logs code:
local event = require 'lib.samp.events'

function event.onServerMessage(col, text)
    if text:find("Администратор nick_name выдал Вам дилдо.") then
        file = io.open(getWorkingDirectory().."\\Logs.txt", "a")
        file:write(text.."\n")
        file:close()
    end
end
 
Решение
Lua:
local event = require 'lib.samp.events'

function event.onServerMessage(col, text)
    file = io.open(getWorkingDirectory().."\\Logs.txt", "a")
    local cur_date = os.date('*t')
    local hour, minute, second = string.format('%02d', cur_date.hour), string.format('%02d', cur_date.min), string.format('%02d', cur_date.sec)

    file:write(('[%s:%s:%s] %s \n'):format(hour, minute, second, text))
    file:close()
end

mooh

Известный
162
45
Lua:
local event = require 'lib.samp.events'

function event.onServerMessage(col, text)
    file = io.open(getWorkingDirectory().."\\Logs.txt", "a")
    local cur_date = os.date('*t')
    local hour, minute, second = string.format('%02d', cur_date.hour), string.format('%02d', cur_date.min), string.format('%02d', cur_date.sec)

    file:write(('[%s:%s:%s] %s \n'):format(hour, minute, second, text))
    file:close()
end