Advertisement
Cherro

dwdwd

Jun 9th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.99 KB | None | 0 0
  1. -- outputChatBox ( chatterName.." mówi:#FFFFFF "..message, getRootElement(), 255, 255, 255, true )
  2.  
  3. -- funkcje tekstowe
  4. function addStop(message)
  5.     local interp = string.byte(message, string.len(message))
  6.     if(interp ~= string.byte(".") and interp ~= string.byte("!") and interp ~= string.byte("?")) then
  7.         message = string.format("%s.", message)
  8.     end
  9.     return message
  10. end
  11.  
  12. function firstToUpper(str)
  13.     return (str:gsub("^%l", string.upper))
  14. end
  15.  
  16.  
  17.  
  18.  
  19.  
  20. -- koniec funkcji tekstowej
  21.  
  22.  
  23.  
  24. function colouredChat ( message, theType )
  25.     if theType == 0 then --if its normal chat (not /me or teamchat) then
  26.         cancelEvent() --prevent MTA from outputting chat
  27.         message = string.gsub(message, "#%x%x%x%x%x%x", "") --remove any hex tags in a player's chat to prevent custom colours by using lua's string.gsub
  28.        
  29.         message = string.gsub(message,"<","#DCA2F4**")
  30.         message = string.gsub(message,">","**#FFFFFF")
  31.         message = firstToUpper(message)
  32.         message = addStop(message)
  33.         local chatterName = getPlayerName ( source ) --get his name
  34.         local chatterName = string.gsub(string.gsub(chatterName, "#%x%x%x%x%x%x", ""), "_", " ")
  35.         --output a message with the name as his nametag colour, and the rest in white.
  36.          local x,y,z=getElementPosition(source)
  37.             local strefa=createColSphere(x,y,z,50)
  38.             local gracze=getElementsWithinColShape(strefa, "player")
  39.    
  40.  
  41. for k,v in pairs(gracze) do
  42. outputChatBox ( chatterName.." mówi:#FFFFFF "..message, v, 255, 255, 255, true )
  43. end
  44.    
  45.  
  46. elseif theType==1 then
  47.         cancelEvent()
  48.         message = string.gsub(message, "#%x%x%x%x%x%x", "") --remove any hex tags in a player's chat to prevent custom colours by using lua's string.gsub
  49.         local chatterName = getPlayerName ( source ) --get his name
  50.         local chatterName = string.gsub(string.gsub(chatterName, "#%x%x%x%x%x%x", ""), "_", " ")
  51.          local x,y,z=getElementPosition(source)
  52.             local strefa=createColSphere(x,y,z,50)
  53.             local gracze=getElementsWithinColShape(strefa, "player")
  54.    
  55.  
  56. for k,v in pairs(gracze) do
  57. outputChatBox ( "#DCA2F4*"..chatterName.." "..message, v, 255, 255, 255, true )
  58. end
  59.         end
  60.  
  61.  
  62.  
  63.     end
  64. addEventHandler("onPlayerChat", getRootElement(), colouredChat)
  65.  
  66. local function doChat(player,command, ... )
  67.                 cancelEvent()
  68.                 message = table.concat({...}, " ")
  69.         if (#message == 0 ) then return end
  70.                 message = string.gsub(message, "#%x%x%x%x%x%x", "") --remove any hex tags in a player's chat to prevent custom colours by using lua's string.gsub
  71.                 local chatterName = string.gsub(string.gsub(getPlayerName ( player ), "#%x%x%x%x%x%x", ""), "_", " ")
  72.                  local x,y,z=getElementPosition(player)
  73.                 local strefa=createColSphere(x,y,z,50)
  74.                 local gracze=getElementsWithinColShape(strefa, "player")
  75.        
  76.  
  77. for k,v in pairs(gracze) do
  78. outputChatBox ( "#8882BC**"..message.." (( "..chatterName.." ))**", v, 255, 255, 255, true )
  79. end
  80.  
  81.  
  82. end
  83.  
  84. addCommandHandler("do", doChat)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement