• This is a read only backup of the old Emudevs forum. If you want to have anything removed, please message me on Discord: KittyKaev

Chat system block text

Status
Not open for further replies.

Xaver

Respected Member
"I wrote Kaev a PM to translate it, he will do it asap"



Hallo ich möchte das in diesen script sätze unterbunden werden das heist das wenn man zb test im chat sagt sieses nicht sichtbar ist.

das heist sollte ich im chat schreiben test, sieht es keiner nicht mal ich aber wenn ich was anderes schreibe soll es normal raus gehen.


Code:
local Gmrank = {
				[0] = " |cff00ffffFOD User|r ",
				[1] = " |cffFF8400VIP 1 User |r",
				[2] = " |cffFC3F00VIP 2 User |r",
				[5] = " |cff00ffffFOD User|r ",
				[6] = " |cff00ffffFOD User|r ",
				[10] = " |cff00ffffFOD User|r ",
				[11] = " |cff00ffffFOD User|r ",
				
				
				[12] = " |cff00ffffFOD User|r ",
				
				
				[13] = " |cff00ffffFOD User|r ",
				
				
				[14] = " |cff00ffffFOD User|r ",
				
				
				[15] = " |cff00ffffFOD User|r ",
				
				
				[254] = "|cffDE2E2ECo.Inhaber |r",
				
				
				[255] = "|cffFF0000FoD Owner |r"
				
				};
function ChatSystemSay(event, player, msg, type, lang, unit, channel)
	if (msg:sub(0, ChatPrefix:len()) == ChatPrefix) then
		local a = table.concat{Gmrank[player:GetGMRank()], "|Hplayer:",  "|h|cffFFFFFF", ":|cffffffff ",  msg};
		player:SendUnitSay(a, 0)
		
		
		--player:SendUnitSay(""..WorldChannelName..""..player:GetGMRank()..""..player:GetName(), 0);
		
	return false;
	end
end
RegisterPlayerEvent(18, ChatSystemSay)
 

Xaver

Respected Member
because google does not translate correctly


google trans:


Hello I would like to be suppressed in this script sets that means that if you eg test chatting says it is not visible.

which means I should chatting write test, it does not even I do not but if I want something else write it normal to go out.
 
Last edited:

Sylica

Exalted Member
"I wrote Kaev a PM to translate it, he will do it asap"



Hallo ich möchte das in diesen script sätze unterbunden werden das heist das wenn man zb test im chat sagt sieses nicht sichtbar ist.

das heist sollte ich im chat schreiben test, sieht es keiner nicht mal ich aber wenn ich was anderes schreibe soll es normal raus gehen.

Luckly I know German.

Hello I would like to be suppressed in this script sets the heist that if you for example test chatting says sieses is not visible.

the heist I should write in the chat, it looks no not even me but when I want something else write it normal to go out.
 

Kaev

Super Moderator
Luckly I know German.

Hello I would like to be suppressed in this script sets the heist that if you for example test chatting says sieses is not visible.

the heist I should write in the chat, it looks no not even me but when I want something else write it normal to go out.

Much nope. :p
I dont translate it 1:1, but it will be more understandable.

Hello, i would like to block messages in the chat. E.g. when i write "ED sucks", other players shouldn't see it.

Code:
local Gmrank = {
				[0] = " |cff00ffffFOD User|r ",
				[1] = " |cffFF8400VIP 1 User |r",
				[2] = " |cffFC3F00VIP 2 User |r",
				[5] = " |cff00ffffFOD User|r ",
				[6] = " |cff00ffffFOD User|r ",
				[10] = " |cff00ffffFOD User|r ",
				[11] = " |cff00ffffFOD User|r ",
				
				
				[12] = " |cff00ffffFOD User|r ",
				
				
				[13] = " |cff00ffffFOD User|r ",
				
				
				[14] = " |cff00ffffFOD User|r ",
				
				
				[15] = " |cff00ffffFOD User|r ",
				
				
				[254] = "|cffDE2E2ECo.Inhaber |r",
				
				
				[255] = "|cffFF0000FoD Owner |r"
				
				};
function ChatSystemSay(event, player, msg, type, lang, unit, channel)
	if (msg:sub(0, ChatPrefix:len()) == ChatPrefix) then
		local a = table.concat{Gmrank[player:GetGMRank()], "|Hplayer:",  "|h|cffFFFFFF", ":|cffffffff ",  msg};
		player:SendUnitSay(a, 0)
		
		
		--player:SendUnitSay(""..WorldChannelName..""..player:GetGMRank()..""..player:GetName(), 0);
		
	return false;
	end
end
RegisterPlayerEvent(18, ChatSystemSay)
 

Grandelf

Esteemed Member
First of:
Code:
if (msg:sub(0, ChatPrefix:len()) == ChatPrefix) then
Does nothing really, it basically grabs the whole string. So ..
if (msg == ChatPrefix) basically does the same as that.

To check for bad words, what you want to do is make a table
with bad words and iterate over the words of the string and check if
those words match. So I wrote some code that would do that for you.
Code:
-- Blocked words go in this table.
local blockedWords = {
	"shit",
	"fuck",
	"bitch"
};
-- The string which the blocked word should be
-- replaced with.
local strReplacement = "%$@!";
-- Function to check for blocked words and fix
-- the message.
local function blockWords(str)
	local words = {};
	-- Grabbing all the words and putting them in a table.
	str:gsub("(%w+)", function (w) table.insert(words, w); end);
	-- Replacing bad words with the 'strReplacement'.
	for _, word in ipairs(words) do
		for _, badWord in ipairs(blockedWords) do
			if word:lower() == badWord:lower() then
				str:gsub(word, strReplacement); break;
			end
		end
	end
	return str;
end
Now what you want to do is enter the words you want to block
and change the 'strReplacement' to your liking (it will replace the bad words with that).
To use it, you simply would do something like this (below the check if the msg equals to the command):
Code:
msg = blockWords(msg)
I didn't test this but I am almost sure it should work.

Grandelf.
 
Last edited:

Grandelf

Esteemed Member
You have to put it in your script yea, just copy and paste it on the top of your script.
Then use the line of code from my previous post.
 

Xaver

Respected Member
hmm this is my change look:


Code:
-- I think these links came from psykko and others I found over time . just kewl little tweeks to customize your world 

-- Blocked words go in this table.
local blockedWords = {
	"shit",
	"fuck",
	"bitch"
};

local strReplacement = "%$@!";

local function blockWords(str)
	local words = {};
	-- Grabbing all the words and putting them in a table.
	str:gsub("(%w+)", function (w) table.insert(words, w); end);
	-- Replacing bad words with the 'strReplacement'.
	for _, word in ipairs(words) do
		for _, badWord in ipairs(blockedWords) do
			if word:lower() == badWord:lower() then
				str:gsub(word, strReplacement); break;
			end
		end
	end
	return str;
end


local ChatPrefix = "";
local WorldChannelName = "";



local Gmrank = {
				[0] = " |cff00ffffFOD User|r ",
				[1] = " |cffFF8400VIP 1 User |r",
				[2] = " |cffFC3F00VIP 2 User |r",
				[5] = " |cff00ffffFOD User|r ",
				[6] = " |cff00ffffFOD User|r ",
				[10] = " |cff00ffffFOD User|r ",
				[11] = " |cff00ffffFOD User|r ",
				
				
				[12] = " |cff00ffffFOD User|r ",
				
				
				[13] = " |cff00ffffFOD User|r ",
				
				
				[14] = " |cff00ffffFOD User|r ",
				
				
				[15] = " |cff00ffffFOD User|r ",
				
				
				[254] = "|cffDE2E2ECo.Inhaber |r",
				
				
				[255] = "|cffFF0000FoD Owner |r"
				
				};
function ChatSystemSay(event, player, msg, type, lang, unit, channel)
	if (msg:sub(0, ChatPrefix:len()) == ChatPrefix) then
		local a = table.concat{Gmrank[player:GetGMRank()], "|Hplayer:",  "|h|cffFFFFFF", ":|cffffffff ",  msg};
		player:SendUnitSay(a, 0)
		
		
		--player:SendUnitSay(""..WorldChannelName..""..player:GetGMRank()..""..player:GetName(), 0);
		
	return false;
	end
end
RegisterPlayerEvent(18, ChatSystemSay)


not work can you look pls and post curectly code pls thx
 

Grandelf

Esteemed Member
So if I understand this right, you want to block certain words from the normal chat,
and give them a certain rank?
 

Xaver

Respected Member
yes all right is finish and works but i have never scripts this script is open gossips menu on say menü or vip

when this script active (say script) and user post menü to open mplayer menu, i´m well not see all user when user say menü you understand ?
 

Grandelf

Esteemed Member
Not exactly..
Anyway I combined the scripts, I wasn't to sure about a few things but at least this'll work.
So you can try to edit it to how you want it. Right now whenever someone says something
in /say it will filter the bad words and put a rank in front of the message.
Code:
-- Blocked words go in this table.
local blockedWords = {
	"shit",
	"fuck",
	"bitch"
};
-- The string which the blocked word should be
-- replaced with.
local strReplacement = "^$@!";
-- Function to check for blocked words and fix
-- the message.
local function blockWords(str)
	local words = {};
	-- Grabbing all the words and putting them in a table.
	str:gsub("(%w+)", function (w) table.insert(words, w); end);
	-- Replacing bad words with the 'strReplacement'.
	for _, word in ipairs(words) do
		for _, badWord in ipairs(blockedWords) do
			if word:lower() == badWord:lower() then
				str = str:gsub(word, strReplacement); break;
			end
		end
	end
	return str;
end

-- What are these for?
local ChatPrefix = "";
local WorldChannelName = "";

-- I am going to assume that the indexes
-- here are correct.
local Gmrank = {
	[0] = " |cff00ffffFOD User|r ",
	[1] = " |cffFF8400VIP 1 User |r",
	[2] = " |cffFC3F00VIP 2 User |r",
	[3] = " |cffFC3F00VIP 3 User |r",
	[5] = " |cff00ffffFOD User|r ",
	[6] = " |cff00ffffFOD User|r ",
	[10] = " |cff00ffffFOD User|r ",
	[11] = " |cff00ffffFOD User|r ",
	[12] = " |cff00ffffFOD User|r ",
	[13] = " |cff00ffffFOD User|r ",
	[14] = " |cff00ffffFOD User|r ",
	[15] = " |cff00ffffFOD User|r ",
	[254] = "|cffDE2E2ECo.Inhaber |r",
	[255] = "|cffFF0000FoD Owner |r"
};
function ChatSystemSay(_, player, msg)
	if msg:find(ChatPrefix) == 1 then
		-- Filter the string for bad words.
		msg = Gmrank[player:GetGMRank()] .. blockWords(msg);
		-- Send it ... ?
		player:SendUnitSay(msg, 0)
		return false;
	end
end
RegisterPlayerEvent(18, ChatSystemSay)
 

Xaver

Respected Member
ok work perfectly but can remore this "^$@!";

and not post ??

when user say fuck no funktion noting say ? very thx
 

Grandelf

Esteemed Member
No problem and yes that's very easy.
Simply edit this line:
Code:
local strReplacement = "^$@!";
So if you want it to post nothing simply edit it to this:
Code:
local strReplacement = "";
 

Xaver

Respected Member
yes i have this testet and look Unbenannt.png
 

Grandelf

Esteemed Member
Ahh you want it so it doesn't show anything at all when a player uses a bad word.
Hmm this should do the trick then:
Code:
-- Blocked words go in this table.
local blockedWords = {
	"shit",
	"fuck",
	"bitch"
};
-- The string which the blocked word should be
-- replaced with.
local strReplacement = "^$@!";
-- Function to check for blocked words and fix
-- the message.
local function blockWords(str)
	local words = {};
	-- Grabbing all the words and putting them in a table.
	str:gsub("(%w+)", function (w) table.insert(words, w); end);
	-- Replacing bad words with the 'strReplacement'.
	for _, word in ipairs(words) do
		for _, badWord in ipairs(blockedWords) do
			if word:lower() == badWord:lower() then return true; end
		end
	end
	return false;
end

-- What are these for?
local ChatPrefix = "";
local WorldChannelName = "";

-- I am going to assume that the indexes
-- here are correct.
local Gmrank = {
	[0] = " |cff00ffffFOD User|r ",
	[1] = " |cffFF8400VIP 1 User |r",
	[2] = " |cffFC3F00VIP 2 User |r",
	[3] = " |cffFC3F00VIP 3 User |r",
	[5] = " |cff00ffffFOD User|r ",
	[6] = " |cff00ffffFOD User|r ",
	[10] = " |cff00ffffFOD User|r ",
	[11] = " |cff00ffffFOD User|r ",
	[12] = " |cff00ffffFOD User|r ",
	[13] = " |cff00ffffFOD User|r ",
	[14] = " |cff00ffffFOD User|r ",
	[15] = " |cff00ffffFOD User|r ",
	[254] = "|cffDE2E2ECo.Inhaber |r",
	[255] = "|cffFF0000FoD Owner |r"
};
function ChatSystemSay(_, player, msg)
	if msg:find(ChatPrefix) == 1 then
		-- Filter the string for bad words.
		if not blockWords(msg) then
			player:SendUnitSay(Gmrank[player:GetGMRank()] .. msg, 0)
		end
		return false;
	end
end
RegisterPlayerEvent(18, ChatSystemSay)
 

Foereaper

Founder
Grand, if you wouldn't mind cleaning up the script and posting it as a release for others to enjoy, that would be great! :)

Marking as solved.
 
Status
Not open for further replies.
Top