Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- outputChatBox ( chatterName.." mówi:#FFFFFF "..message, getRootElement(), 255, 255, 255, true )
- -- funkcje tekstowe
- function addStop(message)
- local interp = string.byte(message, string.len(message))
- if(interp ~= string.byte(".") and interp ~= string.byte("!") and interp ~= string.byte("?")) then
- message = string.format("%s.", message)
- end
- return message
- end
- function firstToUpper(str)
- return (str:gsub("^%l", string.upper))
- end
- -- koniec funkcji tekstowej
- function colouredChat ( message, theType )
- if theType == 0 then --if its normal chat (not /me or teamchat) then
- cancelEvent() --prevent MTA from outputting chat
- 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
- message = string.gsub(message,"<","#DCA2F4**")
- message = string.gsub(message,">","**#FFFFFF")
- message = firstToUpper(message)
- message = addStop(message)
- local chatterName = getPlayerName ( source ) --get his name
- local chatterName = string.gsub(string.gsub(chatterName, "#%x%x%x%x%x%x", ""), "_", " ")
- --output a message with the name as his nametag colour, and the rest in white.
- local x,y,z=getElementPosition(source)
- local strefa=createColSphere(x,y,z,50)
- local gracze=getElementsWithinColShape(strefa, "player")
- for k,v in pairs(gracze) do
- outputChatBox ( chatterName.." mówi:#FFFFFF "..message, v, 255, 255, 255, true )
- end
- elseif theType==1 then
- cancelEvent()
- 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
- local chatterName = getPlayerName ( source ) --get his name
- local chatterName = string.gsub(string.gsub(chatterName, "#%x%x%x%x%x%x", ""), "_", " ")
- local x,y,z=getElementPosition(source)
- local strefa=createColSphere(x,y,z,50)
- local gracze=getElementsWithinColShape(strefa, "player")
- for k,v in pairs(gracze) do
- outputChatBox ( "#DCA2F4*"..chatterName.." "..message, v, 255, 255, 255, true )
- end
- end
- end
- addEventHandler("onPlayerChat", getRootElement(), colouredChat)
- local function doChat(player,command, ... )
- cancelEvent()
- message = table.concat({...}, " ")
- if (#message == 0 ) then return end
- 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
- local chatterName = string.gsub(string.gsub(getPlayerName ( player ), "#%x%x%x%x%x%x", ""), "_", " ")
- local x,y,z=getElementPosition(player)
- local strefa=createColSphere(x,y,z,50)
- local gracze=getElementsWithinColShape(strefa, "player")
- for k,v in pairs(gracze) do
- outputChatBox ( "#8882BC**"..message.." (( "..chatterName.." ))**", v, 255, 255, 255, true )
- end
- end
- addCommandHandler("do", doChat)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement