Advertisement
Bolodefchoco_LUAXML

[Script] Chat

Nov 2nd, 2015
772
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.29 KB | None | 0 0
  1. --Creator: Bolodefchoco
  2. --Made in: 02/11/2015
  3. --Last update: 19/05/2016
  4. --[[ Notes:
  5.     Does:
  6.         Abre um chat de textareas.
  7.     ui.chat:
  8.         Args:
  9.             name --> Nome de quem irá atualizar a popup de escrita
  10.             message --> A nova message (msg .. message)
  11.             x --> Posição horizontal do chat
  12.             y --> Posição vertical do chat
  13.             w --> Largura do chat
  14.             h --> Altura do chat
  15.             title --> Nome do chat
  16.     Chat commands:
  17.         /clear --> Limpa a textarea
  18.         /size --> Mostra o tamanho da textarea (limite de 2000 caracteres)
  19.         /
  20.             BV R BL J N V VP VI ROSE CH T CE CEP CS N2 PT S G --> Coloca a cor correspondente no chat
  21.         /flood
  22.             quantity --> Quantidade (número) de vezes para aparecer o texto (exemplo: 20)
  23.                 text --> Texto
  24.         /admin
  25.             Name --> Faz o jogador de admin
  26.         /unadmin
  27.             Name --> Remove o jogador de admin
  28. ]]--
  29.  
  30. adm = {Bolodefchoco=1} -- Troque Bolodefchoco pelo seu nick
  31. mice={}
  32.  
  33. ui.chat = function(name,message,title,x,y,w,h)
  34.     for admin in next,adm do message=message:gsub(admin,"<R>"..admin.."</R>") end
  35.     _G.message = message or ""
  36.     x,y,w,h = x or 300-150/2, y or 80, w or 350, h or 200
  37.     title = title or "Chat"
  38.     if mice[name] then
  39.         if mice[name].on then
  40.             ui.addPopup(0,2,"",name,x-1,y+200,w+1,true)
  41.         end
  42.     else
  43.         for n in next,tfm.get.room.playerList do
  44.             if mice[n].on then
  45.                 ui.addPopup(0,2,"",n,x-1,y+200,w+1,true)
  46.             end
  47.         end
  48.     end
  49.     for n in next,tfm.get.room.playerList do
  50.         if mice[n] and mice[n].on then
  51.             ui.addTextArea(0,"",n,x,y,w,h,0x324650,0x212E35,1,true)
  52.             ui.addTextArea(1,message,n,x+4,y+5,w-9,h-10,1,1,0,true)
  53.             ui.addTextArea(2,"<font face='Lucida Console'><p align='center'><V>"..title,n,x-1,y-15,w+1,h-185,0x212E35,0x212E35,1,true)
  54.             ui.addTextArea(3,"<R><font size='15'><a href='event:chat_Close'><B>x</B></a></font></R>",n,x+325,y-20,25,25,1,1,0,true)
  55.         end
  56.     end
  57. end
  58.  
  59. eventNewPlayer=function(n)
  60.     mice[n] = {
  61.         on = true,
  62.         msgs = 0
  63.     }
  64.     ui.chat(n,message or "")
  65. end table.foreach(tfm.get.room.playerList,eventNewPlayer)
  66.  
  67. eventTextAreaCallback=function(id,n,c)
  68.     if c == "chat_Close" then
  69.         mice[n].on = false
  70.         for i = 0,3 do ui.removeTextArea(i,n) end
  71.         ui.addPopup(0,2,"",n,1e7,1e7)
  72.         ui.addTextArea(4,"<VP><p align='center'><a href='event:chat_Open'>Chat <J>"..mice[n].msgs,n,745,378,50,h,0x324650,0x212E35,1,true)
  73.     end if c== "chat_Open" then
  74.         mice[n].on = true
  75.         mice[n].msgs = 0
  76.         ui.removeTextArea(4,n)
  77.         ui.chat(n,message or "")
  78.     end
  79. end
  80.  
  81. eventPopupAnswer=function(i,n,a)
  82.     if i == 0 then
  83.         a = a:gsub("http",''):gsub("<","&lt;"):gsub("://",":\\\\")
  84.         for color,tag in next,{"BV","R","BL","J","V","VP","VI","ROSE","CE","CEP","PT","G","N","CH","T","CS","N2","S"} do
  85.             if color>12 or (color <13 and adm[n]) then
  86.                 if a:upper():find("/"..tag.." ") then
  87.                     a = a:gsub("/"..tag:lower().." ","<"..tag..">"):gsub("/"..tag.." ","<"..tag..">")
  88.                 end
  89.             end
  90.         end
  91.         if adm[n] and a:sub(1,1)=="/" and a:sub(2,2)~="/" then
  92.             if a == "/clear" then
  93.                 ui.chat(nil,"<ROSE>[Chat] <PT>#Admin Clear")
  94.             end
  95.             if a == "/size" then
  96.                 message = "<J> . . . #%d\n"..message
  97.                 ui.chat(n,message:format(#message))
  98.             end
  99.             if a:sub(1,6) == "/flood" then
  100.                 local mult,text = a:match("/flood (%d+) (.+)")
  101.                 if mult and text then
  102.                     for i = 1,tonumber(mult) do
  103.                         ui.chat(n,"<V>["..n.."] <N>"..text.."\n"..message)
  104.                     end
  105.                 end
  106.             end
  107.             if a:sub(1,6) == "/admin" then
  108.                 local who = a:sub(8)
  109.                 who = who:gsub("%a",string.upper,1)
  110.                 if tfm.get.room.playerList[who] then
  111.                     adm[who] = 1
  112.                     ui.chat(n,"<ROSE>[Chat] "..who.." <PT>agora é admin!\n"..message)
  113.                 end
  114.             end
  115.             if a:sub(1,8) == "/unadmin" then
  116.                 local who = a:sub(10)
  117.                 who = who:gsub("%a",string.upper,1)
  118.                 if adm[who] then
  119.                     adm[who] = nil
  120.                     ui.chat(n,"<ROSE>[Chat] "..who.." <PT>não é mais admin!\n"..message)
  121.                 end
  122.             end
  123.             ui.chat(n,message)
  124.         else
  125.             if adm[n] then a=a:gsub("//","/") end
  126.             if a ~= "" then
  127.                 ui.chat(n,"<V>["..n.."] <N>"..a.."\n"..message)
  128.             else
  129.                 ui.chat(n,message)
  130.             end
  131.         end
  132.         if #message > 1990 then
  133.             ui.chat(nil,"<ROSE>[Chat] <PT>#2000 Clear")
  134.         end
  135.         for n in next,tfm.get.room.playerList do
  136.             if not mice[n].on then
  137.                 mice[n].msgs = mice[n].msgs + 1
  138.                 ui.updateTextArea(4,"<VP><p align='center'><a href='event:chat_Open'>Chat <J>"..mice[n].msgs,n)
  139.             end
  140.         end
  141.     end
  142. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement