playMaker

Author Topic: set some specific dates to launch something...?  (Read 1584 times)

xunxun

  • Junior Playmaker
  • **
  • Posts: 53
set some specific dates to launch something...?
« on: October 21, 2013, 12:05:48 PM »
is there any efficient way to do so?

I have a long list of events in game that only can be self-unlocked after a specific dates. Something like...

after 01/12/2013 -> User can be able to do ****
after 05/12/2013 -> User can be able to do blah blah....
after dd/MM/yyyy -> unlock this...
... and so on....

Get date -> store string -> convert to Int -> compare Int ...seems to be a long long way Y__ _Y
« Last Edit: October 21, 2013, 12:15:51 PM by xunxun »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: set some specific dates to launch something...?
« Reply #1 on: October 21, 2013, 02:43:26 PM »
Hi,

 This is fine actually, as long as you do this only once for each dates, and only when the game starts or at a specific time during the game process.

The other solution is to not save dates as strings, but as ints, and then you only need to convert the current date as int and simply compare ints. that would be the way to do it to gain performances.

I looked at date string comparision, and they parse it first before comparing, or actually create a proper datetime object that requires entering year, month, day, time as separate ints, so that work would have to be done up front anyway. So I am not sure creating a custom action would make it more efficient, and actually would require the action to always parse the current date, where if you compare ints yourself, then you only need to parse the current date once.

bye,

Jean

Bye,

 Jean