A few questions for the experts.

0 favourites
  • 10 posts
From the Asset Store
Human base in various poses created by an expert pixel artist
  • Hi guys, I have a few questions which I would like to ask today and hopefully someone can point me in the right direction to learn.

    1) I've made a countdown timer by using zeropad, and a subtract 1 every 1 second logic, but this timer stops if the game is not active on the background, had anyone ever done allows the game to play in the background even when it is not active (minimized browser, etc), so even when the browser is minimized, the countdown timer still continues.

    2) So for the second question, now assuming that I am integrating a SMS blaster which generates a 4 digit pin, and this 4 digit pin only allows the player to play once every 24hour per mobile phone, is it possible to design it so the box currently looks like the image below? I currently just have a normal looking textbox which lets players enter their pin. Which looks like:

    3) Last question, now I know this is probably out of Construct 3's forums but had anyone ever worked with a SMS blaster provider? I understand how their API works and had tested it sending the message through their API. But how can I set it so each mobile phone can only receive a SMS code every 24hour? (I believe this is done through MySQL and timestamp) if anyone had done anything similar do guide me in the right direction!

    Thanks everyone!

  • 1. You need to use world clock instead of the "Every 1 second". Take a look at the Date plugin.

    2. I made a demo:

    dropbox.com/s/exiesrn5khmxbfr/CodeEnter.c3p

    4. If the SMS Blaster doesn't provide this feature, then yes, you need to store the mobile number and the time it was last used on your own server.

  • 1. You need to use world clock instead of the "Every 1 second". Take a look at the Date plugin.

    2. I made a demo:

    https://www.dropbox.com/s/exiesrn5khmxbfr/CodeEnter.c3p?dl=0

    4. If the SMS Blaster doesn't provide this feature, then yes, you need to store the mobile number and the time it was last used on your own server.

    Hi dop! Thanks for having you here guiding me again, thanks for the .capx on the second question, it works splendidly. But on the first question, I had a look at the date plugin's documentation which is here: construct.net/en/make-games/manuals/construct-3/plugin-reference/date

    And had played around with it, but I'm not so sure on how am I able to use this to create a countdown timer. Or am I looking at the wrong plugin when you mentioned "World clock"? As even when I'm using the date plugin, I'm just converting miliseconds to minutes, but how do I get these minutes to subtract itself? At the end of the day I found out I'm still using the Every X second logic, which still makes my clock freeze.

  • See this demo:

    dropbox.com/s/6zrsqmc62ps8nq7/RealClockCountdown.c3p

    Even when the game is suspended, when you resume it, the timer will "catch up".

  • See this demo:

    https://www.dropbox.com/s/6zrsqmc62ps8nq7/RealClockCountdown.c3p?dl=0

    Even when the game is suspended, when you resume it, the timer will "catch up".

    Thanks for show me that, but I'm wondering, using the logic you had written, how is it possible to write action for it? Since by using the global variable subtract 1 action, the global variable constantly changes, and when it reaches == 0 , we can end the game. But currently, the timer counts down from 20, using milliseconds until it reaches 0. How would I go around making it if it reaches 0 the game ends? Also: Is it possible to format the countdown into a minute and seconds timer? IE: 10:00 -> 09:59.... etc, instead of using numbers such as: 600 -> 599.... Thanks!

  • ((Date.Now-start)/1000) is the number of seconds passed since the start of countdown. You can do whatever you need with this number. For example compare if it's >=20, this means that 20 seconds has passed.

    See this demo on how to format the time:

    howtoconstructdemos.com/simple-stopwatch

  • ((Date.Now-start)/1000) is the number of seconds passed since the start of countdown. You can do whatever you need with this number. For example compare if it's >=20, this means that 20 seconds has passed.

    See this demo on how to format the time:

    https://howtoconstructdemos.com/simple-stopwatch/

    zeropad(floor(minutes - round((Date.Now-start)) / 60000 % 60),2) & ":" & zeropad(floor(seconds - round((Date.Now-start))/1000 % 60),2)

    Thanks Dop! So after awhile of testing, I've decided to use the logic above, it uses 2 variable though one minutes, and another one for seconds, but it gets the job done, except that I do know it's extremely flawed. But atleast it's real-time. I am attempting to write a logic to make it so when both the seconds and minutes var = 0, it will stop the game next.

    PS: Anyway I just thought of another issue that hopefully you may be able to answer me :c..

    So these are the scenario:

    1) My database has 10 rewards , lets call this Reward X. So these 10 rewards are loaded into my global variable through AJAX.

    2) A player plays my game, and win a reward X, so i will subtract 1 from reward X, and update my database. Now my database has 9 rewards left.

    3) My timer of 15minutes starts counting down, and within these 15minutes, if you do not provide me your address, the reward goes back into the pool (I'll be doing add 1, and update it through AJAX).

    4) When the 15minutes timer starts counting down and you close your browser (Forcing the game to close as well), I want the reward to go back into my database as well.

    ^ So based on the above scenario, is it possible to do #4? Or should I rewrite my logic to make it so, I do not deduct the rewards first, but instead to detect it on the 3rd step, where if the player actually inserts their address in step 3, then only I will deduct the reward.

  • I don't know. Maybe you can "reserve" the reward on the server, without deleting it. Save the time it was reserved. When checking for available rewards, pick records with reservedTime is null or (now-reservedTime)>15 minutes

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I don't know. Maybe you can "reserve" the reward on the server, without deleting it. Save the time it was reserved. When checking for available rewards, pick records with reservedTime is null or (now-reservedTime)>15 minutes

    Thanks, based on the reserved logic I'll look more into it. I was wondering for the 4 keys input solution you provided, since it detects based on Keyboard input, is it fair to assume that it doesn't work on mobile? How would I go around making it work on both mobile and desktop? I understand that the box is a sprite, and it is just overlaying the sprite with text, and if the text == the pin in database, it shall allow access. But the keyboard doesn't popup when I'm using mobile.

  • If you only need to enter numbers, it may be easier to make a "virtual keyboard". Just 10 sprites with digits from 0-9, similar to how it's done in this tutorial:

    construct.net/en/tutorials/mobile-keyboard-and-hall-of-fame-for-all-mobile-devices-738

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