Solved 2 people get chosen when I only want 1

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

ultimateunion

Member
Sep 5, 2021
1
0
1
25
I am trying to make a lottery script however 2 people (I'm testing with 2 people) get chosen. can anyone help me? (The low timers are so I don't have to wait ages for it to be tested)
Code:
options:
    prefix: &a[&2Lottery&a]
    lotteryLength: 1 minute # Determines the amount of time between each lottery draw
    price: 100000 # The amount of money that it costs to enter
    remindTimer1: 30 seconds # The amount of time that a reminder gets broadcast (ideally should be half of lotteryLength)
    remindTimer2: 50 seconds # ideally should be 1/6th of the time (for an hour 50 minutes)

on join:
    set {lotteryJoined.%player%} to false

on quit:
    if {lotteryJoined.%player%} is true:
        add {@price} to player's balance
        set {lotteryJoined.%player%} to false
        remove 100000 from {lotteryPot}
    else:
        stop

command /lottery [<text>]:
    trigger:
        if arg-1 is not set:
            send "{@prefix}"
            send ""
            send "&7/lottery help: shows this page"
            send "&7/lottery join: Allows you to join the lottery!"
        else if arg-1 is "help":
            send "{@prefix}"
            send ""
            send "&7/lottery help: shows this page"
            send "&7/lottery join: Allows you to join the lottery!"
        else if arg-1 is "join":
            if player's balance >= {@price}:
                if {lotteryJoined.%player%} is false:
                    set {lotteryJoined.%player%} to true
                    add {@price} to {lotteryPot}
                    remove {@price} from player's balance
                    send "{@prefix} &7Successfully joined the lottery!"
                else:
                    send "{@prefix} &7You have already joined!"
            else:
                send "{@prefix} &7You do not have enough money to join!"
        else:
            send "{@prefix} &7Insufficent command!"

every {@remindTimer1}:
    if {lotteryPot} is not set:
        set {lotteryPot} to 0
    send "" to all players
    send "{@prefix} &7Remember to join the lottery! The current pot is &a$%{lotteryPot}%" to all players
    send "" to all players

every {@remindTimer2}:
    if {lotteryPot} is not set:
        set {lotteryPot} to 0
    send "" to all players
    send "{@prefix} &7Remember to join the lottery! The current pot is &a$%{lotteryPot}%" to all players
    send "" to all players

every {@lotteryLength}:
    if {lotteryPot} == 0:
        send "" to all players
        send "{@prefix} &7The lottery has ended and no one joined!" to all players
        send "" to all players
        set {lotteryPot} to 0
        loop all players:
            set {lotteryJoined.%loop-player%} to false
    else:
        loop all players:
            if {lotteryJoined.%loop-player%} is true:
                add loop-player to {lotteryEntrees::*}
                set {_winner} to a random element out of {lotteryEntrees::*}
                set {winner::%{_winner}%} to {_winner}
                send "%{winner::%{_winner}%}%" to all players # Debugging to see the winners
                add {lotteryPot} to {winner::%{_winner}%}'s balance
                set {lotteryJoined.%loop-player%} to false
        send "" to all players
        send "{@prefix} &a%{_winner}% &7Has won the lottery, with a prize pot of &a$%{lotteryPot}%" to all players
        send "" to all players
        set {lotteryPot} to 0
        delete {_winner}
        clear {lotteryEntrees::*}
[doublepost=1630842603,1630835386][/doublepost]I found a plugin that can do this for me in a gui with custom options
 
Status
Not open for further replies.