addEventHandler("onPlayerLogin", root,
function(_, account)
setAccountData(account, "lastconnection", getRealTime().timestamp)
end
)
addCommandHandler("login",
function(player, _, accountName)
if accountName then
local account = getAccount(accountName)
if account then
local lastconnection = getAccountData(account, "lastconnection")
if lastconnection then
outputChatBox("Last Connection "..formatDate(lastconnection), player)
end
end
end
end
)
function formatDate ( timestamp )
if ( tonumber ( timestamp ) ) then
local time = getRealTime ( timestamp )
return string.format ( "%02d.%02d.%02d", time.monthday, time.month + 1, time.year + 1900, time.hour, time.minute )
end
end
you can guide yourself from this example