Advertisement
Bolodefchoco_LUAXML

[Script] Modificar cor do nome

Aug 16th, 2015
532
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.20 KB | None | 0 0
  1. --Creator: Bolodefchoco
  2. --Made in: 16/08/2015
  3. --Last update: 15/05/2016
  4. --[[ Notes:
  5.     Does:
  6.         Altera a cor do nome de um jogador.
  7.     Commands:
  8.         !
  9.             namecolor
  10.                 * --> Todos os jogadores
  11.                 Player
  12.                     cor --> Insere cor na cor de Player ou *
  13.                     ? --> Cor aleatória.
  14.                     * --> Cor aleatória.
  15.                     rand --> Cor aleatória.
  16.                     picker --> Abre uma tabela de cores para que você selecione a cor.
  17.                     loop --> Loop de cores aleatórias infinitas
  18.             stop
  19.                 looping --> Interrompe o loop de cores aleatórias
  20.                 Player
  21.                     loop --> Para com o loop de cores aleatórias de player
  22.                 colors --> Volta com a cor normal de nickaname para todos os jogadores
  23. ]]--
  24.  
  25. adm = {Bolodefchoco=1} -- Para usar os comandos, substitua Bolodefchoco e coloque seu nickname no lugar.
  26.  
  27. string.nick=function(player)
  28.     return player:lower():gsub('%a',string.upper,1)
  29. end
  30.  
  31. mice={}
  32. eventNewPlayer=function(n)
  33.     mice[n] = {
  34.         color = 0,
  35.         rand = false,
  36.         player = ""
  37.     }
  38. end
  39. table.foreach(tfm.get.room.playerList,eventNewPlayer)
  40.  
  41. looping = false
  42. eventChatCommand=function(n,c)
  43.     if adm[n] then
  44.         local p = {}
  45.         for val in c:gmatch("[^%s]+") do table.insert(p,val) end
  46.         if p[1]:lower() == "namecolor" then
  47.             mice[n].player = ""
  48.             if p[3]:lower() ~= "picker" and p[3]:lower() ~= "loop" then
  49.                 local color = ""
  50.                 if p[3]:find("^%x") then
  51.                     color = p[3]
  52.                 elseif p[3] == "?" or p[3] == "*" or p[3] == "rand" then
  53.                     color = math.random(0x0000000,0xFFFFFF)
  54.                 end
  55.                 if color ~= "" then
  56.                     if p[2] == "*" then
  57.                         for n in next,tfm.get.room.playerList do
  58.                             tfm.exec.setNameColor(n,color)
  59.                             mice[n].color = color
  60.                         end
  61.                     else
  62.                         p[2] = string.nick(p[2])
  63.                         if tfm.get.room.playerList[p[2]] then
  64.                             tfm.exec.setNameColor(p[2],color)
  65.                             mice[n].color = color
  66.                         end
  67.                     end
  68.                 end
  69.             else
  70.                 if p[3]:lower() == "picker" then
  71.                     if p[2] == "*" then
  72.                         ui.showColorPicker(0,n,1)
  73.                     else
  74.                         p[2] = string.nick(p[2])
  75.                         if tfm.get.room.playerList[p[2]] then
  76.                             mice[n].player = p[2]
  77.                             ui.showColorPicker(1,n,mice[p[2]].color)
  78.                         end
  79.                     end
  80.                 end
  81.                 if p[3]:lower() == "loop" then
  82.                     if p[2] == "*" then
  83.                         looping = true
  84.                     else
  85.                         p[2] = string.nick(p[2])
  86.                         if tfm.get.room.playerList[p[2]] then
  87.                             mice[p[2]].loop = true
  88.                         end
  89.                     end                    
  90.                 end
  91.             end
  92.         end
  93.         if p[1]:lower() == "stop" then
  94.             if p[2] == "looping" then
  95.                 looping = false
  96.             elseif p[3] == "loop" then
  97.                 p[2] = string.nick(p[2])
  98.                 if tfm.get.room.playerList[p[2]] then
  99.                     mice[p[2]].loop = false
  100.                 end
  101.             elseif p[2] == "colors" then
  102.                 for n in next,tfm.get.room.playerList do
  103.                     tfm.exec.setNameColor(n,0)
  104.                     mice[n].color = 0
  105.                 end
  106.             end
  107.         end
  108.     end
  109. end
  110.  
  111. eventLoop=function()
  112.     for n in next,tfm.get.room.playerList do
  113.         if mice[n].loop or looping then
  114.             tfm.exec.setNameColor(n,math.random(0x000000,0xFFFFFF))
  115.         end
  116.     end
  117. end
  118.  
  119. eventColorPicked=function(i,n,c)
  120.     if i == 0 then
  121.         for k in next,tfm.get.room.playerList do
  122.             tfm.exec.setNameColor(k,c)
  123.             mice[k].color = c
  124.         end
  125.     end
  126.     if i == 1 then
  127.         tfm.exec.setNameColor(mice[n].player,c)
  128.         mice[mice[n].player].color = c
  129.     end
  130. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement