• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[Support] Lua os.date ?

Xavizus

Panchira Project Member
Joined
Jun 16, 2010
Messages
14
Reaction score
0
Location
Sweden
Greetings Otlander's Once again!

Once again I need your help to make my script!
This time I am having problem to create a time stamp.
Lua:
		file = io.open("data/logs/premium.txt", "a+")
		file:write("Account = "..getPlayerAccountId(cid).." has bought "..cfg.days.." premium days!\n")
		file:close()
but I am not sure where to add:
Lua:
(os.date(%x - %X)) --Types: current date - time
or
Lua:
(os.date(%c)) -- Types current date and time.
Shall I make an var. or can I at somehow just put it in the text?
 
you don't have to do that
TFS has a custom function for that @ 050-function.lua

Lua:
function doWriteLogFile(file, text)
    local f = io.open(file, "a+")
    if(not f) then
        return false
    end

    f:write("[" .. os.date("%d/%m/%Y %H:%M:%S") .. "] " .. text .. "\n")
    f:close()
    return true
end

it'd be:

Lua:
doWriteLogFile('data/logs/premium.txt', 'Account = '..getPlayerAccountId(cid)..' has bought '..cfg.days..' premium days!\n')
 
Back
Top