Advertisement
wassimevicw

uno

Feb 21st, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 21.94 KB | None | 0 0
  1. adm = "Ninguem" -- seu nick
  2. gameName = "UNO!" -- nome do mapa
  3. configTempo = 15000 -- tempo limite entre cada jogada
  4. autoStart = false -- inicia e encerra a partida sozinho sem precisar dar !start e !new
  5.  
  6. mapa = [[<C><P /><Z><S><S P="0,0,0.3,0.2,0,0,0,0" L="800" o="214a25" X="400" c="3" Y="135" T="12" H="40" /><S P="0,0,0.3,0.2,0,0,0,0" L="800" o="214a25" X="400" N="" Y="370" T="12" H="60" /><S P="0,0,0,0.2,0,0,0,0" L="200" o="6a7495" X="900" c="3" N="" Y="200" T="12" H="3000" /><S H="3000" L="200" o="6a7495" X="-100" c="3" N="" Y="200" T="12" P="0,0,0,0.2,0,0,0,0" /><S H="100" L="800" o="6a7495" X="400" c="4" N="" Y="-41" T="12" P="0,0,0,0.2,0,0,0,0" /></S><D><P C="ffd800" Y="60" T="90" P="0,0" X="400" /><P C="ffd800" Y="60" T="90" X="606" P="0,0" /><P C="ffd800" Y="60" T="90" P="0,0" X="812" /><P C="ffd800" Y="60" T="90" X="194" P="0,0" /><P C="ffd800" Y="60" T="90" P="0,0" X="-12" /><P C="317c39" Y="125" T="34" X="0" P="0,0" /><P C="8a311b" Y="135" T="19" X="150" P="0,0" /><P C="8a311b" Y="135" T="19" P="0,0" X="250" /><P C="8a311b" Y="134" T="19" X="350" P="0,0" /><P C="8a311b" Y="134" T="19" P="0,0" X="450" /><P C="8a311b" Y="134" T="19" X="550" P="0,0" /><P C="8a311b" Y="134" T="19" P="0,0" X="650" /><P C="8a311b" Y="135" T="19" P="0,0" X="50" /><P C="8a311b" Y="134" T="19" X="750" P="0,0" /><DS Y="100" X="400" /></D><O /></Z></C>]]
  7.  
  8. -- cores das cartas
  9. -- vermelho, azul, amarelo, verde, preto
  10. corInt = {0xFF3232, 0x5365CC, 0xFFD800, 0x73D33B, 1}
  11. corStr = {"FF3232", "5365CC", "FFD800", "73D33B", "000000"}
  12.  
  13. -- ícones das cartas especiais
  14. rev="&#167;"
  15. skip="&#216;"
  16. d2="+2"
  17. d4="+4"
  18. wild="*"
  19.  
  20. -- baralho com 108 cartas
  21. cartas = { -- {cor,valor}
  22.         {1,"0"},{1,"1"},{1,"1"},{1,"2"},{1,"2"},{1,"3"},{1,"3"},{1,"4"},{1,"4"},{1,"5"},{1,"5"},{1,"6"},{1,"6"},{1,"7"},{1,"7"},{1,"8"},{1,"8"},{1,"9"},{1,"9"},{1,rev},{1,rev},{1,skip},{1,skip},{1,d2},{1,d2},
  23.         {2,"0"},{2,"1"},{2,"1"},{2,"2"},{2,"2"},{2,"3"},{2,"3"},{2,"4"},{2,"4"},{2,"5"},{2,"5"},{2,"6"},{2,"6"},{2,"7"},{2,"7"},{2,"8"},{2,"8"},{2,"9"},{2,"9"},{2,rev},{2,rev},{2,skip},{2,skip},{2,d2},{2,d2},
  24.         {3,"0"},{3,"1"},{3,"1"},{3,"2"},{3,"2"},{3,"3"},{3,"3"},{3,"4"},{3,"4"},{3,"5"},{3,"5"},{3,"6"},{3,"6"},{3,"7"},{3,"7"},{3,"8"},{3,"8"},{3,"9"},{3,"9"},{3,rev},{3,rev},{3,skip},{3,skip},{3,d2},{3,d2},
  25.         {4,"0"},{4,"1"},{4,"1"},{4,"2"},{4,"2"},{4,"3"},{4,"3"},{4,"4"},{4,"4"},{4,"5"},{4,"5"},{4,"6"},{4,"6"},{4,"7"},{4,"7"},{4,"8"},{4,"8"},{4,"9"},{4,"9"},{4,rev},{4,rev},{4,skip},{4,skip},{4,d2},{4,d2},
  26.         {5,wild},{5,wild},{5,wild},{5,wild},{5,d4},{5,d4},{5,d4},{5,d4},
  27. }
  28.  
  29. -- TEXTOS
  30.  
  31. txtDraw = "Jogue um %s ou compre %d cartas."
  32. txtSit = "Vá até uma cadeira e aperte espaço para pegar seu lugar!"
  33. txtGameOver = "%s venceu o jogo!"
  34. txtPass = "Passar a vez"
  35. txtWarn = "Volte para sua cadeira!"
  36. txtChoose = "Escolha uma cor"
  37. txtRed = "VERMELHO"
  38. txtBlue = "AZUL"
  39. txtYellow = "AMARELO"
  40. txtGreen = "VERDE"
  41.  
  42. -- VARIÁVEIS DE JOGO
  43.  
  44. comandos = {"ban", "kick", "new", "start"}
  45. baralho = {}
  46. pilha = {}
  47. jogador = {}
  48. nome = {}
  49. timerTxt = {}
  50. modo = "inicio"
  51. duelo = false
  52. atual = nil
  53. vez = false
  54. sel = true
  55. draw = false
  56. acumulo = 0
  57. acumulo4 = 0
  58. fluxo = 1
  59. tempoJogada = os.time() + 15000
  60. tempo = os.time()+1000
  61.  
  62. -- FUNÇÕES AUXILIARES -- podem funcionar em outros scripts
  63.  
  64. function split(t,s) -- retorna uma table com a string dividida
  65.         local a={}
  66.         for i,v in string.gmatch(t,string.format("[^%s]+",s or "%s")) do
  67.                 table.insert(a,i)
  68.         end
  69.         return a
  70. end
  71.  
  72. function arrumaNick(p) -- retorna o nick com o formato padrão (inicial maiúscula e restante minúsculo)
  73.         return p:sub(1,1):upper() .. p:sub(2):lower()
  74. end
  75.  
  76. function embaralhar(b) -- embaralha uma table recebida
  77.         local novo = {}
  78.         local rand = {}
  79.         for i=1, #b do
  80.                 rand[i] = i
  81.         end
  82.         for i=1, #b do
  83.                 local r = math.random(#rand)
  84.                 table.insert(novo, b[rand[r]])
  85.                 table.remove(rand, r)
  86.         end
  87.         return novo
  88. end
  89.  
  90. function efeitoExplosao(id, x, y, vezes, vel) -- faz uma mini explosão de partículas
  91.         for i=1, vezes do
  92.                 tfm.exec.displayParticle(id, x, y, math.random(-vel,vel)/10, math.random(-vel,vel)/10, 0, 0)
  93.         end
  94. end
  95.  
  96. function apagaText() -- procura textos pra apagar, requer uma table global timerTxt, preenchida com {id=idDaTextArea, p=JogadorAlvo, time=TempoDeDuracao}
  97.         local apagar={}
  98.         for i,v in pairs(timerTxt) do
  99.                 if v.time<os.time() then
  100.                         table.insert(apagar,i)
  101.                         ui.removeTextArea(v.id, v.p)
  102.                 end
  103.         end
  104.         for i=1,#apagar do
  105.                 timerTxt[apagar[i]]=nil
  106.         end
  107. end
  108.  
  109. function timerText(i, t, pp) -- auxilia no preenchimento da tabela timerTxt
  110.         table.insert(timerTxt, {id=i, time=os.time()+t, p=pp})
  111. end
  112.  
  113. -- FUNÇÕES DO SCRIPT
  114.  
  115. function novoJogo()
  116.         for i=1, 50 do
  117.                 ui.removeTextArea(i)
  118.         end
  119.         for i=1, 8 do
  120.                 if jogador[i] then
  121.                         nome[jogador[i].nome] = nil
  122.                         jogador[i] = nil
  123.                 end
  124.         end
  125.         ui.removeTextArea(100)
  126.         modo = "inicio"
  127.         tfm.exec.newGame(mapa)
  128. end
  129.  
  130. function desenhaCarta(i, c, p, x, y)
  131.         ui.addTextArea(i, "\n<p align='center'><font size='23px' color='#ffffff'>"..c[2], p, x, y, 40, 60, corInt[c[1]], 0xffffff, 1,false)
  132. end
  133.  
  134. function desenhaBaralho(p)
  135.         ui.addTextArea(11, "", p, 330, 200, 40, 60, 1, 0xffffff, 1,false)
  136.         ui.addTextArea(12, "<p align='center'><font size='12px' color='#FFD800'>UNO", p, 333, 223, 34, 16, 0xFF3232, 0xFF3232, 1,false)
  137. end
  138.  
  139. function atualizaScore(n, p)
  140.         ui.addTextArea(n, "<p align='center'>"..jogador[n].nome.."<b>\n<font size='18px'><j>"..(#jogador[n].mao~=1 and #jogador[n].mao or "UNO!"), p, (n-1)*100-50, 115, 200, 60, 0, 0, 0, false)
  141. end
  142.  
  143. function atualizaMao(p)
  144.         for i=20, 50 do
  145.                 ui.removeTextArea(i, p)
  146.         end
  147.         for i, v in pairs(jogador[nome[p]].mao) do
  148.                 desenhaCarta(i+20, v, p, 400-(#jogador[nome[p]].mao*25)+50*(i-1), 330)
  149.         end
  150. end
  151.  
  152. function atualizaFluxo(p)
  153.         defFluxo = {
  154.                 "&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;",
  155.                 "&lt; &lt; &lt; &lt; &lt; &lt; &lt; &lt; &lt; &lt; &lt; &lt; &lt; &lt; &lt; &lt; &lt; &lt; &lt; &lt; &lt; &lt; &lt; &lt; &lt; &lt; &lt; &lt; &lt; &lt; &lt; &lt;"
  156.         }
  157.         ui.addTextArea(14, string.format("<p align='center'><font size='20px' color='#214A25'><b>%s", defFluxo[fluxo]), p, 0, 160, 800, 120, 0, 0, 0, false)
  158. end
  159.  
  160. function atualizaPonteiro(p)
  161.         ui.addTextArea(13, "", p, 100*(vez-1), 30, 100, 120, -1, 0xffffff, 1, false)
  162. end
  163.  
  164. function atualizaTimer()
  165.         tempoJogada = os.time() + configTempo
  166. end
  167.  
  168. function criaJogador(p, n)
  169.         jogador[n] = {nome=p, mao={}, timer=os.time()+2000}
  170.         atualizaScore(n)
  171.         ui.removeTextArea(0, p)
  172.         nome[p] = n
  173. end
  174.  
  175. function removeJogadorUI(p, n)
  176.         ui.removeTextArea(n)
  177.         jogador[n] = nil
  178.         nome[p] = nil
  179. end
  180.  
  181. function removeJogador(p, n)
  182.         if n == vez then
  183.                 autoPlay()
  184.         end
  185.         for i=1, #jogador[n].mao do
  186.                 table.insert(pilha, table.remove(jogador[n].mao))
  187.         end
  188.         removeJogadorUI(p, n)
  189. end
  190.  
  191. function ordenar(b)
  192.         table.sort(b, function(a, b)
  193.                 p = {["0"]=0,["1"]=1,["2"]=2,["3"]=3,["4"]=4,["5"]=5,["6"]=6,["7"]=7,["8"]=8,["9"]=9,[rev]=10,[skip]=11,[d2]=12,[wild]=13,[d4]=14,}
  194.                 if a[1] ~= b[1] then
  195.                         return a[1] < b[1]
  196.                 else
  197.                         return p[a[2]] < p[b[2]]
  198.                 end
  199.         end)
  200. end
  201.  
  202. function comprarCartas(p, qtd)
  203.         ui.addTextArea(70+nome[p], "<p align='center'><font size='20px'><bv><b>+"..qtd, nil, (nome[p]-1)*100, 145, 100, 60, 0, 0, 0, false)
  204.         timerText(70+nome[p], 2000)
  205.         for i=1, qtd do
  206.                 if #baralho == 0 then
  207.                         baralho = embaralhar(pilha)
  208.                         pilha = {}
  209.                 end
  210.                 table.insert(jogador[nome[p]].mao, table.remove(baralho))
  211.         end
  212.         ordenar(jogador[nome[p]].mao)
  213.         atualizaMao(p)
  214.         atualizaScore(nome[p])
  215. end
  216.  
  217. function pegaAnterior()
  218.         local n = vez
  219.         repeat
  220.                 n = fluxo == 1 and (n == 1 and 8 or n - 1) or (n == 8 and 1 or n + 1)
  221.         until jogador[n]
  222.         return n
  223. end
  224.  
  225. function pegaProximo()
  226.         local n = vez
  227.         repeat
  228.                 n = fluxo == 1 and (n == 8 and 1 or n + 1) or (n == 1 and 8 or n - 1)
  229.         until jogador[n]
  230.         return n
  231. end
  232.  
  233. function passarVez()
  234.         vez = pegaProximo()
  235.         draw = false
  236.         atualizaPonteiro()
  237.         atualizaTimer()
  238.         ui.removeTextArea(15)
  239.         ui.removeTextArea(16)
  240.         ui.removeTextArea(17)
  241. end
  242.  
  243. function estaNoLugar(p)
  244.         local x = tfm.get.room.playerList[p].x
  245.         return nome[p] and x > (nome[p]-1)*100+20 and x < (nome[p]-1)*100+80
  246. end
  247.  
  248. function usaDraw4()
  249.         acumulo4 = acumulo4 + 4
  250.         ui.addTextArea(16, string.format("<p align='center'>"..txtDraw, d4, acumulo4), jogador[vez].nome, 250, 290, 300, 20, 1, 1, 0.4, true)
  251. end
  252.  
  253. function autoPlay()
  254.         local p = jogador[vez].nome
  255.         n = acumulo > 0 and acumulo or acumulo4 > 0 and acumulo4 or 1
  256.         acumulo = 0
  257.         acumulo4 = 0
  258.         if not draw then
  259.                 comprarCartas(p, n)
  260.         end
  261.         passarVez()
  262.         if atual[1] == 5 then
  263.                 mudaCor()
  264.                 sel = true
  265.                 if atual[2] == d4 then
  266.                         usaDraw4()
  267.                 end
  268.         end
  269. end
  270.  
  271. function mudaCor(n)
  272.         atual[1] = n or math.random(1,4)
  273.         desenhaCarta(10, atual, nil, 420, 200)
  274.         local b = {21, 23, 24, 22}
  275.         efeitoExplosao(b[atual[1]], 445, 230, 30, 20)
  276. end
  277.  
  278. function usaSkip()
  279.         efeitoExplosao(35, pegaProximo()*100-50, 100, 50, 10)
  280.         passarVez()
  281. end
  282.  
  283. function usaReverse()
  284.         fluxo = fluxo == 1 and 2 or 1
  285.         atualizaFluxo()
  286.         for i=20, 780, 10 do
  287.                 tfm.exec.displayParticle(3, i, 177, 0, 0, 0, 0)
  288.         end
  289. end
  290.  
  291. -- EVENTOS
  292.  
  293. function eventNewGame()
  294.         tempo = os.time()+1000
  295.         tfm.exec.setUIMapName(gameName)
  296.         ui.addTextArea(0, "<font size='25px'><p align='center'>"..txtSit, nil, 0, 180, 800, 200, 0, 0, 0, false)
  297.         for i, v in pairs(tfm.get.room.playerList) do
  298.                 tfm.exec.bindKeyboard(i, 32, true, true)
  299.                 system.bindMouse(i, true)
  300.         end
  301. end
  302.  
  303. function eventTextAreaCallback(id, p, cmd)
  304.         if id == 15 and nome[p] == vez then
  305.                 mudaCor(tonumber(cmd))
  306.                 passarVez()
  307.                 sel = true
  308.                 if atual[2] == d4 then
  309.                         acumulo4 = acumulo4 + 4
  310.                         ui.addTextArea(16, string.format("<p align='center'>"..txtDraw, d4, acumulo4), jogador[vez].nome, 250, 290, 300, 20, 1, 1, 0.4, true)
  311.                 end
  312.         elseif cmd = "skip" then
  313.                 passarVez()
  314.         end
  315. end
  316.  
  317. function eventMouse(p, x, y)
  318.         if modo == "start" then
  319.                 local xx =  tfm.get.room.playerList[p].x
  320.                 if jogador[nome[p]] and y > 325 and y < 400 and estaNoLugar(p) then
  321.                         local carta = math.ceil((x+5 - (400 - (#jogador[nome[p]].mao*25)))/50)
  322.                         local mao = jogador[nome[p]].mao
  323.                         if vez == nome[p] and sel then
  324.                                 if mao[carta] and (acumulo == 0 or mao[carta][2] == d2) and (acumulo4 == 0 or mao[carta][2] == d4) and (mao[carta][1] == atual[1] or mao[carta][2] == atual[2] or mao[carta][2] == wild or mao[carta][2] == d4) then
  325.                                         if atual[2] == d4 or atual[2] == wild then
  326.                                                 atual[1] = 5
  327.                                         end
  328.                                         table.insert(pilha, atual)
  329.                                         atual = table.remove(mao, carta)
  330.                                         atualizaMao(p)
  331.                                         desenhaCarta(10, atual, nil, 420, 200)
  332.                                         atualizaScore(nome[p])
  333.                                         if #jogador[nome[p]].mao == 0 then
  334.                                                 ui.addTextArea(13, "", nil, 5, 5, 790, 400, 1, 1, 0.5, false)
  335.                                                 ui.addTextArea(14, string.format("<p align='center'><font size='60px' color='#ffffff'>"..txtGameOver, p), nil, 0, 170, 800, 400, 0, 0, 0, false)
  336.                                                 tfm.exec.setPlayerScore(p, 1, true)
  337.                                                 modo = "fim"
  338.                                         else
  339.                                                 if atual[2] == wild or atual[2] == d4 then
  340.                                                         sel = false
  341.                                                         draw = true
  342.                                                         ui.addTextArea(15, string.format("<p align='center'>%s\n<a href='event:1'><font color='#FF3232'>%s</font></a> - <a href='event:2'><font color='#5365CC'>%s</font></a> - <a href='event:3'><font color='#FFD800'>%s</font></a> - <a href='event:4'><font color='#73D33B'>%s</font></a>", txtChoose, txtRed, txtBlue, txtYellow, txtGreen), p, 250, 290, 300, 30, 1, 1, 0.7, true)
  343.                                                 else
  344.                                                         if atual[2] == skip then
  345.                                                                 usaSkip()
  346.                                                         elseif atual[2] == rev then
  347.                                                                 if duelo then
  348.                                                                         usaSkip()
  349.                                                                 else
  350.                                                                         usaReverse()
  351.                                                                 end
  352.                                                         elseif atual[2] == d2 then
  353.                                                                 acumulo = acumulo + 2
  354.                                                                 ui.addTextArea(16, string.format("<p align='center'>"..txtDraw, d2, acumulo), jogador[pegaProximo()].nome, 250, 290, 300, 20, 1, 1, 0.4, true)
  355.                                                         end
  356.                                                         passarVez()
  357.                                                 end
  358.                                         end
  359.                                         for i=1, 10 do
  360.                                                 tfm.exec.displayParticle(3, 445, 230, math.random(-20,20)/10, math.random(-20,20)/10, 0, 0)
  361.                                         end
  362.                                 end
  363.                         elseif os.time() > jogador[nome[p]].timer and mao[carta] then
  364.                                 desenhaCarta(nome[p]+200, mao[carta], nil, (nome[p]-1)*100+30, 30)
  365.                                 timerText(200+nome[p], 1000)
  366.                                 jogador[nome[p]].timer = os.time()+2000
  367.                         end
  368.                 elseif x > 325 and x < 375 and y > 195 and y < 245 and not draw and vez == nome[p] and sel then
  369.                         if acumulo > 0 or acumulo4 > 0 then
  370.                                 comprarCartas(p, acumulo > 0 and acumulo or acumulo4)
  371.                                 acumulo = 0
  372.                                 acumulo4 = 0
  373.                                 passarVez()
  374.                         else
  375.                                 comprarCartas(p, 1)
  376.                                 ui.addTextArea(16, "<p align='center'><a href='event:skip'>"..txtPass, p, 250, 290, 300, 20, 1, 1, 0.7, true)
  377.                                 draw = true
  378.                         end
  379.                 end
  380.         end
  381. end
  382.  
  383. function eventChatCommand(p, cmd)
  384.         local arg = split(cmd, " ")
  385.         if p == adm then
  386.                 if arg[1] == "start" and modo == "inicio" then
  387.                         local r = {}
  388.                         modo = "start"
  389.                         sel = true
  390.                         fluxo = 1
  391.                         draw = false
  392.                         atual = nil
  393.                         atualizaTimer()
  394.                         baralho = embaralhar(cartas)
  395.                         pilha = {}
  396.                         ui.removeTextArea(0)
  397.                         for i, v in pairs(jogador) do
  398.                                 comprarCartas(v.nome, 7)
  399.                                 table.insert(r, i)
  400.                         end
  401.                         duelo = #r == 2
  402.                         repeat
  403.                                 table.insert(pilha, atual)
  404.                                 atual = table.remove(baralho)
  405.                         until atual[2] ~= d4 and atual[2] ~= wild and atual[2] ~= d2 and atual[2] ~= skip and atual[2] ~= rev
  406.                         desenhaCarta(10, atual, nil, 420, 200)
  407.                         desenhaBaralho()
  408.                         vez = r[math.random(#r)]
  409.                         atualizaPonteiro()
  410.                         atualizaFluxo()
  411.                 elseif arg[1] == "new" then
  412.                         novoJogo()
  413.                 elseif arg[1] == "skip" then
  414.                         autoPlay()
  415.                 elseif arg[1] == "ban" and arg[2] and nome[arrumaNick(arg[2])] then
  416.                         eventPlayerLeft(arrumaNick(arg[2]))
  417.                 end
  418.         end
  419. end
  420.  
  421. function eventKeyboard(p, t, d, x, y)
  422.         if modo == "inicio" and os.time() > tempo and not nome[p] then
  423.                 if x > 20 and x < 80 and not jogador[1] then
  424.                         criaJogador(p, 1)
  425.                 elseif x > 120 and x < 180 and not jogador[2] then
  426.                         criaJogador(p, 2)
  427.                 elseif x > 220 and x < 280 and not jogador[3] then
  428.                         criaJogador(p, 3)
  429.                 elseif x > 320 and x < 380 and not jogador[4] then
  430.                         criaJogador(p, 4)
  431.                 elseif x > 420 and x < 480 and not jogador[5] then
  432.                         criaJogador(p, 5)
  433.                 elseif x > 520 and x < 580 and not jogador[6] then
  434.                         criaJogador(p, 6)
  435.                 elseif x > 620 and x < 680 and not jogador[7] then
  436.                         criaJogador(p, 7)
  437.                 elseif x > 720 and x < 780 and not jogador[8] then
  438.                         criaJogador(p, 8)
  439.                 end
  440.         end
  441. end
  442.  
  443. function eventLoop()
  444.         for i, v in pairs(jogador) do
  445.                 if not estaNoLugar(v.nome) then
  446.                         ui.addTextArea(100, "<font size='50px' color='#ffffff'><p align='center'>"..txtWarn, v.nome, 5, 325, 790, 80, 0xff0000, 0xff0000, 1, true)
  447.                 else
  448.                         ui.removeTextArea(100, v.nome)
  449.                 end
  450.         end
  451.         if modo == "fim" then
  452.                 local b = {0, 1, 2, 4, 9, 11, 13}
  453.                 local x, y, id = math.random(800), math.random(400), b[math.random(#b)]
  454.                 for i=1, 40 do
  455.                         tfm.exec.displayParticle(id, x, y, math.random(-20,20)/10, math.random(-20,20)/10, 0, 0)
  456.                 end
  457.                 if os.time() > tempoJogada and autoStart then
  458.                         atualizaTimer()
  459.                         eventChatCommand(adm, "new")
  460.                 end
  461.         end
  462.         if modo == "start" then
  463.                 if os.time() > tempoJogada then
  464.                         autoPlay()
  465.                 elseif tempoJogada - os.time() < 10000 then
  466.                         ui.addTextArea(17, "<p align='center'><font size='25px' color='#214A25'>"..math.ceil((tempoJogada - os.time())/1000), nil, 350, 210, 90, 100, 0, 0, 0, false)
  467.                 else
  468.                         ui.removeTextArea(17)
  469.                 end
  470.         elseif modo == "inicio" then
  471.                 if os.time() > tempoJogada and autoStart then
  472.                         atualizaTimer()
  473.                         eventChatCommand(adm, "start")
  474.                 end
  475.         end
  476.         apagaText()
  477. end
  478.  
  479. function eventNewPlayer(p)
  480.         if modo == "inicio" then
  481.                 ui.addTextArea(0, "<font size='25px'><p align='center'>"..txtSit, p, 0, 180, 800, 200, 0, 0, 0, false)
  482.                 tfm.exec.bindKeyboard(p, 32, true, true)
  483.                 system.bindMouse(p, true)
  484.         elseif modo == "start" then
  485.                 desenhaCarta(10, atual, p, 420, 200)
  486.                 desenhaBaralho(p)
  487.                 atualizaPonteiro(p)
  488.                 atualizaFluxo(p)
  489.         end
  490.         for i, v in pairs(jogador) do
  491.                 atualizaScore(i, p)
  492.         end
  493.         tfm.exec.respawnPlayer(p)
  494.         tfm.exec.setUIMapName(gameName)
  495. end
  496.  
  497. function eventPlayerLeft(p)
  498.         if modo == "inicio" then
  499.                 if nome[p] then
  500.                         removeJogadorUI(p, nome[p])
  501.                 end
  502.         elseif modo == "start" then
  503.                 if nome[p] and jogador[nome[p]] then
  504.                         removeJogador(p, nome[p])
  505.                 end
  506.         end
  507. end
  508.  
  509. function eventPlayerDied(p)
  510.         tfm.exec.respawnPlayer(p)
  511. end
  512.  
  513. -- INICIO
  514.  
  515. tfm.exec.disableAutoScore(true)
  516. tfm.exec.disableAutoShaman(true)
  517. tfm.exec.disableAutoNewGame(true)
  518. tfm.exec.disableAfkDeath(true)
  519. for i, v in pairs(comandos) do
  520.         system.disableChatCommandDisplay(v, true)
  521. end
  522. for i, v in pairs(tfm.get.room.playerList) do
  523.         tfm.exec.setPlayerScore(i, 0, false)
  524. end
  525. tfm.exec.newGame(mapa)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement