السلام عليكم
الكود يكرر الكلام بالشات
-- Forbidden words
-- Not necessary to be full words. If they are found in a part of the word, the whole word if filtered
swearWords = {
"",
}
-- Intercept chat messages
addEventHandler("onPlayerChat",getRootElement(),
function(msg,type)
-- Only affect normal messages
if type == 0 then
-- Cancel output
cancelEvent()
-- Clean up the message from any bad words
local new = ""
local iter = 0
for word in msg:gmatch("%S+") do
iter = iter + 1
for i,swr in ipairs(swearWords) do
local src = word:lower():gsub("%s","")
local src = src:gsub("#%x%x%x%x%x%x","")
local src = src:gsub("%c","")
local src = src:gsub("%p","")
local pat = swr:lower():gsub("%s","")
if src:find(pat) then
local replaceString = ""
for x=1,word:gsub("#%x%x%x%x%x%x",""):len() do
replaceString = replaceString.."*"
end
word = word:gsub(word,replaceString)
end
end
if iter == 1 and word:len() > 2 then
word = word:gsub("%a",string.upper,1)
end
new = new..word.." "
end
if new ~= "" then msg = new end
-- Get appropriate team colors and output the clean message
local pTeam = getPlayerTeam(source)
if pTeam then
local r,g,b = getTeamColor(pTeam)
local hr,hg,hb = decToHex(r),decToHex(g),decToHex(b)
local color = "#"..hr..hg..hb
outputMessage(color..getPlayerName(source),msg)
else
outputMessage(getPlayerName(source),msg)
end
end
end)
-- Output preformatted message to the chatbox
function outputMessage(author,message)
outputChatBox(author..": #E0D0B0"..message,getRootElement(),255,255,255,true)
end
-- Convert number from decimal to hexadecimal
function decToHex(num)
return string.format("%02X",num)
end
تنويه ... داري انة من التاج في طريقة يتشغل بدون تكرار مع التاج .؟