Daily Rewards

Discussion in 'Buildbox 3.0' started by panceh, May 2, 2020.

  1. panceh

    panceh Boxer

    Joined:
    Nov 4, 2016
    Messages:
    7
    Likes Received:
    0
    Is there a way to implement a daily reward system in Buildbox right now?


    is there a way to do this by clicking on the button every 24 hours or starting the game by watching the award-winning video?
     

    Attached Files:

  2. panceh

    panceh Boxer

    Joined:
    Nov 4, 2016
    Messages:
    7
    Likes Received:
    0
  3. sws

    sws Boxer

    Joined:
    Apr 20, 2020
    Messages:
    26
    Likes Received:
    6
    I think this is what I would do: go to your game's start UI, go to the Asset Library, add the yellow button object (you can change the image later). Double click on it, add the custom script node, and double click on the node. In the script, change your init() function to look like this:

    function init(){
    if(Settings['startTime'] == undefined)
    Settings['startTime'] = new Date();

    var currentTime = new Date();
    var elapsedTime = (currentTime - Settings['startTime']) / 1000;
    log(elapsedTime);

    if(elapsedTime > 72000){
    // Here you can display the button, for example, maybe the button is off-screen,
    // now change its X position to be on-screen.
    }

    I personally chose the button to unlock the reward after 20 hours (72000 seconds), but you can change it to whatever you want. Every time you go the menu, you can check the log and see how many seconds have passed.
    Whenever the user clicks the button to collect the rewards, add this: Settings['startTime'] = new Date();
     
    Robdd likes this.
  4. sws

    sws Boxer

    Joined:
    Apr 20, 2020
    Messages:
    26
    Likes Received:
    6
    I also want to add, when the user clicks the button, delete it or move it back off-screen after this: Settings['startTime'] = new Date();
     
  5. panceh

    panceh Boxer

    Joined:
    Nov 4, 2016
    Messages:
    7
    Likes Received:
    0
    çok teşekkür ederim ama başaramadım
     

    Attached Files:

    • 22.PNG
      22.PNG
      File size:
      56.5 KB
      Views:
      28
    • 33.PNG
      33.PNG
      File size:
      16.2 KB
      Views:
      27
  6. sws

    sws Boxer

    Joined:
    Apr 20, 2020
    Messages:
    26
    Likes Received:
    6
    You should remove Settings['startTime'] = new Date() from the start() function. When the button it touched, it should trigger a new custom script with Settings['startTime'] = new Date() in the signal() function:

    function signal(){
    Settings['startTime'] = new Date();
    }
     
  7. sws

    sws Boxer

    Joined:
    Apr 20, 2020
    Messages:
    26
    Likes Received:
    6
    Here is an example:

    bonus1.png
     
  8. panceh

    panceh Boxer

    Joined:
    Nov 4, 2016
    Messages:
    7
    Likes Received:
    0
    thank you so much.Working
     
  9. Robdd

    Robdd Boxer

    Joined:
    May 17, 2020
    Messages:
    12
    Likes Received:
    1
    This might be a bit late (and a bit dumb), but how do you make the yellow object a button which you can press on
     
  10. Robdd

    Robdd Boxer

    Joined:
    May 17, 2020
    Messages:
    12
    Likes Received:
    1
    nvm I got it to work
     
  11. Robdd

    Robdd Boxer

    Joined:
    May 17, 2020
    Messages:
    12
    Likes Received:
    1
    I've run into another problem. I want the button to open another UI screen, how do I do that?
     
  12. SpawnP

    SpawnP Boxer

    Joined:
    May 24, 2020
    Messages:
    10
    Likes Received:
    2
    @sws While I am trying to run this script to award daily reward I am getting error as elapsedTime is not defined in log while running the script ?
     
  13. Karamer

    Karamer Boxer

    Joined:
    Feb 10, 2020
    Messages:
    8
    Likes Received:
    1
    can you share bbdoc file ?
     
  14. axem

    axem Boxer

    Joined:
    Feb 28, 2019
    Messages:
    7
    Likes Received:
    0
    Please share bbdoc file :)
     

Share This Page