Advertisement
Thetroz

Sistema de Rif

Dec 10th, 2015
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.17 KB | None | 0 0
  1. local admin = "Thetroz" --Cambia por tu nombre
  2. local modo = 0
  3. local jugadores = {}
  4. local jugadores_c = 0
  5. for j in pairs(jugadores) do jugadores_c = jugadores_c + 1 end
  6. local continue = true
  7.  
  8. function main()
  9.     table.foreach(tfm.get.room.playerList, function(k,v) preguntar(k) end)
  10. end
  11.  
  12. function sorteo(m)
  13.     if m == 1 then
  14.         ui.addTextArea (4, "<p align='center'><font size='20'>ESCOGIENDO UN GANADOR DE LOS JUGADORES PRESENTES...", nil, 100, 100, nil, nil, 0x000001, 0x000001, 0.8, true)
  15.         timerb = true
  16.         timer = 15
  17.     elseif m == 2 then
  18.         ui.addTextArea (4, "<p align='center'><font size='20'>ESCOGIENDO UN GANADOR DE LOS JUGADORES EN LA LISTA...", nil, 100, 100, nil, nil, 0x000001, 0x000001, 0.8, true)
  19.         timerb = true
  20.         timer = 15 
  21.     end
  22. end
  23.  
  24. function eventLoop()
  25.     if timerb == true then
  26.         timer = timer - 0.5
  27.             if timer == 0 then
  28.                 wons()
  29.                 timer = 15
  30.                 timerb = false
  31.             end
  32.     end
  33. end
  34.  
  35. function wons()
  36.     jugador = jugadores[math.random(#jugadores)]
  37.     ui.addTextArea (4, "<p align='center'><font size='20'><j>"..jugador.."<n> ES EL/LA GANADOR(A)!!!!", nil, 300, 100, nil, nil, 0x000001, 0x000001, 0.8, true)
  38.     animation()
  39. end
  40.  
  41. function animation()
  42.     for i=1,150 do tfm.exec.displayParticle (math.random(21,24), math.random(1,800), math.random(1,400)) end
  43. end
  44.  
  45. function start()
  46.     if modo == 1 then
  47.         playershere()
  48.     elseif modo == 2 then
  49.         createList()
  50.     end
  51. end
  52.  
  53. function createList()
  54.     ui.addPopup (1, 2, "Inserta uno por uno los nombres de los jugadores de la rifa. Cuando termines presiona el botón '<b>Terminar y empezar rifa</b>'<br><br>Insertar jugador #"..jugadores_c+1, admin, 200, 100, 240, true)
  55.     ui.addTextArea (2, "<p align='center'><a href='event:end'>Terminar y empezar rifa", name, 5, 30, 200, 20, 0x000001, 0x000001, 0.8, true)
  56. end
  57.  
  58. function eventPopupAnswer (id,name,answer)
  59.     if id == 1 then
  60.         table.insert(jugadores,answer)
  61.         jugadores_c = jugadores_c + 1
  62.         if continue == true then
  63.             ui.addPopup (1, 2, "Inserta uno por uno los nombres de los jugadores de la rifa. Cuando termines presiona el botón '<b>Terminar y empezar rifa</b>'<br><br>Insertar jugador #"..jugadores_c+1, admin, 200, 100, 240, true)
  64.         end
  65.     end
  66. end
  67.  
  68. function playershere()
  69.     table.foreach(tfm.get.room.playerList, function(k,v) table.insert(jugadores,k) end)
  70.     sorteo(1)
  71. end
  72.  
  73. function preguntar(name)
  74.     if name == admin then
  75.         elegirModo(name)
  76.     end
  77. end
  78.  
  79. function elegirModo(name)
  80.     ui.addTextArea (1, "<p align='center'><font color='000001'>Elige un modo de rifa", name, 200, 100, 240, 150, 0x000001, 0x000001, 0.5, true)
  81.     ui.addTextArea (2, "<p align='center'><a href='event:jp'>Con los jugadores presentes", name, 220, 150, 200,20, 0x000001, 0x000001, 0.8, true)
  82.     ui.addTextArea (3, "<p align='center'><a href='event:lj'>Con una lista de jugadores", name, 220, 190, 200, 20, 0x000001, 0x000001, 0.8, true)
  83. end
  84.  
  85. function eventTextAreaCallback(id,name,event)
  86.     if event == "jp" then
  87.         for i=1,3 do ui.removeTextArea(i,name) end
  88.         modo = 1
  89.         start()
  90.     elseif event == "lj" then
  91.         for i=1,3 do ui.removeTextArea(i,name) end
  92.         modo = 2
  93.         start()
  94.     elseif event == "end" then
  95.         continue = false
  96.         ui.addPopup (1, 0, "", admin, 5, 50000)
  97.         sorteo(2)
  98.     end
  99. end
  100.  
  101. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement