Advertisement
alditojeje

Sorteo

Sep 24th, 2020 (edited)
1,079
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.74 KB | None | 0 0
  1. local verde = "<font color='#00C17c' size='12'>" -- 00C17c cambias eso x el color
  2. local fondoTextAreas = 0x2B2B2B -- color de fondo, ponelo despues del 0x
  3. local bordeTextAreas = 0x121212 -- color del borde
  4.  
  5. local equipos = {{1, "Blood#3565", "Soothsayer#4890", "Benjaneitorc#0000"}, -- 1
  6.             {2, "Misterthepro#0000", "Noob#5388", "Profeteus#0000"},
  7.             {3, "Random#0000", "random2#5388", "random3#0000"},
  8.             {4, "random6#0000", "random5#5388", "random4#0000"},
  9.             {5, "random7#0000", "random8#5388", "random9#0000"},
  10.             {6, "random12#0000", "random11#5388", "random10#0000"},
  11.             {7, "random12#0000", "random11#5388", "random10#0000"},
  12.             {8, "random12#0000", "random11#5388", "random10#0000"},
  13.             {9, "random12#0000", "random11#5388", "random10#0000"},
  14.             {10, "random12#0000", "random11#5388", "random10#0000"},
  15.             {11, "random12#0000", "random11#5388", "random10#0000"},
  16.             {12, "random12#0000", "random11#5388", "random10#0000"},
  17.             {13, "random12#0000", "random11#5388", "random10#0000"},
  18.             {14, "random12#0000", "random11#5388", "random10#0000"},
  19.             {15, "random12#0000", "random11#5388", "random10#0000"},
  20.             {16, "random12#0000", "random11#5388", "random10#0000"}
  21. }
  22.  
  23. -----------------------
  24. local _, msg = pcall(nil)
  25. local admin = string.match(msg, "^(.-)%.")
  26.  
  27. local admins = {
  28.     [admin] = true, -- Este pertenece a quien cargó el lua, no es necesario que lo cambies
  29.     ["Blood#3565"] = true,
  30.     ["Alditohacker#0000"] = true,
  31.     ["S_hippo#0000"] = true}
  32.  
  33.    
  34. local copy = function(list)
  35.     local out = { }
  36.     for k, v in next, list do
  37.         out[k] = v
  38.     end
  39.     return out
  40. end
  41.  
  42. local totalEquipos = copy(equipos)
  43.  
  44. local x = 115
  45. local y = 45
  46. local countTotal = 0
  47. for _ in pairs(totalEquipos) do
  48.     countTotal = countTotal + 1
  49. end
  50. local enfrentamientos = {}
  51. local countEnfrentamientos = 1
  52. local eligiendo = false
  53. local count = 0
  54.  
  55. for _, i in next, totalEquipos do
  56.     ui.addTextArea(i[1], verde .. "<p align='center'><b><a href='event:team" .. i[1] .. "'>Team" .. i[1] .. "</a>", nil, x, y, 60, 20, fondoTextAreas, bordeTextAreas, 1, true)
  57.     y = y + 45
  58.         if y == 405 then
  59.             x = 645
  60.             y = 45
  61.     end
  62. end
  63.  
  64.  
  65. verIndice = function(team)
  66.     for i, k in next, totalEquipos do    
  67.         if k[1] == team then
  68.             return i
  69.         end
  70.     end
  71. end
  72.  
  73. concatEnfrentamientos = function()
  74.     local versus = "\n<textformat tabstops='[10, 95, 160]'>"
  75.     for _, team in next, enfrentamientos do
  76.         versus = versus .. "\n\t<a href='event:team" .. team[1] .. "'>Team" .. team[1]
  77.                         .. "</a>\t  Vs  \t"
  78.                         .. "<a href='event:team" .. team[2] .. "'>Team" .. team[2]  .. "</a>"
  79.     end
  80.     return versus
  81. end
  82.  
  83.  
  84. eventTextAreaCallback = function (id, name, callback)
  85.     --Callbacks de teams:
  86.     if string.find(callback, "team") then
  87.         local team, players = callback:gsub("team", ""), "\n\n<N><font size='12'>"
  88.         team = tonumber(team)
  89.         for i = 2, 4 do
  90.             players = players .. equipos[team][i] .. "\n"
  91.         end
  92.         ui.addTextArea(666, verde .. "<font size='16'><p align='center'><b>Team" .. team .. players, name, 280, 270, 250, 100, 0x2B2B2B, bordeTextAreas, 1, true)
  93.     end
  94.     --callbacks elegir teams [admins]
  95.     if not admins[name] then return end
  96.  
  97.     if callback == "elegirTeam" and countEnfrentamientos <= 8 then
  98.         local team1 = math.random(1, countTotal) -- Elijo un número del 1 al total de teams
  99.         team1 = totalEquipos[team1][1] -- elijo el team que está en el indice
  100.         table.remove(totalEquipos, verIndice(team1))
  101.         countTotal = countTotal - 1
  102.         ui.removeTextArea(team1, nil)
  103.  
  104.         local team2 = math.random(1, countTotal)
  105.         team2 = totalEquipos[team2][1]
  106.         table.remove(totalEquipos, verIndice(team2))
  107.         countTotal = countTotal - 1
  108.         ui.removeTextArea(team2, nil)
  109.        
  110.         enfrentamientos[countEnfrentamientos] = {team1, team2}
  111.         countEnfrentamientos = countEnfrentamientos + 1
  112.  
  113.         ui.updateTextArea(51, verde .. "<font size='14'><p align='center'><b>Enfrentamientos<p align='left'><font size='12'>" .."<J>" .. (concatEnfrentamientos() or ""), nil)
  114.     end  
  115. end
  116.  
  117.  
  118.  
  119. ui.addTextArea(50, verde .. "", nil, 280, 45, 250, 190, 0x1E1E1E, 0x121212, 1, true)
  120. ui.addTextArea(51, verde .. "<font size='14'><p align='center'><b>Enfrentamientos<font size='12'>" .."\n\n<J>" .. (concatEnfrentamientos() or ""), nil, 290, 55, 235, 160, 0x2B2B2B, 0x2B2B2B, 1, true)
  121. ui.addTextArea(52, verde .. "<p align='center'><b><a href='event:elegirTeam'>Elegir team</a>", nil, 280, 230, 250, 20, fondoTextAreas, bordeTextAreas, 1, true)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement