How do you have a live counter

Discussion in 'Spigot Plugin Development' started by dogboy60, Jun 27, 2016.

  1. So I want to know how to make a live counter, of a counter that is updated automatically. Here let me get a bit more specific, in many gambling sites and others, players or bettors put in bets into a jackpot. How can I make a jackpot that updates as the players or bettors bet? What should I use or do, like if I put in a yml file I couldn't have the jackpot update or it would not update instantly. this would be the big jackpot that all players or bettors would put money into. How would i code the portion where it would show the jackpot and update it
    If you know any tutorials please link them. :)
  2. Common sense says you just call the method that updates the live counter whenever something happens that would affect the number being updated.
    I.e. in the bet command when the bet has been successful, run the "updateCounter()" method

    Am I misunderstanding your issue? o_O
    • Agree Agree x 1
  3. a bit, see if i have a "updateCounter()" where would the values be stored, see when we have a player bet, the bet is added to thejackpot. but where or how would it be stored so all players can see it update instantly.
    player 1: bets $10
    Jackpot is: $10
    player 2: bets $10
    Jackpot is: $20
    player 3: bets $20
    Jackpot is: $40
    player 4: bets $40
    Jackpot is: $80
    See as the players bet, the jackpot then is updated, and the players can see what the new jackpot is.
  4. You can create HashMap with String (Jackpot name) and Integer (Jackpot amount) and when someone new bets you just update HashMap with old amount + new amount.
  5. Ok?
    Code (Text):
    int jackpot = 0;

        jackpot += <their bet>;

        save jackpot to config

        if config contains jackpot, set jackpot to the config value
    #5 Trophonix, Jun 27, 2016
    Last edited: Jun 27, 2016
    • Agree Agree x 2