• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Help with date function!

Nottinghster

Tibia World RPG Developer
Joined
Oct 24, 2007
Messages
1,618
Solutions
6
Reaction score
537
Location
Brazil - Rio de Janeiro
GitHub
Nottinghster
Hello OTland!

I need a help, look this:

15:18 You have 59 days left of VIP account.
15:18 Your VIP ends in 31/12/1969 at 22:00:58.


The time and date is wrong, I want to fix it, but don't know how...

Now the code:

Code:
if isPlayerVip(cid) == TRUE then
dataFormat = os.date("%d/%m/%Y", getPlayerVipDays(cid))
horaFormat = os.date("%X", getPlayerVipDays(cid))
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have ".. getPlayerVipDays(cid)+1 .." days left of VIP account.")
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Your VIP ends in ".. dataFormat .." at ".. horaFormat ..".")
else
end

Thanks!
 
In the date format you can use
LUA:
os.time() + getPlayerVipDays() * 24* 60* 60
As for the time format this wont be accurate unless when player get their vip you save thier time in storage or something then you recall it.
 
this should be a really accurate formula
LUA:
	local vipStorage = getPlayerStorage(cid,vip_storage)
	local left = os.date("%d days, %H hours,%M minutes and %S seconds.", ((vipStorage-os.time())-(day))- 2*60*60)
	local time_it_end = os.date("%X",vipStorage)
	local ends_date = os.date("%d/%m/%Y",vipStorage-day)
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Vip will end after ".. left)
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Vip will end in ".. ends_date.. " at "..time_it_end)
 
Back
Top