[DemoN] Posted July 8, 2011 Share Posted July 8, 2011 Hello. I'm trying to make a script which doesn't allow you to swear... but it says: lua4 ')' expected near ' "#FFFFFFWho?" ' and it's not cancelling when I type gay (Is there any function to make it GaY or gAy ??) (and I need to add a lot of 'elseif'. How can i make a table?) Here is the code: function sansur(message,type) if (string.find(message,"hacker")) then outputChatBox("#00FF00Jonathan :" "#FFFFFFWho?" ) elseif (string.find(message,"hax")) then outputChatBox("#00FF00Jonathan :" "#FFFFFFWho?" ) elseif (string.find(message,"hack"))then outputChatBox( "#00FF00Jonathan :" "#FFFFFFWho?" ) end end addEventHandler ("onPlayerChat",getRootElement(), sansur) function sansur2(message, type) if (string.find(message,"gay")) then cancelEvent() outputChatBox(getPlayerName(source).. ":" "#FF0000(dirty word)") outputChatBox( "#00FF00Jonathan :" "#FF0000Don't swear and don't talk about dirty things. That's not good.") end end addEventHandler("onPlayerChat", getRootElement(), sansur2) ( outputChatBox(getPlayerName(source).. ":" "#FF0000(dirty word)") <----- Here i wanted to turn gay into (dirty word) not all message. can someone help me? ) Link to comment
NotAvailable Posted July 8, 2011 Share Posted July 8, 2011 : https://community.multitheftauto.com/index.php?p= ... ls&id=1350 Link to comment
BinSlayer1 Posted July 8, 2011 Share Posted July 8, 2011 but it says: lua4 ')' expected near ' "#FFFFFFWho?" ' it's outputChatBox("#00FF00Jonathan :".."#FFFFFFWho?", source ) --notice those dots, they're for concatenating strings. and 'source' to send it to that player and it's not cancelling when I type gay (Is there any function to make it GaY or gAy ??)(and I need to add a lot of 'elseif'. How can i make a table?) for every message, do this: message = string.lower(message) this will make the message be gay even if it was previously gAy or Gay. So in your bad-words-list just use lowercase letters wordsTable = { } --add stuff here like wordsTable = { "gay" ,"fu" } then go through the table using ipairs like this: for i,v in ipairs(wordsTable) do in the for, "v" will be your swear word string (defined in the table, 1 at a time) I just answered some of your questions, you should take a look at the link above my post though. Link to comment
qaisjp Posted July 8, 2011 Share Posted July 8, 2011 local badman = { "i", "like", "to", "say", "bad", "words", "cos", "its", "so", "fu", "fun!!!" } function oyestfu(msg, lolT) _G["cancelEvent"]() for i,v in ipairs(badman) do if string.find(string.lower(msg), v) then msg = string.gsub(string.lower(msg), v, "<I_Love_You>") end end r,g,b = getPlayerNametagColor(source) outputChatBox(getPlayerName(source)..": "..msg, root, r,g,b) end addEventHandler("onPlayerChat", root, oyestfu) Send me a pm and i will give you the one i made from af server. Please note i am not sure how to restore the capitalization. Link to comment
Buffalo Posted July 8, 2011 Share Posted July 8, 2011 function oyestfu(msg, lolT) _G["cancelEvent"]() for i,v in ipairs(badman) do local s,e = string.find(string.lower(msg), v) if s then msg = string.sub(msg,1,s).."<I_Love_You>"..string.sub(msg,e,string.len(msg))) end end r,g,b = getPlayerNametagColor(source) outputChatBox(getPlayerName(source)..": "..msg, root, r,g,b) end should fix capitals missing Link to comment
bandi94 Posted July 8, 2011 Share Posted July 8, 2011 (edited) its one on comunity whit a tabel you write the words "...","....." and done .. https://community.multitheftauto.com/ind ... ls&id=1479 Edited July 9, 2011 by Guest Link to comment
Cadu12 Posted July 9, 2011 Share Posted July 9, 2011 @Demon, your code is wong. you can use my function: removeSwear( string ) here code: ChatBad = {"anus", "arse", "arsehole", "ass", "ass-hat", "ass-jabber", "ass-pirate", "assbag", "assbandit", "assbanger", "assbite", "assclown", "asscock", "asscracker", "asses", "assface", "assfuck", "assfucker", "assgoblin", "asshat", "asshead", "asshole", "asshopper", "assjacker", "asslick", "asslicker", "assmonkey", "assmunch", "assmuncher", "assnigger", "asspirate", "assshit", "assshole", "asssucker", "asswad", "asswipe" "bampot", "bastard", "beaner", "bitch", "bitchass", "bitches", "bitchtits", "bitchy", "blow job", "blowjob", "bollocks", "bollox", "boner", "brotherfucker", "bullshit", "bumblefuck", "butt plug", "butt-pirate", "buttfucka", "buttfucker", "camel toe", "carpetmuncher", "chinc", "chink", "choad", "chode", "clit", "clitface", "clitfuck", "clusterfuck", "cock", "cockass", "cockbite", "cockburger", "cockface", "cockfucker", "cockhead", "cockjockey", "cockknoker", "cockmaster", "cockmongler", "cockmongruel", "cockmonkey", "cockmuncher", "cocknose", "cocknugget", "cockshit", "cocksmith", "cocksmoke", "cocksmoker", "cocksniffer", "cocksucker", "cockwaffle", "coochie", "coochy", "coon", "cooter", "cracker", "cum", "cumbubble", "cumdumpster", "cumguzzler", "cumjockey", "cumslut", "cumtart", "cunnie", "cunnilingus" "cunt", "cuntass", "cuntface", "cunthole", "cuntlicker", "cuntrag", "cuntslut", "dago", "damn", "deggo", "dick", "dickbag"} -- add more :] function removeSwear(message) local Findingdots = string.gsub(message, "([%s%_%*%+%?%.%(%)%[%]%{%}%\%/%|%^%$%-])", '') Removelower = string.lower(message) Remove = message for i, Findingbad in ipairs(ChatBad) do if string.find( Remove, Findingbad ) then Remove = string.gsub( Remove:lower(), Findingbad, string.rep('*', #Findingbad) ) removeSwear(Remove) elseif string.find( Findingdots, Findingbad) then Remove = string.gsub( Findingdots, Findingbad, string.rep('*', #Findingbad) ) removeSwear(Remove) end end return Remove end function onPlayerChat(messages, typechat) local N = getPlayerName(source) if typechat == 0 then cancelEvent() local playerTeam = getPlayerTeam ( source ) local r, g, b = 224, 208, 176 if playerTeam then local r, g, b = getTeamColor ( playerTeam ) end outputChatBox(string.format("#%02X%02X%02X", r, g, b) .. N .. ": " .. removeSwear(messages), getRootElement(), 255, 255, 255, true) end end addEventHandler('onPlayerChat', getRootElement(), onPlayerChat) Link to comment
bandi94 Posted July 9, 2011 Share Posted July 9, 2011 hm..... gePlayerTeam getTeamColor in no swear.... ( if you give a code try to remove the +code) and if you use this if (type(string.find(message,"bitch")) == "number") then that "number" is if you type whit . or , you stil get muted or .... and if you type blablabitchbalbla you stil get muted so no need to write 1 word in difrent persons and ... Link to comment
[DemoN] Posted July 10, 2011 Author Share Posted July 10, 2011 Woah! Thank you Cadu12 (where have you found this dirty things? ) Link to comment
Cadu12 Posted July 10, 2011 Share Posted July 10, 2011 I made my own function, so you can use function. You can add more http://www.noswearing.com/dictionary/d I didnt added D at Z, becuase im making my own scripts @bandi94, number? hmmmmmm I dont use it Link to comment
[DemoN] Posted July 11, 2011 Author Share Posted July 11, 2011 hm..... gePlayerTeam getTeamColor in no swear.... ( if you give a code try to remove the +code)and if you use this if (type(string.find(message,"bitch")) == "number") then that "number" is if you type whit . or , you stil get muted or .... and if you type blablabitchbalbla you stil get muted so no need to write 1 word in difrent persons and ... Wow. Thanks for the tip. I'll use it Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now