Jump to content

Two Script together


Recommended Posts

Hy, please help me :)

I use "tagflood" script and I want to build another script ("chatfilter")

Because it can not be used separately

Because Since it appears twice in chatbox message.

This is my "tagflood" script:

time = {}
muted = {}
words = {}
Repeat = {}
function chatbox(text, msgtype)
local r,g,b = getPlayerNametagColor(source)
local name = getPlayerName(source)
local accountname = getAccountName (getPlayerAccount(source))
local UpdateTime = get("UpdateTime")*1000
local TimeOfMute = get("TimeOfMute")*1000
local Chances = get("ChancesOfRepetitions")
if (msgtype == 0) then
if get("AntiRepeatSystem") == "true" then
if isTimer(time[source]) and words[source] == text then
local r, e, t = getTimerDetails(time[source])
local sec = r/1000
Repeat[source] = Repeat[source] + 1
outputChatBox("Ne Ismételd Magad! (No Flood)", source,255,0,0,true)
cancelEvent()
if Repeat[source] >= tonumber(Chances) then
if isPlayerMuted(source) then Repeat[source] = 0 return end
setPlayerMuted(source, true)
Repeat[source] = 0
realTime = TimeOfMute/1000
muted[source] = setTimer(function(source) 
setPlayerMuted(source, false) 
muted[source] = nil
end,TimeOfMute,1,source)
end
return
end
words[source] = text
Repeat[source] = 0
time[source] = setTimer(function(source) 
time[source] = nil 
words[source] = nil
Repeat[source] = 0
end
,UpdateTime,1,source)
end
	if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( get("TarsTulajdonosGroupACLName") ) ) then
		cancelEvent()
		outputChatBox(""..get("TarsTulajdonosTagColor").."["..get("TarsTulajdonosTag").."] #333333|BM| "..RGBToHex(0,255,255)..name..": "..get("TarsTulajdonosTalkColor")..""..text, getRootElement(),0,0,0,true)
		outputServerLog( "["..get("TarsTulajdonosTag").."] " .. getPlayerName ( source ).. ": " .. text)
		
	elseif isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( get("AdminGroupACLName") ) ) then
		cancelEvent()
		outputChatBox(""..get("AdminTagColor").."["..get("AdminTag").."] #333333|BM| "..RGBToHex(0,255,255)..name..": "..get("AdminTalkColor")..""..text, getRootElement(),0,0,0,true)
		outputServerLog( "["..get("AdminTag").."] " .. getPlayerName ( source ).. ": " .. text )
		
	elseif isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( get("ModeratorGroupACLName") ) ) then
		cancelEvent()
		outputChatBox(""..get("ModeratorTagColor").."["..get("ModeratorTag").."] #333333|BM| "..RGBToHex(0,255,255)..name..": "..get("ModeratorTalkColor")..""..text, getRootElement(),0,0,0,true)
		outputServerLog( "["..get("ModeratorTag").."] " .. getPlayerName ( source ).. ": " .. text )
		
	elseif isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( get("KisModeratorGroupACLName") ) ) then
		cancelEvent()
		outputChatBox(""..get("KisModeratorTagColor").."["..get("KisModeratorTag").."] #333333|BM| "..RGBToHex(0,255,255)..name..": "..get("KisModeratorTalkColor")..""..text, getRootElement(),0,0,0,true)
		outputServerLog( "["..get("KisModeratorTag").."] " .. getPlayerName ( source ).. ": " .. text )	
	
	elseif isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( get("TulajdonosGroupACLName") ) ) then
		cancelEvent()
		outputChatBox(""..get("TulajdonosTagColor").."["..get("TulajdonosTag").."] #333333|BM| "..RGBToHex(0,255,255)..name..": "..get("TulajdonosTalkColor")..""..text, getRootElement(),0,0,0,true)
		outputServerLog( "["..get("TulajdonosTag").."] " .. getPlayerName ( source ).. ": " .. text )
		
	elseif isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( get("VIP1GroupACLName") ) ) then
		cancelEvent()
		outputChatBox(""..get("VIP1TagColor")..""..get("VIP1Tag").." "..RGBToHex(255,255,255)..name..": "..get("VIP1TalkColor")..""..text, getRootElement(),0,0,0,true)
		outputServerLog( ""..get("VIP1Tag").." " .. getPlayerName ( source ).. ": " .. text )	
		
	elseif isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( get("VIP2GroupACLName") ) ) then
		cancelEvent()
		outputChatBox(""..get("VIP2TagColor")..""..get("VIP2Tag").." "..RGBToHex(255,255,255)..name..": "..get("VIP2TalkColor")..""..text, getRootElement(),0,0,0,true)
		outputServerLog( ""..get("VIP2Tag").." " .. getPlayerName ( source ).. ": " .. text )	

    elseif isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( get("VIP3GroupACLName") ) ) then
		cancelEvent()
		outputChatBox(""..get("VIP3TagColor")..""..get("VIP3Tag").." "..RGBToHex(255,255,255)..name..": "..get("VIP3TalkColor")..""..text, getRootElement(),0,0,0,true)
		outputServerLog( ""..get("VIP3Tag").." " .. getPlayerName ( source ).. ": " .. text )		
		
	elseif isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( get("VIPBMGroupACLName") ) ) then
		cancelEvent()
		outputChatBox(""..get("VIPBMTagColor")..""..get("VIPBMTag").." #333333|BM| "..RGBToHex(255,255,255)..name..": "..get("VIPBMTalkColor")..""..text, getRootElement(),0,0,0,true)
		outputServerLog( ""..get("VIPBMTag").." " .. getPlayerName ( source ).. ": " .. text )		

    elseif isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( get("BMGroupACLName") ) ) then
		cancelEvent()
		outputChatBox(""..get("BMTagColor")..""..get("BMTag").." "..RGBToHex(255,255,255)..name..": "..get("BMTalkColor")..""..text, getRootElement(),0,0,0,true)
		outputServerLog( ""..get("BMTag").." " .. getPlayerName ( source ).. ": " .. text )			
		
	elseif isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( get("EveryoneGroupACLName") ) ) then
		cancelEvent()
		if isGuestAccount ( getPlayerAccount ( source ) ) then
			outputChatBox(""..get("GuestTagColor").."["..get("GuestTag").."] "..RGBToHex(r,g,b)..name..": "..get("GuestTalkColor")..""..text, getRootElement(),0,0,0,true)
			outputServerLog( "["..get("GuestTag").."] " .. getPlayerName ( source ).. ": " .. text )
		else
			outputChatBox(""..get("LoginTagColor")..""..RGBToHex(r,g,b)..name..": "..get("LoginTalkColor")..""..text, getRootElement(),0,0,0,true)
			outputServerLog( "["..get("LoginTag").."] " .. getPlayerName ( source ).. ": " .. text )	
		end
	end
end
end
addEventHandler("onPlayerChat", getRootElement(), chatbox)

function stop ( )
  for _,v in ipairs(getElementsByType("player")) do
	if isTimer(muted[v]) then
		setPlayerMuted(v, false)
		  startResource ( source )
        stopResource ( source )
	end
  end
end
addEventHandler ( "onResourceStop", resourceRoot, stop )

function saveData ( )
local serial = getPlayerSerial ( source )
if isTimer(muted[source]) then
	local r, e, t = getTimerDetails(muted[source])
	setElementData(resourceRoot,serial,r)
end
end
addEventHandler ( "onPlayerQuit", getRootElement(), saveData )

function getData( )
local serial = getPlayerSerial ( source )
local dataSystem = tonumber(getElementData(resourceRoot,serial)) or false
if dataSystem == false then return end
if isPlayerMuted(source) then return end
if get("AntiRepeatSystem") == "false" then return end
if dataSystem < 1 then setElementData(resourceRoot,serial,false) return end
		local timeData = dataSystem/1000
		setPlayerMuted(source, true)
	muted[source] = setTimer(function(source) 
		setPlayerMuted(source, false) 
		setElementData(resourceRoot,serial,false)
		muted[source] = nil
	end,dataSystem,1,source)
end
addEventHandler ( "onPlayerJoin", getRootElement(), getData )


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

 

 

In this I want to incorporate this

 

swearWords = {
	":O",
	":~",
	"piss",
	"bitch",
	"ass",
	"tard",
	":O",
	"nazi",
	"fack",
	"fock",
	"cock",
	"pussy",
	"fack",
	"gay",
	"lesbian",
	"whore",
	":O",
	":O",
	":O",
	":O",
}


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

 

So that it's all together and one chatbox

Thanks

Edited by ssxskullboy
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...