Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getLotteryPlayers()
- local players = {}
- for _, zid in pairs(getPlayersOnline()) do
- if getCreatureStorage(zid, 1300) == 1 and getPlayerAccess(zid) < 4 then
- table.insert(players, zid)
- end
- end
- return players
- end
- local players = getLotteryPlayers()
- local rewarditems = {
- {id = 9776, count = 1},
- {id = 2498, count = 1},
- {id = 2492, count = 1},
- {id = 2488, count = 1}
- }
- function onSay(cid, words, param, channel)
- local t = string.explode(param, ",")
- if (t[1] == 'open') then
- setGlobalStorageValue(1300, 1)
- doBroadcastMessage("".. getCreatureName(cid) .." is testing donation lottery.", MESSAGE_EVENT_ADVANCE)
- --doBroadcastMessage("".. getCreatureName(cid) .." has opened donation lottery to participate say /lotteryjoin for 100gn.", MESSAGE_EVENT_ADVANCE)
- elseif (t[1] == 'roll') then
- local storage = getGlobalStorageValue(1300)
- if storage == 1 then
- local players = getLotteryPlayers()
- local list = {}
- for i, tid in ipairs(players) do
- list[i] = tid
- end
- local winner = list[math.random(1, #list)]
- doBroadcastMessage('['.. getCreatureName(cid) ..'] has drawn the donation lottery and the winner is ['.. getCreatureName(winner) ..'] - Congratulations!', MESSAGE_EVENT_ADVANCE)
- setGlobalStorageValue(1300, 0)
- for _, bid in pairs(getPlayersOnline()) do
- if getCreatureStorage(bid, 1300) == 1 then
- doPlayerSetStorageValue(bid, 1300, 0)
- end
- end
- else
- doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Lottery is not open yet start it first.")
- end
- end
- return true
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement