Jump to content

مشكله في كود .. تكرير الكلام بالشات


Recommended Posts

السلام عليكم

الكود يكرر الكلام بالشات

  
-- 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 
  
  
  

تنويه ... داري انة من التاج في طريقة يتشغل بدون تكرار مع التاج .؟

Link to comment
اذا تستخدم الفري روم رح ملف

fr_server.lua > ابحث عن > onPlayerChat , وأحذف الكود كامل

حتى انا مركبه ... بس يسوي تكرار وطفيتهه

وشايل الايفنت اللي في الفري روم انا

مدري شالحل :|

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...