Jump to content

How can i create last login script?


Turbe$Z

Recommended Posts

Posted
addEventHandler("onPlayerLogin", getRootElement(), function(_, theAccount)
	local lastLogin = getAccountData(theAccount, "acc:lastLogin") or 0
	local lastTime = getRealTime(lastLogin)
	local timeText = lastTime.year + 1900 .. ". " .. string.format("%02d", lastTime.month+1) .. ". " .. string.format("%02d", lastTime.monthday) .. " " .. string.format("%02d", lastTime.hour) .. ":" .. string.format("%02d", lastTime.minute) .. ":" .. string.format("%02d", lastTime.second)
	outputChatBox("Last login date: " .. timeText, source, 255, 255, 255, true)
	local timeAtm = getRealTime().timestamp
	setAccountData(theAccount, "acc:lastLogin", timeAtm)
end)

I had this done already. :D If you need explanations, feel free to ask.

Posted
13 hours ago, NeXuS™ said:

addEventHandler("onPlayerLogin", getRootElement(), function(_, theAccount)
	local lastLogin = getAccountData(theAccount, "acc:lastLogin") or 0
	local lastTime = getRealTime(lastLogin)
	local timeText = lastTime.year + 1900 .. ". " .. string.format("%02d", lastTime.month+1) .. ". " .. string.format("%02d", lastTime.monthday) .. " " .. string.format("%02d", lastTime.hour) .. ":" .. string.format("%02d", lastTime.minute) .. ":" .. string.format("%02d", lastTime.second)
	outputChatBox("Last login date: " .. timeText, source, 255, 255, 255, true)
	local timeAtm = getRealTime().timestamp
	setAccountData(theAccount, "acc:lastLogin", timeAtm)
end)

I had this done already. :D If you need explanations, feel free to ask.

doesn't working this :/ 

"Last login date: 1970. 01. 01 01:00:00"
how to fix?

Posted (edited)
9 minutes ago, Turbo777 said:

doesn't working this :/ 

"Last login date: 1970. 01. 01 01:00:00"
how to fix?

try this, but you will have to clear previous account data that saved lastlogin otherwise it will still show same thing.

addEventHandler("onPlayerLogin", getRootElement(), function(_, theAccount)
    local timeAtm = getRealTime().timestamp
	local lastLogin = getAccountData(theAccount, "acc:lastLogin") or timeAtm
	local lastTime = getRealTime(lastLogin)
	local timeText = lastTime.year + 1900 .. ". " .. string.format("%02d", lastTime.month+1) .. ". " .. string.format("%02d", lastTime.monthday) .. " " .. string.format("%02d", lastTime.hour) .. ":" .. string.format("%02d", lastTime.minute) .. ":" .. string.format("%02d", lastTime.second)
	outputChatBox("Last login date: " .. timeText, source, 255, 255, 255, true)
	setAccountData(theAccount, "acc:lastLogin", timeAtm)
end)

 

Edited by Fist
  • Like 1
Posted
15 minutes ago, Fist said:

try this, but you will have to clear previous account data that saved lastlogin otherwise it will still show same thing.


addEventHandler("onPlayerLogin", getRootElement(), function(_, theAccount)
    local timeAtm = getRealTime().timestamp
	local lastLogin = getAccountData(theAccount, "acc:lastLogin") or timeAtm
	local lastTime = getRealTime(lastLogin)
	local timeText = lastTime.year + 1900 .. ". " .. string.format("%02d", lastTime.month+1) .. ". " .. string.format("%02d", lastTime.monthday) .. " " .. string.format("%02d", lastTime.hour) .. ":" .. string.format("%02d", lastTime.minute) .. ":" .. string.format("%02d", lastTime.second)
	outputChatBox("Last login date: " .. timeText, source, 255, 255, 255, true)
	setAccountData(theAccount, "acc:lastLogin", timeAtm)
end)

 

Thank you:D

Posted

@Turbo777, you just had to relogin once, and it would have outputted your last login, thats how it works. If you haven't logged in once before this script started running, it could output "First login" (or in my case, it outputs 1970.)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...