@name Lotto
@outputs A:array D Done In Out
In = 5
Out = 100

if (first()) {
    foreach (K,E:entity = players()) {
        moneyRequest(E,1,"Lottery! Win $"+Out+"!")
    }
}

if (moneyClk() && !Done) {A:insertEntity(A:count()+1,moneyClkPlayer())}

timer("5",5000)

if (clk("5")) {
    Done = 1
    stoptimer("5")
    D = randint(1,A:count()),moneyGive(A:removeEntity(D),Out)
}

if (moneyClk() && Done) {moneyGive(moneyClkPlayer(),In)}
