function eventPlayerSay(userid, strText, bTeam) --My custom curse word blocker
BadWords = {"", "", "omg", "lol", "rofl", "brb"} --well here are our bad words
GoodWords = {"****", "****", "oh my god", "laugh out load", "rolling on floor laughing", "be right back"} --and he's what we will replace them with
local message = string.lower(strText); --this will be our message except all in lower case
local Indent = 0;
local StartLoc; --Starting location of the bad word
local EndLoc; --end
local StrInMsg; --the actual bad word in the "real" message, not the lower case one
local size = table.getn(BadWords)
for i=1, size do --we're going to check every word in the bad words list
StartLoc = string.find(message, BadWords[i], Indent) --we need to use the lower case message so that it's not case sensitive
while StartLoc ~= nil do --while we have a bad word
EndLoc = (string.len(BadWords[i])+StartLoc)-1 --we can find the end of the bad word if we know what word it is
_Msg(StartLoc)
_Msg(EndLoc)
StrInMsg = string.sub(strText, StartLoc, EndLoc) --this is the actual bad word in the real message with the case
strText = string.gsub(strText, StrInMsg, GoodWords[i]) --we're going to replace this bad word with a good one
message = string.lower(strText) --make sure we update the lower case message
Indent = EndLoc + 1 -- add our indent, which isn't really needed but i guess it could make the script go a bit faster
local firstLetter=string.upper(string.sub(strText,1,1));
local restOfString=string.sub(strText,2,-1);
lastmessage = firstLetter..restOfString;
if (Indent >= string.len(strText)) then --make sure we haven't over run the length of the message, if we have, we're done
break
end
StartLoc = string.find(message, BadWords[i], Indent) -- make sure there is still a bad word in there
end
Indent = 0 --reset our indent for the next bad word
end
if ( bTeam == false ) then --If the message is for everyone, just send it once to everyone
_GModText_Start( "Default" ); --Just standard style
_GModText_SetColor( 255, 255, 255, 255 ); --Color: RGB A -> White, no transparency (Alpha 255)
_GModText_SetTime( 5, 1, 1 ); --How long it stays, and the fading times
_GModText_SetEntityOffset( vector3( 0, 0, 35 ) ); --Messages appear 35 Units above Players
_GModText_SetEntity( userid ); --Entity/Player the message will follow
_GModText_SetText( strText ); --Set the message
_GModText_Send( 0, 50+userid ); --Send it ( 0 => send to everyone )
else
local pteam = _PlayerInfo(userid,"team"); --Get the team of the player, who sent the chat message
for i=1, _MaxPlayers() do
if ( _PlayerInfo(i,"team") == pteam and i ~= userid ) then --now only send it to teammates
_GModText_Start( "Default" ); --Just standard style
_GModText_SetColor( 255, 255, 255, 255 ); --Color: RGB A -> White, no transparency (Alpha 255)
_GModText_SetTime( 2, 0, 0.5 ); --How long it stays, and the fading times
_GModText_SetEntityOffset( vector3( 0, 0, 35 ) ); --Messages appear 35 Units above Players
_GModText_SetEntity( userid ); --Entity/Player the message will follow
_GModText_SetText( strText ); --Set the message
_GModText_Send( i, 50+userid ); --Send it ( i => send it to the current i => those are only teammates now, since we filter any other out )
end
end
end
return ""..strText.." "; --give back the text except with the replaced bad words
end
Not a Ulib or ULX script not sure if it works with it Ulib admin isn't working for me.
EDIT
Fixed code sorry its in my complete one that I use for my server so it has some extras.