Date countdown

Get Help on scripting in POL with configurations, config setups, script trouble shooting, etc.

Moderator: POL Developer

Post Reply
User avatar
ghibli1983
New User
Posts: 26
Joined: Mon Apr 23, 2018 1:36 pm
Location: Italy
Contact:

Date countdown

Post by ghibli1983 » Sun Jul 08, 2018 6:02 am

Hello to everybody, ^^

I create a package , the name is Rent System,
the pkg function on singn (similar a housing system) when the Player click on the rent sing , open a gump when the pg pay a first rent start a system rent, in the sign props write a data when start the first payment, now i need to start countdown days for the next rent ...

now i not ideas, someone wants to help me? :cheesy:
props.PNG
SING PROPS WHEN START THE RENT

User avatar
ghibli1983
New User
Posts: 26
Joined: Mon Apr 23, 2018 1:36 pm
Location: Italy
Contact:

Re: Date countdown

Post by ghibli1983 » Mon Jul 09, 2018 9:59 am

Solved,

I used the POLCore().systime and and his family :cheesy:
thanks to all I read carefully the unix time topic,

TIP FOR OTHER NOVICE USER; https://www.epochconverter.com/ READ :-)

Yukiko
Distro Developer
Posts: 2505
Joined: Thu Feb 02, 2006 1:41 pm
Location: San Antonio, Texas
Contact:

Re: Date countdown

Post by Yukiko » Mon Jul 09, 2018 11:04 am

I am glad you solved it. I had a solution I was going to post but it involved using the game clock but I think your solution is probably better. :)
Sincerely,
Yukiko

I would tell you a UDP joke but you might not get it.

Titus 2:13

User avatar
ghibli1983
New User
Posts: 26
Joined: Mon Apr 23, 2018 1:36 pm
Location: Italy
Contact:

Re: Date countdown

Post by ghibli1983 » Mon Jul 09, 2018 11:31 am

please yukiko , post your solution, i want learn more and more and more for the pol :D :D , is possible use in the future for the other package or function

DevGIB
Grandmaster Poster
Posts: 204
Joined: Mon Feb 06, 2006 6:12 am

Re: Date countdown

Post by DevGIB » Tue Jul 10, 2018 5:21 pm

I'll see if i can dig up my static housing package which has a rental system built into it referred to as Upkeep.

guialtran
Grandmaster Poster
Posts: 108
Joined: Wed Jul 30, 2008 12:42 pm

Re: Date countdown

Post by guialtran » Tue Jul 10, 2018 8:45 pm

Sorry, I do not speak English.
I do not know if this will help you.

I did this job a long time ago.

you only have to add the total time and the formula that already has the correct calculations for leap year, and you can add the time zone.

if you add a return you can pick up this data structure, and you can do other functions to show the time the way you want.

this code was created to create a date that is in the future.


:deadhorse:

Code: Select all

program data(character)
	var year := {2678400,2419200,2678400,2592000,2678400,2592000,2678400,2678400,2592000,2678400,2592000,2678400};
	var leap_year := {2678400,2505600,2678400,2592000,2678400,2592000,2678400,2678400,2592000,2678400,2592000,2678400};
	var date := struct{"second":=0,"minute":=0,"hour":=0,"day":=1,"month":=1,"year":=1970};
	var time := polcore().systime;//add the time here in the future
	//time := (time - 3*60*60); //com Fuso horário do brasil - 3 horas
	var quociente := cint(time / 126230400);// 126230400 é igual a 3 anos normais + 1 bissexto, transformados em segundos
	time := ( time - ( quociente * 126230400 )) ;// time = quantos 4 anos cabem no total
	date.year := ( date.year + quociente*4 );
	while(time >= 31536000)
		if(date.year % 4 == 0)
			date.year := ( date.year + 1 );
			time := ( time - 31622400 );
		else
			date.year := ( date.year + 1 );
			time := ( time - 31536000 );
		endif
	endwhile
	if(date.year % 4 == 0)
		while(time >= leap_year[date.month] )
			time := ( time - leap_year[date.month] );
			date.month := ( date.month + 1 );
		endwhile
	else
		while(time >= year[date.month] )
			time := ( time - year[date.month] );
			date.month := ( date.month + 1 );
		endwhile
	endif

	quociente := cint( time / 86400 );
	time := ( time - ( quociente * 86400 )) ;
	date.day := (date.day + quociente );
	quociente := cint( time / 3600 );
	time := ( time - ( quociente * 3600 )) ;
	date.hour := (date.hour + quociente );
	quociente := cint( time / 60 );
	date.minute := (date.minute + quociente );
	date.second := ( time - ( quociente * 60 )) ;

	SendSysMessage( character," Clock  "+date.hour+":"+date.minute+":"+date.second, 3, 33 );
	SendSysMessage( character," Date "+date.month+"/"+date.day+"/"+date.year, 3, 33 );
endprogram

OR
use util::StrFormatTime( format_string, time_stamp:=0 ), time_stamp == future
http://www.cppreference.com/stddate/strftime.html

var future := 100000;
print(StrFormatTime( "%Y %m %d %H %M %S", (POLCore().systime + future) ));

output 2018 07 12 05 44 35
@CronosKing
Image ZuluHotel Forgotten Realms
www.zuluhotel.com.br

User avatar
ghibli1983
New User
Posts: 26
Joined: Mon Apr 23, 2018 1:36 pm
Location: Italy
Contact:

Re: Date countdown

Post by ghibli1983 » Wed Jul 11, 2018 12:40 am

nice to meet you here, I use your code in another PACKAGE in my Shard, thanks for developing the date function, I did not think to meet you here
:D :D :D :D :D :D :D :D

PS: Note the first props in my gump.... in my fisrt post 8)
guialtran wrote:
Tue Jul 10, 2018 8:45 pm
Sorry, I do not speak English.
I do not know if this will help you.

I did this job a long time ago.

you only have to add the total time and the formula that already has the correct calculations for leap year, and you can add the time zone.

if you add a return you can pick up this data structure, and you can do other functions to show the time the way you want.

this code was created to create a date that is in the future.


:deadhorse:

Code: Select all

program data(character)
	var year := {2678400,2419200,2678400,2592000,2678400,2592000,2678400,2678400,2592000,2678400,2592000,2678400};
	var leap_year := {2678400,2505600,2678400,2592000,2678400,2592000,2678400,2678400,2592000,2678400,2592000,2678400};
	var date := struct{"second":=0,"minute":=0,"hour":=0,"day":=1,"month":=1,"year":=1970};
	var time := polcore().systime;//add the time here in the future
	//time := (time - 3*60*60); //com Fuso horário do brasil - 3 horas
	var quociente := cint(time / 126230400);// 126230400 é igual a 3 anos normais + 1 bissexto, transformados em segundos
	time := ( time - ( quociente * 126230400 )) ;// time = quantos 4 anos cabem no total
	date.year := ( date.year + quociente*4 );
	while(time >= 31536000)
		if(date.year % 4 == 0)
			date.year := ( date.year + 1 );
			time := ( time - 31622400 );
		else
			date.year := ( date.year + 1 );
			time := ( time - 31536000 );
		endif
	endwhile
	if(date.year % 4 == 0)
		while(time >= leap_year[date.month] )
			time := ( time - leap_year[date.month] );
			date.month := ( date.month + 1 );
		endwhile
	else
		while(time >= year[date.month] )
			time := ( time - year[date.month] );
			date.month := ( date.month + 1 );
		endwhile
	endif

	quociente := cint( time / 86400 );
	time := ( time - ( quociente * 86400 )) ;
	date.day := (date.day + quociente );
	quociente := cint( time / 3600 );
	time := ( time - ( quociente * 3600 )) ;
	date.hour := (date.hour + quociente );
	quociente := cint( time / 60 );
	date.minute := (date.minute + quociente );
	date.second := ( time - ( quociente * 60 )) ;

	SendSysMessage( character," Clock  "+date.hour+":"+date.minute+":"+date.second, 3, 33 );
	SendSysMessage( character," Date "+date.month+"/"+date.day+"/"+date.year, 3, 33 );
endprogram

OR
use util::StrFormatTime( format_string, time_stamp:=0 ), time_stamp == future
http://www.cppreference.com/stddate/strftime.html

var future := 100000;
print(StrFormatTime( "%Y %m %d %H %M %S", (POLCore().systime + future) ));

output 2018 07 12 05 44 35
Last edited by ghibli1983 on Wed Jul 11, 2018 1:24 am, edited 1 time in total.

User avatar
ghibli1983
New User
Posts: 26
Joined: Mon Apr 23, 2018 1:36 pm
Location: Italy
Contact:

Re: Date countdown

Post by ghibli1983 » Wed Jul 11, 2018 12:48 am

The rent system is complete i use a unixtime in polcore, but i like learn other methods , I like to learn from other developers !

Next step is notify the rent countdown when the player logged on , i think check the props in logon code (script/misc/logon)

Thank's for your contribute! ;) ;)
DevGIB wrote:
Tue Jul 10, 2018 5:21 pm
I'll see if i can dig up my static housing package which has a rental system built into it referred to as Upkeep.

Post Reply