Advertisement
Guest User

LUA призы

a guest
Aug 28th, 2016
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.60 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. function eventNewPlayer(p)
  23. if not inicio and not fim then
  24. 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)
  25. ui.addTextArea(-3, "<p align='center'><font size='30px'>"..nome, p, 5, 40, 795, 40, 1, 1, 0.8, false)
  26. end
  27. end
  28.  
  29. function eventPopupAnswer(id, p, cmd)
  30. if tonumber(cmd, 10) then
  31. if tonumber(cmd, 10) >= 1 and tonumber(cmd, 10) <= #participante then
  32. ui.removeTextArea(0, nil)
  33. ui.removeTextArea(-1, nil)
  34. qtd = tonumber(cmd, 10)
  35. fast = math.random(5,15)
  36. inicio = true
  37. end
  38. end
  39. end
  40.  
  41. function participando(p)
  42. for i, v in pairs(participante) do
  43. if v == p then
  44. return true
  45. end
  46. end
  47. return false
  48. end
  49.  
  50. function entrada(p, num)
  51. if not participando(p) then
  52. participante[num] = p
  53. 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)
  54. end
  55. end
  56.  
  57. function novo()
  58. for i=1, #participante do
  59. ui.removeTextArea(i, nil)
  60. table.remove(participante, 1)
  61. end
  62. ui.addTextArea(0, "<p align='center'><a href='event:entrada'>Нажмите, чтобы участвовать в розыгрыше!", nil, 200, 370, 400, 20, 1, 0xffff00, 0.8, false)
  63. ui.addTextArea(-1, "<p align='center'><a href='event:inicio'>Запуск", adm, 650, 370, 100, 20, 1, 0x0000ff, 0.8,false)
  64. tfm.exec.removePhysicObject(0)
  65. fim = false
  66. end
  67.  
  68. function sorteio(tipo)
  69. local lista = {}
  70. local sorteado = 0
  71. for i=1, #participante do
  72. lista[i] = i
  73. end
  74. local rand = 0
  75. for i, v in pairs(participante) do
  76. 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)
  77. end
  78. for i=1, qtd do
  79. sorteado = math.random(#lista)
  80. rand = lista[sorteado]
  81. table.remove(lista, sorteado)
  82. if tipo == "quase" then
  83. 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)
  84. elseif tipo == "final" then
  85. 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)
  86. end
  87. end
  88. end
  89.  
  90. function eventLoop()
  91. if inicio then
  92. if fast > 0 then
  93. sorteio("quase")
  94. fast = fast - 1
  95. else
  96. sorteio("final")
  97. inicio = false
  98. fim = true
  99. ui.addTextArea(-1, "<p align='center'><a href='event:novo'>Еще", adm, 650, 370, 100, 20, 1, 0x0000ff, 0.8,false)
  100. end
  101. end
  102. if fim then
  103. tfm.exec.addPhysicObject(0, 400, 200, {type=12,color=math.random(0x666666, 0x777777), miceCollision=false, width=800, height=400})
  104. for i=1, 50 do
  105. 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)
  106. end
  107. end
  108. end
  109.  
  110. tfm.exec.disableAutoShaman(true)
  111. tfm.exec.disableAutoNewGame(true)
  112. tfm.exec.newGame(mapa)
  113. ui.addTextArea(0, "<p align='center'><a href='event:entrada'>Нажмите, чтобы участвовать в розыгрыше!", nil, 200, 370, 400, 20, 1, 0xffff00, 0.8, false)
  114. ui.addTextArea(-1, "<p align='center'><a href='event:inicio'>Запуск", adm, 650, 370, 100, 20, 1, 0x0000ff, 0.8,false)
  115. ui.addTextArea(-3, "<p align='center'><font size='30px'>"..nome, nil, 5, 40, 795, 40, 1, 1, 0.8, false)
  116. tfm.exec.setUIMapName("v 1.0.1 ")
  117. print("<font color='#FF0500'> Запуск..")
  118. print("<font color='#7AFF00'> Успешно запущено!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement