Advertisement
Guest User

UNO - Transformice Lua

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