Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local players, canVote, voted = {}, true, {}
- ui.addPopup(20, 1, 'Você deseja votar?', nil, 20, 20, 200, true)
- for n in pairs(tfm.get.room.playerList) do
- table.insert(players, n)
- end
- function checkVotes()
- if #voted == #players then
- canVote = false
- for i = 1, #voted do
- print(voted[i][1]..' '..(voted[i][2] == "yes" and "upvoted" or "downvoted")..'.')
- end
- end
- end
- function eventNewPlayer(n)
- if canVote then
- local found = false
- for i = 1, #players do
- if players[i] == n then
- found = true
- break
- end
- end
- if not found then
- table.insert(players, n)
- end
- end
- end
- function eventPlayerLeft(n)
- local idx
- for i = 1, #players do
- if players[i] == n then
- idx = i
- break
- end
- end
- local vidx
- for i = 1, #voted do
- if voted[i][1] == n then
- vidx = i
- break
- end
- end
- table.remove(players, idx)
- table.remove(voted, vidx)
- end
- function eventPopupAnswer(id, n, answer)
- if canVote and id == 20 then
- table.insert(voted, {n, answer})
- checkVotes()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement