Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2016
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.53 KB | None | 0 0
  1. --Где adm=”vladwv” вставляем свой ник
  2. adm = "vladwv"
  3. nome = "Розыгрыш призов!"
  4. mapa = [[<C><P Ca=""/><Z><S><S H="40" P="0,0,0.3,0.2,0,0,0,0" L="800" X="399" N="" Y="380" T="0" /></S><D /><O /></Z></C>]]
  5.  
  6. participante = {}
  7. inicio = false
  8. fim = false
  9. qtd = 0
  10. fast = 0
  11.  
  12. function eventTextAreaCallback(id, p, cmd)
  13. if cmd == "entrada" then
  14. ui.addTextArea(0, "<p align='center'>Вы участвуете", p, 200, 370, 400, 20, 1, 0x00ff00, 0.8,false)
  15. entrada(p, #participante + 1)
  16. elseif cmd == "inicio" then
  17. ui.addPopup(0, 2, "<p align='center'>Количество выпавших", p, 300, 200, 200, false)
  18. elseif cmd == "novo" then
  19. novo()
  20. end
  21. end
  22.  
  23. function eventNewPlayer(p)
  24. if not inicio and not fim then
  25. ui.addTextArea(0, "<p align='center'><a href='event:entrada'>Clique para participar do sorteio!", p, 200, 370, 400, 20, 1, 0xffff00, 0.8, false)
  26. ui.addTextArea(-3, "<p align='center'><font size='30px'>"..nome, p, 5, 40, 795, 40, 1, 1, 0.8, false)
  27. end
  28. end
  29.  
  30. function eventPopupAnswer(id, p, cmd)
  31. if tonumber(cmd, 10) then
  32. if tonumber(cmd, 10) >= 1 and tonumber(cmd, 10) <= #participante then
  33. ui.removeTextArea(0, nil)
  34. ui.removeTextArea(-1, nil)
  35. qtd = tonumber(cmd, 10)
  36. fast = math.random(5,15)
  37. inicio = true
  38. end
  39. end
  40. end
  41.  
  42. function participando(p)
  43. for i, v in pairs(participante) do
  44. if v == p then
  45. return true
  46. end
  47. end
  48. return false
  49. end
  50.  
  51. function entrada(p, num)
  52. if not participando(p) then
  53. participante[num] = p
  54. ui.addTextArea(num, "<p align='center'>" .. p, nil, ((num-1)%8)*100+5, math.floor((num-1)/8)*30+100, 90, 20, 1, 1, 0.8, false)
  55. end
  56. end
  57.  
  58. function novo()
  59. for i=1, #participante do
  60. ui.removeTextArea(i, nil)
  61. table.remove(participante, 1)
  62. end
  63. ui.addTextArea(0, "<p align='center'><a href='event:entrada'>Нажмите, чтобы участвовать в розыгрыше!", nil, 200, 370, 400, 20, 1, 0xffff00, 0.8, false)
  64. ui.addTextArea(-1, "<p align='center'><a href='event:inicio'>Iniciar", adm, 650, 370, 100, 20, 1, 0x0000ff, 0.8,false)
  65. tfm.exec.removePhysicObject(0)
  66. fim = false
  67. end
  68.  
  69. function sorteio(tipo)
  70. local lista = {}
  71. local sorteado = 0
  72. for i=1, #participante do
  73. lista[i] = i
  74. end
  75. local rand = 0
  76. for i, v in pairs(participante) do
  77. ui.addTextArea(i, "<p align='center'>" .. v, nil, ((i-1)%8)*100+5, math.floor((i-1)/8)*30+100, 90, 20, 1, 1, 0.8, false)
  78. end
  79. for i=1, qtd do
  80. sorteado = math.random(#lista)
  81. rand = lista[sorteado]
  82. table.remove(lista, sorteado)
  83. if tipo == "quase" then
  84. ui.addTextArea(rand, "<p align='center'><font color='#ffff00'>" .. participante[rand], nil, ((rand-1)%8)*100+5, math.floor((rand-1)/8)*30+100, 90, 20, 1, 0xffff00, 0.8, false)
  85. elseif tipo == "final" then
  86. ui.addTextArea(rand, "<p align='center'><font color='#00ff00'><b>" .. participante[rand], nil, ((rand-1)%8)*100+5, math.floor((rand-1)/8)*30+100, 90, 20, 1, 0x00ff00, 0.8, false)
  87. end
  88. end
  89. end
  90.  
  91. function eventLoop()
  92. if inicio then
  93. if fast > 0 then
  94. sorteio("quase")
  95. fast = fast - 1
  96. else
  97. sorteio("final")
  98. inicio = false
  99. fim = true
  100. ui.addTextArea(-1, "<p align='center'><a href='event:novo'>Новый розыгрыш", adm, 650, 370, 100, 20, 1, 0x0000ff, 0.8,false)
  101. end
  102. end
  103. if fim then
  104. tfm.exec.addPhysicObject(0, 400, 200, {type=12,color=math.random(0x666666, 0x777777), miceCollision=false, width=800, height=400})
  105. for i=1, 50 do
  106. tfm.exec.displayParticle(math.random(21,24), math.random(1,800), 20, math.random(-20,20)/100, math.random(10,1000)/100, 0, 0, nil)
  107. end
  108. end
  109. end
  110.  
  111. tfm.exec.disableAutoShaman(true)
  112. tfm.exec.disableAutoNewGame(true)
  113. tfm.exec.newGame(mapa)
  114. ui.addTextArea(0, "<p align='center'><a href='event:entrada'>Нажмите, чтобы участвовать в розыгрыше!", nil, 200, 370, 400, 20, 1, 0xffff00, 0.8, false)
  115. ui.addTextArea(-1, "<p align='center'><a href='event:inicio'>Пуск", adm, 650, 370, 100, 20, 1, 0x0000ff, 0.8,false)
  116. ui.addTextArea(-3, "<p align='center'><font size='30px'>"..nome, nil, 5, 40, 795, 40, 1, 1, 0.8, false)
  117. tfm.exec.setUIMapName("Автор перевода Vladwv")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement