clock expire

0 favourites
  • 3 posts
From the Asset Store
Clock Challenge
$2 USD
60% off
The clock has started ticking, but are you fast enough?
  • how do I make it so an item expires after 1 hour whether or not the app is open--or if its been 1 hour it expires when the open it back up

  • Make an plugin, choose a given one or use on that let you execute JS-Code. There are many.

    If you make your own plugin or use a JS-Code-Plugin:

    new Date().getTime(); Will return the actual milliseconds since year 0 save this for your item.

    As soon as the player starts the game again you just check with new Date().getTime(); if the new value is an hour bigger than the old ;)

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You'd need some way of syncing real-world time with a source outside of the game. There are 2 plugins that get the system date an time on the user's computer:

    Clock

    System Date and Time

    If you're concerned that the user would cheat by messing with their system clock, you can sync with an external source to get the correct time, but this is a bit more complex. If you have your own server, you can get the time by setting up a simple PHP script. Then, within the game, ajax request the php page.

    Once you have a method of getting the current time, all you'd need to do is record the time the item is acquired, and destroy the item if more than an hour or more has passed.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)