Jump to content

مشكلةة[تمت الافادة]


ivor

Recommended Posts

شباب الحين معي مود عند دخول اللاعب الى السيرفر لا يتكلم بالشات الا لما يسجل

ولكن اللاعب يدخل السيرفر ويتكلم عادي وتظهر له الكلمة ويتكلم عادى

هاد الكود

addEventHandler("onPlayerChat", root, 
function ( ) 
    if ( isGuestAccount ( getPlayerAccount ( source ) ) ) then 
    cancelEvent ( ) 
    outputChatBox ( "[Gta-AW] Login First !!", source, 255, 255, 0, true ) 
    end 
end) 
  

لين الحين جالس اعدل عليه مشان يشتغل

ملحوظة سيرفري حرب عصابات

Edited by Guest
Link to comment

مود التاج chat كامل

--***********************************-- 
--***********************************--           --
--***********************************--
--***********************************--
--
outputDebugString("Gta Arab Way Chat System | Started")
--
rRoot = getResourceRootElement(getThisResource())
--
ANTI_FLOOD = true -- Enable anti flood ?.
ANTI_REPEAT = true -- Enable anti repeat ?.
ANTI_FLOOD_TIME = 5 * 1000 -- Anti flood time in miliseconds .
MUTE_PLAYERS = true -- Mute players if they flooded too much ? .
MAX_FLOOD_TIMES = 10 -- Max flood times.
MUTE_TIME = 10 * 60 * 1000 -- Time to mute player if he flooded too much.
ADMIN_SOUND = 1 -- Play sound if admin talked ( set to false to disable ) .
--
lastChatMessage = {}
chatTime = {}
chatTimers = {}
floodTimes = {}
muteTimers = {}
--
TAGS = {
    -- Tag Group | Tag | Tag Message Color | Anti Flood for Group | Play sound on talk | Anti flood time
    {"Console", "#FF0000* #f3f781[Manager]","#81bef7",false,true},
    {"Leader", "#FF0000* #FF0033[Head Admin]","#FFFA54",true,false,9*1000},
    {"Big-Admin", "#FF0000* #FF0033[HeadAdmin]","#FFFA54",true,false,9*1000},
    {"Msabah", "#FF0000* #00C4FF[OwnerTs3]","#FFFA54",true,false,9*1000},
    {"Admin", "#FF0000* #DC143C[Admin]","#FFFA54",true,false,9*1000},
    {"VIP", "#FF0000* #FFCD00[VIP]","#FFFA54",true,false,6*1000},
    {"Support", "#FF0000* #ff00ff[support]","#FFFA54",true,false,6*1000},
    {"LVL1", "#FF0000* #A5A5A5[Arab|1|Com]","#FFFA54",true,false,9*1000},
    {"LVL2", "#FF0000* #A5A5A5[Arab|2|Com]","#FFFA54",true,false,9*1000},
    {"LVL3", "#FF0000* #A5A5A5[Arab|3|Com]","#FFFA54",true,false,9*1000},
    {"LVL4", "#FF0000* #A5A5A5[Arab|4|Com]","#FFFA54",true,false,9*1000},
    {"LVL5", "#FF0000* #A5A5A5[Arab|5|Com]","#FFFA54",true,false,9*1000}
}
--
function logMessage(text,player)
    if text and player then
        text = string.gsub(text, '#%x%x%x%x%x%x', '')
        local log = fileOpen("ChatLog.log") or fileCreate("ChatLog.log")
        --
        if log then
            fileSetPos(log,fileGetSize(log))
            fileWrite(log,"\r\n",text)
            fileFlush(log)
            fileClose(log)
        end
    end
end
--
function isInGroup(p,Group)
    if p and Group then
        local pAcc = getPlayerAccount(p)
        if pAcc and isGuestAccount(pAcc) ~= true then
            --
            local g = aclGetGroup (tostring(Group))
            if not g then return false end
            --
            local pAccName = getAccountName(pAcc)
            if isObjectInACLGroup ("user."..pAccName,g) then
                return true
            else
                return false
            end
            --
        else return false end
    end
end
--
function getFixedName(player)
if isElement(player) then
    local hisName = getPlayerName(player)
    if hisName then
         result = string.gsub(hisName, '#%x%x%x%x%x%x', '')
            if result then
                return result
            end
    end
else
    outputDebugString("ERROR : Bad Player at getFixedName !")
end
end
 
--
function RGBToHex(red, green, blue, alpha)
    if((red < 0 or red > 255 or green < 0 or green > 255 or blue < 0 or blue > 255) or (alpha and (alpha < 0 or alpha > 255))) then
        return nil
    end
    if(alpha) then
        return string.format("#%.2X%.2X%.2X%.2X", red,green,blue,alpha)
    else
        return string.format("#%.2X%.2X%.2X", red,green,blue)
    end
end
--
addEvent("onPlayerChat",true)
addEventHandler("onPlayerChat",root,function ( Text,msgtype )
            cancelEvent()
        if ANTI_FLOOD then
            if getElementData(source,"TagFlood") == true or getElementData(source,"TagFlood") == nil or tonumber(getElementData(source,"TagFlood")) then
                if chatTime[source] then
                    if MUTE_PLAYERS then
                        if tonumber(floodTimes[source]) >= tonumber(MAX_FLOOD_TIMES) then
                            mutePlr(source,msgtype)
                            return
                        end
                    end
                    local time,_,__ = getTimerDetails(chatTimers[source])
                    outputChatBox("Stop spamming chat!, wait "..math.floor(time/1000,2).." seconds.", source, 255, 0, 0)
                    floodTimes[source] = tonumber(floodTimes[source]) + 1
                    cancelEvent()
                    return
                   
                end
                if ANTI_REPEAT and lastChatMessage[source] and lastChatMessage[source] == Text then
                    outputChatBox("Stop repeating yourself!", source, 255, 0, 0)
                    cancelEvent()
                    return
                else
                    lastChatMessage[source] = Text
                end
            end
        end
        msgTag = nil
        for k,v in ipairs ( TAGS ) do
            if not msgTag then
                local Group,Tag,Color,Flood = v[1],v[2],v[3],v[4]
                if isInGroup(source,Group) then
                    msgTag = Tag
                    msgColor = v[3]
                    msgFlood = v[4]
                    msgSound = v[5]
                    msgFloodTime = v[6]
                    setElementData(source,"TagFlood",msgFlood)
                    setElementData(source,"TagSound",msgSound)
                    setElementData(source,"TagFloodTime",msgFloodTime)
                end
                r,g,b = getPlayerNametagColor(source)
                hex = RGBToHex(r,g,b) or "#FFFFFF"
            end
        end
        ---
        local time = getRealTime()
        local second,minute,hour,day,month,year = time.second,time.minute,time.hour,time.monthday ,time.month + 1,time.year + 1900
        if hour <= 0 then x = "AM" else x = "PM" end
        hour = math.floor(hour / 12)  
        if hour == 0 then hour = "12" end
        --
        chatTime[source] = true
        floodTimes[source] = 0
        if getElementData(source,"TagFloodTime") then
            t = getElementData(source,"TagFloodTime")
        else
            t = ANTI_FLOOD_TIME
        end
        chatTimers[source] = setTimer(function(p) chatTime[p] = nil chatTimers[p] = nil end , t , 1 ,source)
        --
        if msgtype == 0 then
            if msgTag then 
                outputChatBox( ""..msgTag.." "..hex..""..getFixedName(source).." "..msgColor..": "..string.gsub(Text, '#%x%x%x%x%x%x', '').."",root,255,0,0,true)
                logMessage( "["..math.floor(hour)..":"..minute..":"..second..""..tostring(x).." "..day.."/"..month.."/"..year.."] "..msgTag.." [ "..getFixedName(source).." ] : "..string.gsub(Text, '#%x%x%x%x%x%x', '').."",source)
                        if ADMIN_SOUND ~= false then
                            if getElementData(source,"TagSound") == true then
                                playSoundFrontEnd(root,tonumber(ADMIN_SOUND))
                            end
                        end        
            else
                setElementData(source,"TagFlood",true)
                setElementData(source,"TagSound",false)
                setElementData(source,"TagFloodTime",nil)
                outputChatBox( ""..hex..""..getFixedName(source).." #FFFFFF: "..string.gsub(Text, '#%x%x%x%x%x%x', '').."",root,255,255,255,true)
                logMessage( "["..math.floor(hour)..":"..minute..":"..second..""..tostring(x).." "..day.."/"..month.."/"..year.."] [ "..getFixedName(source).." ] : "..string.gsub(Text, '#%x%x%x%x%x%x', '').."",source)
            end
        elseif msgtype == 2 then
            for k,v in ipairs ( getElementsByType("player") ) do
                if getPlayerTeam(v) == getPlayerTeam(source) then
                    if msgTag then 
                        outputChatBox( "(Team) "..msgTag.." "..hex..""..getFixedName(source).." "..msgColor..": "..string.gsub(Text, '#%x%x%x%x%x%x', '').."",v,255,0,0,true)
                        if ADMIN_SOUND ~= false then
                            if getElementData(source,"TagSound") == true then
                                playSoundFrontEnd(v,tonumber(ADMIN_SOUND))
                            end
                        end
                    else
                        setElementData(source,"TagFlood",true)
                        setElementData(source,"TagFloodTime",nil)
                        setElementData(source,"TagSound",false)
                        outputChatBox( "(Team) "..hex..""..getFixedName(source).." #FFFFFF: "..string.gsub(Text, '#%x%x%x%x%x%x', '').."",v,255,255,255,true)
                    end
                end
            end 
            if msgTag then 
                logMessage( "["..math.floor(hour)..":"..minute..":"..second..""..tostring(x).." "..day.."/"..month.."/"..year.."] ("..getTeamName(getPlayerTeam(source))..") "..msgTag.." [ "..getFixedName(source).." ] : "..string.gsub(Text, '#%x%x%x%x%x%x', '').."",source)
            else
                logMessage( "["..math.floor(hour)..":"..minute..":"..second..""..tostring(x).." "..day.."/"..month.."/"..year.."] ("..getTeamName(getPlayerTeam(source))..") [ "..getFixedName(source).." ] : "..string.gsub(Text, '#%x%x%x%x%x%x', '').."",source)
            end
        end
end )
 
function mutePlr(p,t)
    if p then
        if isPlayerMuted(p) ~= true then
            if t == 0 then x = "main" elseif t == 2 then x = "team" end
            setPlayerMuted(p,true)
            outputChatBox("* (ANTI FLOOD) #FFFFFF"..string.gsub(getPlayerName(p), '#%x%x%x%x%x%x', '').." #FF0000have been muted for "..math.floor(MUTE_TIME/1000/60).." minutes for flooding "..x.." chat.",root,255,0,0,true)
            muteTimers[p] = setTimer ( function ( p )
                setPlayerMuted(p,false)
                outputChatBox("You have been unmuted, please don't flood the chat again !",p,255,0,0,true)
            end , MUTE_TIME , 1 ,p )
        end
    end
end
--[[
serialMute = {}
addEventHandler("onPlayerQuit",root,function()
    if muteTimers[source] then
        local serial = getPlayerSerial(source)
        local time = getTimerDetails(muteTimers[source])
        serialMute[serial] = time
        killTimer(muteTimers[source])
    end
    --
    lastChatMessage[source] = nil
    chatTime[source] = nil
    chatTimers[source] = nil
    floodTimes[source] = nil
    muteTimers[source] = nil
end )
 
addEventHandler("onPlayerJoin",root,function()
    local serial = getPlayerSerial(source)
    if serialMute[serial] then
        setPlayerMuted(source,true)
        outputChatBox("* (ANTI FLOOD) You have been muted for "..math.floor(serialMute[serial]/1000/60).." minutes for flooding.",source,255,0,0,true)
        muteTimers[p] = setTimer ( function ( source )
            setPlayerMuted(p,false)
            outputChatBox("You have been unmuted, please don't flood the chat again !",p,255,0,0,true)
        end , serialMute[serial] , 1 ,source )
        serialMute[serial] = nil
    end
end )
--]]
 
LOCAL_CHAT = true -- enable local chat
LOCAL_CHAT_DIS = 30 -- Local chat distance
LOCAL_CHAT_FLOOD = 5 * 1000 -- Anti flood time ( set to false to disable )
LC_FLOOD = {}
LC_FLOOD_T = {}
Link to comment

جرب كذا

--***********************************-- 
--***********************************--           --
--***********************************--
--***********************************--
--
outputDebugString("Gta Arab Way Chat System | Started")
--
rRoot = getResourceRootElement(getThisResource())
--
ANTI_FLOOD = true -- Enable anti flood ?.
ANTI_REPEAT = true -- Enable anti repeat ?.
ANTI_FLOOD_TIME = 5 * 1000 -- Anti flood time in miliseconds .
MUTE_PLAYERS = true -- Mute players if they flooded too much ? .
MAX_FLOOD_TIMES = 10 -- Max flood times.
MUTE_TIME = 10 * 60 * 1000 -- Time to mute player if he flooded too much.
ADMIN_SOUND = 1 -- Play sound if admin talked ( set to false to disable ) .
--
lastChatMessage = {}
chatTime = {}
chatTimers = {}
floodTimes = {}
muteTimers = {}
--
TAGS = {
    -- Tag Group | Tag | Tag Message Color | Anti Flood for Group | Play sound on talk | Anti flood time
    {"Console", "#FF0000* #f3f781[Manager]","#81bef7",false,true},
    {"Leader", "#FF0000* #FF0033[Head Admin]","#FFFA54",true,false,9*1000},
    {"Big-Admin", "#FF0000* #FF0033[HeadAdmin]","#FFFA54",true,false,9*1000},
    {"Msabah", "#FF0000* #00C4FF[OwnerTs3]","#FFFA54",true,false,9*1000},
    {"Admin", "#FF0000* #DC143C[Admin]","#FFFA54",true,false,9*1000},
    {"VIP", "#FF0000* #FFCD00[VIP]","#FFFA54",true,false,6*1000},
    {"Support", "#FF0000* #ff00ff[support]","#FFFA54",true,false,6*1000},
    {"LVL1", "#FF0000* #A5A5A5[Arab|1|Com]","#FFFA54",true,false,9*1000},
    {"LVL2", "#FF0000* #A5A5A5[Arab|2|Com]","#FFFA54",true,false,9*1000},
    {"LVL3", "#FF0000* #A5A5A5[Arab|3|Com]","#FFFA54",true,false,9*1000},
    {"LVL4", "#FF0000* #A5A5A5[Arab|4|Com]","#FFFA54",true,false,9*1000},
    {"LVL5", "#FF0000* #A5A5A5[Arab|5|Com]","#FFFA54",true,false,9*1000}
}
--
function logMessage(text,player)
    if text and player then
        text = string.gsub(text, '#%x%x%x%x%x%x', '')
        local log = fileOpen("ChatLog.log") or fileCreate("ChatLog.log")
        --
        if log then
            fileSetPos(log,fileGetSize(log))
            fileWrite(log,"\r\n",text)
            fileFlush(log)
            fileClose(log)
        end
    end
end
--
function isInGroup(p,Group)
    if p and Group then
        local pAcc = getPlayerAccount(p)
        if pAcc and isGuestAccount(pAcc) ~= true then
            --
            local g = aclGetGroup (tostring(Group))
            if not g then return false end
            --
            local pAccName = getAccountName(pAcc)
            if isObjectInACLGroup ("user."..pAccName,g) then
                return true
            else
                return false
            end
            --
        else return false end
    end
end
--
function getFixedName(player)
if isElement(player) then
    local hisName = getPlayerName(player)
    if hisName then
         result = string.gsub(hisName, '#%x%x%x%x%x%x', '')
            if result then
                return result
            end
    end
else
    outputDebugString("ERROR : Bad Player at getFixedName !")
end
end
 
--
function RGBToHex(red, green, blue, alpha)
    if((red < 0 or red > 255 or green < 0 or green > 255 or blue < 0 or blue > 255) or (alpha and (alpha < 0 or alpha > 255))) then
        return nil
    end
    if(alpha) then
        return string.format("#%.2X%.2X%.2X%.2X", red,green,blue,alpha)
    else
        return string.format("#%.2X%.2X%.2X", red,green,blue)
    end
end
--
addEvent("onPlayerChat",true)
addEventHandler("onPlayerChat",root,function ( Text,msgtype )
            cancelEvent()
        if ANTI_FLOOD then
            if getElementData(source,"TagFlood") == true or getElementData(source,"TagFlood") == nil or tonumber(getElementData(source,"TagFlood")) then
                if chatTime[source] then
                    if MUTE_PLAYERS then
                        if tonumber(floodTimes[source]) >= tonumber(MAX_FLOOD_TIMES) then
                            mutePlr(source,msgtype)
                            return
                        end
                    end
                    local time,_,__ = getTimerDetails(chatTimers[source])
                    outputChatBox("Stop spamming chat!, wait "..math.floor(time/1000,2).." seconds.", source, 255, 0, 0)
                    floodTimes[source] = tonumber(floodTimes[source]) + 1
                    cancelEvent()
                    return
                   
                end
                if ANTI_REPEAT and lastChatMessage[source] and lastChatMessage[source] == Text then
                    outputChatBox("Stop repeating yourself!", source, 255, 0, 0)
                    cancelEvent()
                    return
                else
                    lastChatMessage[source] = Text
                end
            end
        end
        msgTag = nil
        for k,v in ipairs ( TAGS ) do
            if not msgTag then
                local Group,Tag,Color,Flood = v[1],v[2],v[3],v[4]
                if isInGroup(source,Group) then
                    msgTag = Tag
                    msgColor = v[3]
                    msgFlood = v[4]
                    msgSound = v[5]
                    msgFloodTime = v[6]
                    setElementData(source,"TagFlood",msgFlood)
                    setElementData(source,"TagSound",msgSound)
                    setElementData(source,"TagFloodTime",msgFloodTime)
                end
                r,g,b = getPlayerNametagColor(source)
                hex = RGBToHex(r,g,b) or "#FFFFFF"
            end
        end
        ---
        local time = getRealTime()
        local second,minute,hour,day,month,year = time.second,time.minute,time.hour,time.monthday ,time.month + 1,time.year + 1900
        if hour <= 0 then x = "AM" else x = "PM" end
        hour = math.floor(hour / 12)  
        if hour == 0 then hour = "12" end
        --
        chatTime[source] = true
        floodTimes[source] = 0
        if getElementData(source,"TagFloodTime") then
            t = getElementData(source,"TagFloodTime")
        else
            t = ANTI_FLOOD_TIME
        end
        chatTimers[source] = setTimer(function(p) chatTime[p] = nil chatTimers[p] = nil end , t , 1 ,source)
        --
        if msgtype == 0 then
            if msgTag then
                outputChatBox( ""..msgTag.." "..hex..""..getFixedName(source).." "..msgColor..": "..string.gsub(Text, '#%x%x%x%x%x%x', '').."",root,255,0,0,true)
                logMessage( "["..math.floor(hour)..":"..minute..":"..second..""..tostring(x).." "..day.."/"..month.."/"..year.."] "..msgTag.." [ "..getFixedName(source).." ] : "..string.gsub(Text, '#%x%x%x%x%x%x', '').."",source)
                        if ADMIN_SOUND ~= false then
                            if getElementData(source,"TagSound") == true then
                                playSoundFrontEnd(root,tonumber(ADMIN_SOUND))
                            end
                        end        
            else
                setElementData(source,"TagFlood",true)
                setElementData(source,"TagSound",false)
                setElementData(source,"TagFloodTime",nil)
                outputChatBox( ""..hex..""..getFixedName(source).." #FFFFFF: "..string.gsub(Text, '#%x%x%x%x%x%x', '').."",root,255,255,255,true)
                logMessage( "["..math.floor(hour)..":"..minute..":"..second..""..tostring(x).." "..day.."/"..month.."/"..year.."] [ "..getFixedName(source).." ] : "..string.gsub(Text, '#%x%x%x%x%x%x', '').."",source)
            end
        elseif msgtype == 2 then
            for k,v in ipairs ( getElementsByType("player") ) do
                if getPlayerTeam(v) == getPlayerTeam(source) then
                    if msgTag then
                        outputChatBox( "(Team) "..msgTag.." "..hex..""..getFixedName(source).." "..msgColor..": "..string.gsub(Text, '#%x%x%x%x%x%x', '').."",v,255,0,0,true)
                        if ADMIN_SOUND ~= false then
                            if getElementData(source,"TagSound") == true then
                                playSoundFrontEnd(v,tonumber(ADMIN_SOUND))
                            end
                        end
                    else
                        setElementData(source,"TagFlood",true)
                        setElementData(source,"TagFloodTime",nil)
                        setElementData(source,"TagSound",false)
                        outputChatBox( "(Team) "..hex..""..getFixedName(source).." #FFFFFF: "..string.gsub(Text, '#%x%x%x%x%x%x', '').."",v,255,255,255,true)
                    end
                end
            end
            if msgTag then
                logMessage( "["..math.floor(hour)..":"..minute..":"..second..""..tostring(x).." "..day.."/"..month.."/"..year.."] ("..getTeamName(getPlayerTeam(source))..") "..msgTag.." [ "..getFixedName(source).." ] : "..string.gsub(Text, '#%x%x%x%x%x%x', '').."",source)
            else
                logMessage( "["..math.floor(hour)..":"..minute..":"..second..""..tostring(x).." "..day.."/"..month.."/"..year.."] ("..getTeamName(getPlayerTeam(source))..") [ "..getFixedName(source).." ] : "..string.gsub(Text, '#%x%x%x%x%x%x', '').."",source)
            end
        end
    if ( isGuestAccount ( getPlayerAccount ( source ) ) ) then
    cancelEvent()
    outputChatBox ( "[Gta-AW] Login First !!", source, 255, 255, 0, true )
    end
end)
 
function mutePlr(p,t)
    if p then
        if isPlayerMuted(p) ~= true then
            if t == 0 then x = "main" elseif t == 2 then x = "team" end
            setPlayerMuted(p,true)
            outputChatBox("* (ANTI FLOOD) #FFFFFF"..string.gsub(getPlayerName(p), '#%x%x%x%x%x%x', '').." #FF0000have been muted for "..math.floor(MUTE_TIME/1000/60).." minutes for flooding "..x.." chat.",root,255,0,0,true)
            muteTimers[p] = setTimer ( function ( p )
                setPlayerMuted(p,false)
                outputChatBox("You have been unmuted, please don't flood the chat again !",p,255,0,0,true)
            end , MUTE_TIME , 1 ,p )
        end
    end
end
--[[
serialMute = {}
addEventHandler("onPlayerQuit",root,function()
    if muteTimers[source] then
        local serial = getPlayerSerial(source)
        local time = getTimerDetails(muteTimers[source])
        serialMute[serial] = time
        killTimer(muteTimers[source])
    end
    --
    lastChatMessage[source] = nil
    chatTime[source] = nil
    chatTimers[source] = nil
    floodTimes[source] = nil
    muteTimers[source] = nil
end )
 
addEventHandler("onPlayerJoin",root,function()
    local serial = getPlayerSerial(source)
    if serialMute[serial] then
        setPlayerMuted(source,true)
        outputChatBox("* (ANTI FLOOD) You have been muted for "..math.floor(serialMute[serial]/1000/60).." minutes for flooding.",source,255,0,0,true)
        muteTimers[p] = setTimer ( function ( source )
            setPlayerMuted(p,false)
            outputChatBox("You have been unmuted, please don't flood the chat again !",p,255,0,0,true)
        end , serialMute[serial] , 1 ,source )
        serialMute[serial] = nil
    end
end )
--]]
 
LOCAL_CHAT = true -- enable local chat
LOCAL_CHAT_DIS =
Link to comment

جرب كذا

--***********************************-- 
--***********************************--           --
--***********************************--
--***********************************--
--
outputDebugString("Gta Arab Way Chat System | Started")
--
rRoot = getResourceRootElement(getThisResource())
--
ANTI_FLOOD = true -- Enable anti flood ?.
ANTI_REPEAT = true -- Enable anti repeat ?.
ANTI_FLOOD_TIME = 5 * 1000 -- Anti flood time in miliseconds .
MUTE_PLAYERS = true -- Mute players if they flooded too much ? .
MAX_FLOOD_TIMES = 10 -- Max flood times.
MUTE_TIME = 10 * 60 * 1000 -- Time to mute player if he flooded too much.
ADMIN_SOUND = 1 -- Play sound if admin talked ( set to false to disable ) .
--
lastChatMessage = {}
chatTime = {}
chatTimers = {}
floodTimes = {}
muteTimers = {}
--
TAGS = {
    -- Tag Group | Tag | Tag Message Color | Anti Flood for Group | Play sound on talk | Anti flood time
    {"Console", "#FF0000* #f3f781[Manager]","#81bef7",false,true},
    {"Leader", "#FF0000* #FF0033[Head Admin]","#FFFA54",true,false,9*1000},
    {"Big-Admin", "#FF0000* #FF0033[HeadAdmin]","#FFFA54",true,false,9*1000},
    {"Msabah", "#FF0000* #00C4FF[OwnerTs3]","#FFFA54",true,false,9*1000},
    {"Admin", "#FF0000* #DC143C[Admin]","#FFFA54",true,false,9*1000},
    {"VIP", "#FF0000* #FFCD00[VIP]","#FFFA54",true,false,6*1000},
    {"Support", "#FF0000* #ff00ff[support]","#FFFA54",true,false,6*1000},
    {"LVL1", "#FF0000* #A5A5A5[Arab|1|Com]","#FFFA54",true,false,9*1000},
    {"LVL2", "#FF0000* #A5A5A5[Arab|2|Com]","#FFFA54",true,false,9*1000},
    {"LVL3", "#FF0000* #A5A5A5[Arab|3|Com]","#FFFA54",true,false,9*1000},
    {"LVL4", "#FF0000* #A5A5A5[Arab|4|Com]","#FFFA54",true,false,9*1000},
    {"LVL5", "#FF0000* #A5A5A5[Arab|5|Com]","#FFFA54",true,false,9*1000}
}
--
function logMessage(text,player)
    if text and player then
        text = string.gsub(text, '#%x%x%x%x%x%x', '')
        local log = fileOpen("ChatLog.log") or fileCreate("ChatLog.log")
        --
        if log then
            fileSetPos(log,fileGetSize(log))
            fileWrite(log,"\r\n",text)
            fileFlush(log)
            fileClose(log)
        end
    end
end
--
function isInGroup(p,Group)
    if p and Group then
        local pAcc = getPlayerAccount(p)
        if pAcc and isGuestAccount(pAcc) ~= true then
            --
            local g = aclGetGroup (tostring(Group))
            if not g then return false end
            --
            local pAccName = getAccountName(pAcc)
            if isObjectInACLGroup ("user."..pAccName,g) then
                return true
            else
                return false
            end
            --
        else return false end
    end
end
--
function getFixedName(player)
if isElement(player) then
    local hisName = getPlayerName(player)
    if hisName then
         result = string.gsub(hisName, '#%x%x%x%x%x%x', '')
            if result then
                return result
            end
    end
else
    outputDebugString("ERROR : Bad Player at getFixedName !")
end
end
 
--
function RGBToHex(red, green, blue, alpha)
    if((red < 0 or red > 255 or green < 0 or green > 255 or blue < 0 or blue > 255) or (alpha and (alpha < 0 or alpha > 255))) then
        return nil
    end
    if(alpha) then
        return string.format("#%.2X%.2X%.2X%.2X", red,green,blue,alpha)
    else
        return string.format("#%.2X%.2X%.2X", red,green,blue)
    end
end
--
addEvent("onPlayerChat",true)
addEventHandler("onPlayerChat",root,function ( Text,msgtype )
            cancelEvent()
        if ANTI_FLOOD then
            if getElementData(source,"TagFlood") == true or getElementData(source,"TagFlood") == nil or tonumber(getElementData(source,"TagFlood")) then
                if chatTime[source] then
                    if MUTE_PLAYERS then
                        if tonumber(floodTimes[source]) >= tonumber(MAX_FLOOD_TIMES) then
                            mutePlr(source,msgtype)
                            return
                        end
                    end
                    local time,_,__ = getTimerDetails(chatTimers[source])
                    outputChatBox("Stop spamming chat!, wait "..math.floor(time/1000,2).." seconds.", source, 255, 0, 0)
                    floodTimes[source] = tonumber(floodTimes[source]) + 1
                    cancelEvent()
                    return
                   
                end
                if ANTI_REPEAT and lastChatMessage[source] and lastChatMessage[source] == Text then
                    outputChatBox("Stop repeating yourself!", source, 255, 0, 0)
                    cancelEvent()
                    return
                else
                    lastChatMessage[source] = Text
                end
            end
        end
        msgTag = nil
        for k,v in ipairs ( TAGS ) do
            if not msgTag then
                local Group,Tag,Color,Flood = v[1],v[2],v[3],v[4]
                if isInGroup(source,Group) then
                    msgTag = Tag
                    msgColor = v[3]
                    msgFlood = v[4]
                    msgSound = v[5]
                    msgFloodTime = v[6]
                    setElementData(source,"TagFlood",msgFlood)
                    setElementData(source,"TagSound",msgSound)
                    setElementData(source,"TagFloodTime",msgFloodTime)
                end
                r,g,b = getPlayerNametagColor(source)
                hex = RGBToHex(r,g,b) or "#FFFFFF"
            end
        end
        ---
        local time = getRealTime()
        local second,minute,hour,day,month,year = time.second,time.minute,time.hour,time.monthday ,time.month + 1,time.year + 1900
        if hour <= 0 then x = "AM" else x = "PM" end
        hour = math.floor(hour / 12)  
        if hour == 0 then hour = "12" end
        --
        chatTime[source] = true
        floodTimes[source] = 0
        if getElementData(source,"TagFloodTime") then
            t = getElementData(source,"TagFloodTime")
        else
            t = ANTI_FLOOD_TIME
        end
        chatTimers[source] = setTimer(function(p) chatTime[p] = nil chatTimers[p] = nil end , t , 1 ,source)
        --
        if msgtype == 0 then
            if msgTag then
                outputChatBox( ""..msgTag.." "..hex..""..getFixedName(source).." "..msgColor..": "..string.gsub(Text, '#%x%x%x%x%x%x', '').."",root,255,0,0,true)
                logMessage( "["..math.floor(hour)..":"..minute..":"..second..""..tostring(x).." "..day.."/"..month.."/"..year.."] "..msgTag.." [ "..getFixedName(source).." ] : "..string.gsub(Text, '#%x%x%x%x%x%x', '').."",source)
                        if ADMIN_SOUND ~= false then
                            if getElementData(source,"TagSound") == true then
                                playSoundFrontEnd(root,tonumber(ADMIN_SOUND))
                            end
                        end        
            else
                setElementData(source,"TagFlood",true)
                setElementData(source,"TagSound",false)
                setElementData(source,"TagFloodTime",nil)
                outputChatBox( ""..hex..""..getFixedName(source).." #FFFFFF: "..string.gsub(Text, '#%x%x%x%x%x%x', '').."",root,255,255,255,true)
                logMessage( "["..math.floor(hour)..":"..minute..":"..second..""..tostring(x).." "..day.."/"..month.."/"..year.."] [ "..getFixedName(source).." ] : "..string.gsub(Text, '#%x%x%x%x%x%x', '').."",source)
            end
        elseif msgtype == 2 then
            for k,v in ipairs ( getElementsByType("player") ) do
                if getPlayerTeam(v) == getPlayerTeam(source) then
                    if msgTag then
                        outputChatBox( "(Team) "..msgTag.." "..hex..""..getFixedName(source).." "..msgColor..": "..string.gsub(Text, '#%x%x%x%x%x%x', '').."",v,255,0,0,true)
                        if ADMIN_SOUND ~= false then
                            if getElementData(source,"TagSound") == true then
                                playSoundFrontEnd(v,tonumber(ADMIN_SOUND))
                            end
                        end
                    else
                        setElementData(source,"TagFlood",true)
                        setElementData(source,"TagFloodTime",nil)
                        setElementData(source,"TagSound",false)
                        outputChatBox( "(Team) "..hex..""..getFixedName(source).." #FFFFFF: "..string.gsub(Text, '#%x%x%x%x%x%x', '').."",v,255,255,255,true)
                    end
                end
            end
            if msgTag then
                logMessage( "["..math.floor(hour)..":"..minute..":"..second..""..tostring(x).." "..day.."/"..month.."/"..year.."] ("..getTeamName(getPlayerTeam(source))..") "..msgTag.." [ "..getFixedName(source).." ] : "..string.gsub(Text, '#%x%x%x%x%x%x', '').."",source)
            else
                logMessage( "["..math.floor(hour)..":"..minute..":"..second..""..tostring(x).." "..day.."/"..month.."/"..year.."] ("..getTeamName(getPlayerTeam(source))..") [ "..getFixedName(source).." ] : "..string.gsub(Text, '#%x%x%x%x%x%x', '').."",source)
            end
        end
    if ( isGuestAccount ( getPlayerAccount ( source ) ) ) then
    cancelEvent()
    outputChatBox ( "[Gta-AW] Login First !!", source, 255, 255, 0, true )
    end
end)
 
function mutePlr(p,t)
    if p then
        if isPlayerMuted(p) ~= true then
            if t == 0 then x = "main" elseif t == 2 then x = "team" end
            setPlayerMuted(p,true)
            outputChatBox("* (ANTI FLOOD) #FFFFFF"..string.gsub(getPlayerName(p), '#%x%x%x%x%x%x', '').." #FF0000have been muted for "..math.floor(MUTE_TIME/1000/60).." minutes for flooding "..x.." chat.",root,255,0,0,true)
            muteTimers[p] = setTimer ( function ( p )
                setPlayerMuted(p,false)
                outputChatBox("You have been unmuted, please don't flood the chat again !",p,255,0,0,true)
            end , MUTE_TIME , 1 ,p )
        end
    end
end
--[[
serialMute = {}
addEventHandler("onPlayerQuit",root,function()
    if muteTimers[source] then
        local serial = getPlayerSerial(source)
        local time = getTimerDetails(muteTimers[source])
        serialMute[serial] = time
        killTimer(muteTimers[source])
    end
    --
    lastChatMessage[source] = nil
    chatTime[source] = nil
    chatTimers[source] = nil
    floodTimes[source] = nil
    muteTimers[source] = nil
end )
 
addEventHandler("onPlayerJoin",root,function()
    local serial = getPlayerSerial(source)
    if serialMute[serial] then
        setPlayerMuted(source,true)
        outputChatBox("* (ANTI FLOOD) You have been muted for "..math.floor(serialMute[serial]/1000/60).." minutes for flooding.",source,255,0,0,true)
        muteTimers[p] = setTimer ( function ( source )
            setPlayerMuted(p,false)
            outputChatBox("You have been unmuted, please don't flood the chat again !",p,255,0,0,true)
        end , serialMute[serial] , 1 ,source )
        serialMute[serial] = nil
    end
end )
--]]
 
Link to comment

جرب :

--***********************************-- 
--***********************************--           --
--***********************************--
--***********************************--
--
outputDebugString("Gta Arab Way Chat System | Started")
--
rRoot = getResourceRootElement(getThisResource())
--
ANTI_FLOOD = true -- Enable anti flood ?.
ANTI_REPEAT = true -- Enable anti repeat ?.
ANTI_FLOOD_TIME = 5 * 1000 -- Anti flood time in miliseconds .
MUTE_PLAYERS = true -- Mute players if they flooded too much ? .
MAX_FLOOD_TIMES = 10 -- Max flood times.
MUTE_TIME = 10 * 60 * 1000 -- Time to mute player if he flooded too much.
ADMIN_SOUND = 1 -- Play sound if admin talked ( set to false to disable ) .
--
lastChatMessage = {}
chatTime = {}
chatTimers = {}
floodTimes = {}
muteTimers = {}
--
TAGS = {
    -- Tag Group | Tag | Tag Message Color | Anti Flood for Group | Play sound on talk | Anti flood time
    {"Console", "#FF0000* #f3f781[Manager]","#81bef7",false,true},
    {"Leader", "#FF0000* #FF0033[Head Admin]","#FFFA54",true,false,9*1000},
    {"Big-Admin", "#FF0000* #FF0033[HeadAdmin]","#FFFA54",true,false,9*1000},
    {"Msabah", "#FF0000* #00C4FF[OwnerTs3]","#FFFA54",true,false,9*1000},
    {"Admin", "#FF0000* #DC143C[Admin]","#FFFA54",true,false,9*1000},
    {"VIP", "#FF0000* #FFCD00[VIP]","#FFFA54",true,false,6*1000},
    {"Support", "#FF0000* #ff00ff[support]","#FFFA54",true,false,6*1000},
    {"LVL1", "#FF0000* #A5A5A5[Arab|1|Com]","#FFFA54",true,false,9*1000},
    {"LVL2", "#FF0000* #A5A5A5[Arab|2|Com]","#FFFA54",true,false,9*1000},
    {"LVL3", "#FF0000* #A5A5A5[Arab|3|Com]","#FFFA54",true,false,9*1000},
    {"LVL4", "#FF0000* #A5A5A5[Arab|4|Com]","#FFFA54",true,false,9*1000},
    {"LVL5", "#FF0000* #A5A5A5[Arab|5|Com]","#FFFA54",true,false,9*1000}
}
--
function logMessage(text,player)
    if text and player then
        text = string.gsub(text, '#%x%x%x%x%x%x', '')
        local log = fileOpen("ChatLog.log") or fileCreate("ChatLog.log")
        --
        if log then
            fileSetPos(log,fileGetSize(log))
            fileWrite(log,"\r\n",text)
            fileFlush(log)
            fileClose(log)
        end
    end
end
--
function isInGroup(p,Group)
    if p and Group then
        local pAcc = getPlayerAccount(p)
        if pAcc and isGuestAccount(pAcc) ~= true then
            --
            local g = aclGetGroup (tostring(Group))
            if not g then return false end
            --
            local pAccName = getAccountName(pAcc)
            if isObjectInACLGroup ("user."..pAccName,g) then
                return true
            else
                return false
            end
            --
        else return false end
    end
end
--
function getFixedName(player)
if isElement(player) then
    local hisName = getPlayerName(player)
    if hisName then
         result = string.gsub(hisName, '#%x%x%x%x%x%x', '')
            if result then
                return result
            end
    end
else
    outputDebugString("ERROR : Bad Player at getFixedName !")
end
end
 
--
function RGBToHex(red, green, blue, alpha)
    if((red < 0 or red > 255 or green < 0 or green > 255 or blue < 0 or blue > 255) or (alpha and (alpha < 0 or alpha > 255))) then
        return nil
    end
    if(alpha) then
        return string.format("#%.2X%.2X%.2X%.2X", red,green,blue,alpha)
    else
        return string.format("#%.2X%.2X%.2X", red,green,blue)
    end
end
--
addEvent("onPlayerChat",true)
addEventHandler("onPlayerChat",root,function ( Text,msgtype )
   if ( isGuestAccount ( getPlayerAccount ( source ) ) ) then
        cancelEvent()
        return outputChatBox ( "[Gta-AW] Login First !!", source, 255, 255, 0, true )
   end
            cancelEvent()
        if ANTI_FLOOD then
            if getElementData(source,"TagFlood") == true or getElementData(source,"TagFlood") == nil or tonumber(getElementData(source,"TagFlood")) then
                if chatTime[source] then
                    if MUTE_PLAYERS then
                        if tonumber(floodTimes[source]) >= tonumber(MAX_FLOOD_TIMES) then
                            mutePlr(source,msgtype)
                            return
                        end
                    end
                    local time,_,__ = getTimerDetails(chatTimers[source])
                    outputChatBox("Stop spamming chat!, wait "..math.floor(time/1000,2).." seconds.", source, 255, 0, 0)
                    floodTimes[source] = tonumber(floodTimes[source]) + 1
                    cancelEvent()
                    return
                   
                end
                if ANTI_REPEAT and lastChatMessage[source] and lastChatMessage[source] == Text then
                    outputChatBox("Stop repeating yourself!", source, 255, 0, 0)
                    cancelEvent()
                    return
                else
                    lastChatMessage[source] = Text
                end
            end
        end
        msgTag = nil
        for k,v in ipairs ( TAGS ) do
            if not msgTag then
                local Group,Tag,Color,Flood = v[1],v[2],v[3],v[4]
                if isInGroup(source,Group) then
                    msgTag = Tag
                    msgColor = v[3]
                    msgFlood = v[4]
                    msgSound = v[5]
                    msgFloodTime = v[6]
                    setElementData(source,"TagFlood",msgFlood)
                    setElementData(source,"TagSound",msgSound)
                    setElementData(source,"TagFloodTime",msgFloodTime)
                end
                r,g,b = getPlayerNametagColor(source)
                hex = RGBToHex(r,g,b) or "#FFFFFF"
            end
        end
        ---
        local time = getRealTime()
        local second,minute,hour,day,month,year = time.second,time.minute,time.hour,time.monthday ,time.month + 1,time.year + 1900
        if hour <= 0 then x = "AM" else x = "PM" end
        hour = math.floor(hour / 12)  
        if hour == 0 then hour = "12" end
        --
        chatTime[source] = true
        floodTimes[source] = 0
        if getElementData(source,"TagFloodTime") then
            t = getElementData(source,"TagFloodTime")
        else
            t = ANTI_FLOOD_TIME
        end
        chatTimers[source] = setTimer(function(p) chatTime[p] = nil chatTimers[p] = nil end , t , 1 ,source)
        --
        if msgtype == 0 then
            if msgTag then
                outputChatBox( ""..msgTag.." "..hex..""..getFixedName(source).." "..msgColor..": "..string.gsub(Text, '#%x%x%x%x%x%x', '').."",root,255,0,0,true)
                logMessage( "["..math.floor(hour)..":"..minute..":"..second..""..tostring(x).." "..day.."/"..month.."/"..year.."] "..msgTag.." [ "..getFixedName(source).." ] : "..string.gsub(Text, '#%x%x%x%x%x%x', '').."",source)
                        if ADMIN_SOUND ~= false then
                            if getElementData(source,"TagSound") == true then
                                playSoundFrontEnd(root,tonumber(ADMIN_SOUND))
                            end
                        end        
            else
                setElementData(source,"TagFlood",true)
                setElementData(source,"TagSound",false)
                setElementData(source,"TagFloodTime",nil)
                outputChatBox( ""..hex..""..getFixedName(source).." #FFFFFF: "..string.gsub(Text, '#%x%x%x%x%x%x', '').."",root,255,255,255,true)
                logMessage( "["..math.floor(hour)..":"..minute..":"..second..""..tostring(x).." "..day.."/"..month.."/"..year.."] [ "..getFixedName(source).." ] : "..string.gsub(Text, '#%x%x%x%x%x%x', '').."",source)
            end
        elseif msgtype == 2 then
            for k,v in ipairs ( getElementsByType("player") ) do
                if getPlayerTeam(v) == getPlayerTeam(source) then
                    if msgTag then
                        outputChatBox( "(Team) "..msgTag.." "..hex..""..getFixedName(source).." "..msgColor..": "..string.gsub(Text, '#%x%x%x%x%x%x', '').."",v,255,0,0,true)
                        if ADMIN_SOUND ~= false then
                            if getElementData(source,"TagSound") == true then
                                playSoundFrontEnd(v,tonumber(ADMIN_SOUND))
                            end
                        end
                    else
                        setElementData(source,"TagFlood",true)
                        setElementData(source,"TagFloodTime",nil)
                        setElementData(source,"TagSound",false)
                        outputChatBox( "(Team) "..hex..""..getFixedName(source).." #FFFFFF: "..string.gsub(Text, '#%x%x%x%x%x%x', '').."",v,255,255,255,true)
                    end
                end
            end
            if msgTag then
                logMessage( "["..math.floor(hour)..":"..minute..":"..second..""..tostring(x).." "..day.."/"..month.."/"..year.."] ("..getTeamName(getPlayerTeam(source))..") "..msgTag.." [ "..getFixedName(source).." ] : "..string.gsub(Text, '#%x%x%x%x%x%x', '').."",source)
            else
                logMessage( "["..math.floor(hour)..":"..minute..":"..second..""..tostring(x).." "..day.."/"..month.."/"..year.."] ("..getTeamName(getPlayerTeam(source))..") [ "..getFixedName(source).." ] : "..string.gsub(Text, '#%x%x%x%x%x%x', '').."",source)
            end
        end
end )
 
function mutePlr(p,t)
    if p then
        if isPlayerMuted(p) ~= true then
            if t == 0 then x = "main" elseif t == 2 then x = "team" end
            setPlayerMuted(p,true)
            outputChatBox("* (ANTI FLOOD) #FFFFFF"..string.gsub(getPlayerName(p), '#%x%x%x%x%x%x', '').." #FF0000have been muted for "..math.floor(MUTE_TIME/1000/60).." minutes for flooding "..x.." chat.",root,255,0,0,true)
            muteTimers[p] = setTimer ( function ( p )
                setPlayerMuted(p,false)
                outputChatBox("You have been unmuted, please don't flood the chat again !",p,255,0,0,true)
            end , MUTE_TIME , 1 ,p )
        end
    end
end
--[[
serialMute = {}
addEventHandler("onPlayerQuit",root,function()
    if muteTimers[source] then
        local serial = getPlayerSerial(source)
        local time = getTimerDetails(muteTimers[source])
        serialMute[serial] = time
        killTimer(muteTimers[source])
    end
    --
    lastChatMessage[source] = nil
    chatTime[source] = nil
    chatTimers[source] = nil
    floodTimes[source] = nil
    muteTimers[source] = nil
end )
 
addEventHandler("onPlayerJoin",root,function()
    local serial = getPlayerSerial(source)
    if serialMute[serial] then
        setPlayerMuted(source,true)
        outputChatBox("* (ANTI FLOOD) You have been muted for "..math.floor(serialMute[serial]/1000/60).." minutes for flooding.",source,255,0,0,true)
        muteTimers[p] = setTimer ( function ( source )
            setPlayerMuted(p,false)
            outputChatBox("You have been unmuted, please don't flood the chat again !",p,255,0,0,true)
        end , serialMute[serial] , 1 ,source )
        serialMute[serial] = nil
    end
end )
--]]
 
LOCAL_CHAT = true -- enable local chat
LOCAL_CHAT_DIS =
Link to comment
جرب :
--***********************************-- 
--***********************************--           --
--***********************************--
--***********************************--
--
outputDebugString("Gta Arab Way Chat System | Started")
--
rRoot = getResourceRootElement(getThisResource())
--
ANTI_FLOOD = true -- Enable anti flood ?.
ANTI_REPEAT = true -- Enable anti repeat ?.
ANTI_FLOOD_TIME = 5 * 1000 -- Anti flood time in miliseconds .
MUTE_PLAYERS = true -- Mute players if they flooded too much ? .
MAX_FLOOD_TIMES = 10 -- Max flood times.
MUTE_TIME = 10 * 60 * 1000 -- Time to mute player if he flooded too much.
ADMIN_SOUND = 1 -- Play sound if admin talked ( set to false to disable ) .
--
lastChatMessage = {}
chatTime = {}
chatTimers = {}
floodTimes = {}
muteTimers = {}
--
TAGS = {
    -- Tag Group | Tag | Tag Message Color | Anti Flood for Group | Play sound on talk | Anti flood time
    {"Console", "#FF0000* #f3f781[Manager]","#81bef7",false,true},
    {"Leader", "#FF0000* #FF0033[Head Admin]","#FFFA54",true,false,9*1000},
    {"Big-Admin", "#FF0000* #FF0033[HeadAdmin]","#FFFA54",true,false,9*1000},
    {"Msabah", "#FF0000* #00C4FF[OwnerTs3]","#FFFA54",true,false,9*1000},
    {"Admin", "#FF0000* #DC143C[Admin]","#FFFA54",true,false,9*1000},
    {"VIP", "#FF0000* #FFCD00[VIP]","#FFFA54",true,false,6*1000},
    {"Support", "#FF0000* #ff00ff[support]","#FFFA54",true,false,6*1000},
    {"LVL1", "#FF0000* #A5A5A5[Arab|1|Com]","#FFFA54",true,false,9*1000},
    {"LVL2", "#FF0000* #A5A5A5[Arab|2|Com]","#FFFA54",true,false,9*1000},
    {"LVL3", "#FF0000* #A5A5A5[Arab|3|Com]","#FFFA54",true,false,9*1000},
    {"LVL4", "#FF0000* #A5A5A5[Arab|4|Com]","#FFFA54",true,false,9*1000},
    {"LVL5", "#FF0000* #A5A5A5[Arab|5|Com]","#FFFA54",true,false,9*1000}
}
--
function logMessage(text,player)
    if text and player then
        text = string.gsub(text, '#%x%x%x%x%x%x', '')
        local log = fileOpen("ChatLog.log") or fileCreate("ChatLog.log")
        --
        if log then
            fileSetPos(log,fileGetSize(log))
            fileWrite(log,"\r\n",text)
            fileFlush(log)
            fileClose(log)
        end
    end
end
--
function isInGroup(p,Group)
    if p and Group then
        local pAcc = getPlayerAccount(p)
        if pAcc and isGuestAccount(pAcc) ~= true then
            --
            local g = aclGetGroup (tostring(Group))
            if not g then return false end
            --
            local pAccName = getAccountName(pAcc)
            if isObjectInACLGroup ("user."..pAccName,g) then
                return true
            else
                return false
            end
            --
        else return false end
    end
end
--
function getFixedName(player)
if isElement(player) then
    local hisName = getPlayerName(player)
    if hisName then
         result = string.gsub(hisName, '#%x%x%x%x%x%x', '')
            if result then
                return result
            end
    end
else
    outputDebugString("ERROR : Bad Player at getFixedName !")
end
end
 
--
function RGBToHex(red, green, blue, alpha)
    if((red < 0 or red > 255 or green < 0 or green > 255 or blue < 0 or blue > 255) or (alpha and (alpha < 0 or alpha > 255))) then
        return nil
    end
    if(alpha) then
        return string.format("#%.2X%.2X%.2X%.2X", red,green,blue,alpha)
    else
        return string.format("#%.2X%.2X%.2X", red,green,blue)
    end
end
--
addEvent("onPlayerChat",true)
addEventHandler("onPlayerChat",root,function ( Text,msgtype )
   if ( isGuestAccount ( getPlayerAccount ( source ) ) ) then
        cancelEvent()
        return outputChatBox ( "[Gta-AW] Login First !!", source, 255, 255, 0, true )
   end
            cancelEvent()
        if ANTI_FLOOD then
            if getElementData(source,"TagFlood") == true or getElementData(source,"TagFlood") == nil or tonumber(getElementData(source,"TagFlood")) then
                if chatTime[source] then
                    if MUTE_PLAYERS then
                        if tonumber(floodTimes[source]) >= tonumber(MAX_FLOOD_TIMES) then
                            mutePlr(source,msgtype)
                            return
                        end
                    end
                    local time,_,__ = getTimerDetails(chatTimers[source])
                    outputChatBox("Stop spamming chat!, wait "..math.floor(time/1000,2).." seconds.", source, 255, 0, 0)
                    floodTimes[source] = tonumber(floodTimes[source]) + 1
                    cancelEvent()
                    return
                   
                end
                if ANTI_REPEAT and lastChatMessage[source] and lastChatMessage[source] == Text then
                    outputChatBox("Stop repeating yourself!", source, 255, 0, 0)
                    cancelEvent()
                    return
                else
                    lastChatMessage[source] = Text
                end
            end
        end
        msgTag = nil
        for k,v in ipairs ( TAGS ) do
            if not msgTag then
                local Group,Tag,Color,Flood = v[1],v[2],v[3],v[4]
                if isInGroup(source,Group) then
                    msgTag = Tag
                    msgColor = v[3]
                    msgFlood = v[4]
                    msgSound = v[5]
                    msgFloodTime = v[6]
                    setElementData(source,"TagFlood",msgFlood)
                    setElementData(source,"TagSound",msgSound)
                    setElementData(source,"TagFloodTime",msgFloodTime)
                end
                r,g,b = getPlayerNametagColor(source)
                hex = RGBToHex(r,g,b) or "#FFFFFF"
            end
        end
        ---
        local time = getRealTime()
        local second,minute,hour,day,month,year = time.second,time.minute,time.hour,time.monthday ,time.month + 1,time.year + 1900
        if hour <= 0 then x = "AM" else x = "PM" end
        hour = math.floor(hour / 12)  
        if hour == 0 then hour = "12" end
        --
        chatTime[source] = true
        floodTimes[source] = 0
        if getElementData(source,"TagFloodTime") then
            t = getElementData(source,"TagFloodTime")
        else
            t = ANTI_FLOOD_TIME
        end
        chatTimers[source] = setTimer(function(p) chatTime[p] = nil chatTimers[p] = nil end , t , 1 ,source)
        --
        if msgtype == 0 then
            if msgTag then
                outputChatBox( ""..msgTag.." "..hex..""..getFixedName(source).." "..msgColor..": "..string.gsub(Text, '#%x%x%x%x%x%x', '').."",root,255,0,0,true)
                logMessage( "["..math.floor(hour)..":"..minute..":"..second..""..tostring(x).." "..day.."/"..month.."/"..year.."] "..msgTag.." [ "..getFixedName(source).." ] : "..string.gsub(Text, '#%x%x%x%x%x%x', '').."",source)
                        if ADMIN_SOUND ~= false then
                            if getElementData(source,"TagSound") == true then
                                playSoundFrontEnd(root,tonumber(ADMIN_SOUND))
                            end
                        end        
            else
                setElementData(source,"TagFlood",true)
                setElementData(source,"TagSound",false)
                setElementData(source,"TagFloodTime",nil)
                outputChatBox( ""..hex..""..getFixedName(source).." #FFFFFF: "..string.gsub(Text, '#%x%x%x%x%x%x', '').."",root,255,255,255,true)
                logMessage( "["..math.floor(hour)..":"..minute..":"..second..""..tostring(x).." "..day.."/"..month.."/"..year.."] [ "..getFixedName(source).." ] : "..string.gsub(Text, '#%x%x%x%x%x%x', '').."",source)
            end
        elseif msgtype == 2 then
            for k,v in ipairs ( getElementsByType("player") ) do
                if getPlayerTeam(v) == getPlayerTeam(source) then
                    if msgTag then
                        outputChatBox( "(Team) "..msgTag.." "..hex..""..getFixedName(source).." "..msgColor..": "..string.gsub(Text, '#%x%x%x%x%x%x', '').."",v,255,0,0,true)
                        if ADMIN_SOUND ~= false then
                            if getElementData(source,"TagSound") == true then
                                playSoundFrontEnd(v,tonumber(ADMIN_SOUND))
                            end
                        end
                    else
                        setElementData(source,"TagFlood",true)
                        setElementData(source,"TagFloodTime",nil)
                        setElementData(source,"TagSound",false)
                        outputChatBox( "(Team) "..hex..""..getFixedName(source).." #FFFFFF: "..string.gsub(Text, '#%x%x%x%x%x%x', '').."",v,255,255,255,true)
                    end
                end
            end
            if msgTag then
                logMessage( "["..math.floor(hour)..":"..minute..":"..second..""..tostring(x).." "..day.."/"..month.."/"..year.."] ("..getTeamName(getPlayerTeam(source))..") "..msgTag.." [ "..getFixedName(source).." ] : "..string.gsub(Text, '#%x%x%x%x%x%x', '').."",source)
            else
                logMessage( "["..math.floor(hour)..":"..minute..":"..second..""..tostring(x).." "..day.."/"..month.."/"..year.."] ("..getTeamName(getPlayerTeam(source))..") [ "..getFixedName(source).." ] : "..string.gsub(Text, '#%x%x%x%x%x%x', '').."",source)
            end
        end
end )
 
function mutePlr(p,t)
    if p then
        if isPlayerMuted(p) ~= true then
            if t == 0 then x = "main" elseif t == 2 then x = "team" end
            setPlayerMuted(p,true)
            outputChatBox("* (ANTI FLOOD) #FFFFFF"..string.gsub(getPlayerName(p), '#%x%x%x%x%x%x', '').." #FF0000have been muted for "..math.floor(MUTE_TIME/1000/60).." minutes for flooding "..x.." chat.",root,255,0,0,true)
            muteTimers[p] = setTimer ( function ( p )
                setPlayerMuted(p,false)
                outputChatBox("You have been unmuted, please don't flood the chat again !",p,255,0,0,true)
            end , MUTE_TIME , 1 ,p )
        end
    end
end
--[[
serialMute = {}
addEventHandler("onPlayerQuit",root,function()
    if muteTimers[source] then
        local serial = getPlayerSerial(source)
        local time = getTimerDetails(muteTimers[source])
        serialMute[serial] = time
        killTimer(muteTimers[source])
    end
    --
    lastChatMessage[source] = nil
    chatTime[source] = nil
    chatTimers[source] = nil
    floodTimes[source] = nil
    muteTimers[source] = nil
end )
 
addEventHandler("onPlayerJoin",root,function()
    local serial = getPlayerSerial(source)
    if serialMute[serial] then
        setPlayerMuted(source,true)
        outputChatBox("* (ANTI FLOOD) You have been muted for "..math.floor(serialMute[serial]/1000/60).." minutes for flooding.",source,255,0,0,true)
        muteTimers[p] = setTimer ( function ( source )
            setPlayerMuted(p,false)
            outputChatBox("You have been unmuted, please don't flood the chat again !",p,255,0,0,true)
        end , serialMute[serial] , 1 ,source )
        serialMute[serial] = nil
    end
end )
--]]
 
Link to comment
اخوي لو ابيه يخرج بالشات اسم اللاعب كذا بالمود يعنى

احط كذا ؟

return outputChatBox ( "[Gta-AW] Login First " ..getPlayerName.. " To Type In Chat ", 255, 255, 0, true )

return outputChatBox ( "[Gta-AW] Login First " ..getPlayerName(source).. " To Type In Chat ", source, 255, 255, 0, true ) 
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...