Advertisement
Itchyboy

Shaman Vote [Incomplete]

Feb 28th, 2016
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.20 KB | None | 0 0
  1. tfm.exec.disableAutoShaman(true)
  2. errors=0
  3. timer=false
  4. time=20
  5. vote={}
  6. function getHighestVote()
  7. local cand={name="hi",votes=0}
  8. for n,p in pairs(tfm.get.room.playerList) do
  9. if vote[n].votes>=cand.votes then
  10. cand={name=n,votes=votes[n].votes}
  11. end
  12. end
  13. return cand.name
  14. end
  15. function eventNewPlayer(name)
  16. table.insert(vote,name)
  17. vote[name]={votes=0}
  18. end
  19. for i,v in ipairs(tfm.get.room.playerList) do eventNewPlayer(i) end
  20. function eventNewGame()
  21. tfm.exec.disableAutoTimeLeft(true)
  22. for i,v in ipairs(tfm.get.room.playerList) do tfm.exec.killPlayer(i)
  23. ui.addPopup(0,2,'Vote for your next shaman:',i,v.x,v.y,100)
  24. end
  25. timer=true
  26. end
  27. function eventLoop()
  28. if timer then
  29. time=time-1
  30. for i,v in ipairs(tfm.get.room.playerList) do
  31. ui.addTextArea(0,'<font color="#AA0000" size="20">'..(time/2)..'</font>',i,v.x+50,v.y-30,30,30)
  32. end
  33. if time<=0 then
  34. timer=false
  35. for i,v in ipairs(tfm.get.room.playerList) do
  36. tfm.exec.respawnPlayer(i)
  37. tfm.exec.setShaman(getHighestVote())
  38. tfm.exec.disableAutoTimeLeft(false)
  39. end
  40. end
  41. end
  42. end
  43. function eventPopupAnswer(id,name,answer)
  44. if id==0 then
  45. if vote[answer]==nil then errors=errors+1
  46. else vote[answer].votes=vote[answer].votes+1
  47. end
  48. end
  49. end
  50. tfm.exec.newGame('#0')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement