arris Posted July 18, 2009 Share Posted July 18, 2009 Hi does anyone how to make a script that if a player swear he gets a warning and after 3 warning he gets kicked Link to comment
robhol Posted July 18, 2009 Share Posted July 18, 2009 Hook up the onPlayerChat event to a handler, check if whatever he said contains a swear word. If it does, check if his warning count is 3 or higher. If it is, kick him, if not, increment his warning count and send him a warning. For the swear words and warning counts, you can use tables. In the counter tables, you can use the player elements as indices. Alternatively, you can store the warning counts in element data for each player, although this isn't really recommended since it'll sync the data with the client, where it'll never be used anyways. Link to comment
arris Posted July 18, 2009 Author Share Posted July 18, 2009 swears = (All the swears are here) function chat() if outputChatBox ==(swears) and getElementType(source)=="player" then outputChatBox ("PLEASE DONT SWEAR ON NRNS SERVERS!!!!... U CAN GET KICKED/BANNED", 255, 0, 0 ) end end addEventHandler ("onPlayerChat",source, chat ) and i get this is what it says in the console "WARNING: swear.lua: Bad argument @ 'addEventHandler' -Line: 7" Link to comment
robhol Posted July 18, 2009 Share Posted July 18, 2009 Read the lua basics again. Tables are defined using brackets { }, not parentheses. Also you will need to loop through the swears table and check for matches (cast all strings to either lowercase or uppercase first, otherwise people can write stuff like FuCk, FUcK, etc. to evade the censor.) And please do yourself and your clan/whatever a favor and use proper language in the scripts; writing "u" instead of "you" should generally be avoided unless you're in a hurry, but in a server, it makes the whole deal look terribly unprofessional. There's never any excuse for 4 exclamation marks in a row, either. Link to comment
ArmedGuy Posted July 18, 2009 Share Posted July 18, 2009 ahhh... Robohol, i was the one that made that script with arris and we wrote (All Swears Here) Because we didnt want to have a awsomly long text just with swearing. And all words are written like this: swears = { ["Swear"]=true, ["swear"]=true, and so on... Just so u know And that outputChatBox string, thats just temporary So dont worry about that. But The Thing We Gotta Get Fixed Is That Warning. And Right Now We Have No Clue What To Do. And Also We Just Gotta Get It Working Right Now.. Then We Can Fix The Swearings. Link to comment
robhol Posted July 19, 2009 Share Posted July 19, 2009 Post your actual code then. I'll bet a fairly significant sum of money on the fact that we have no psychics here. Link to comment
50p Posted July 19, 2009 Share Posted July 19, 2009 You shouldn't make a table like this: tablename = { ["string"]=true, ["string"], ... } -- just do it this way: tablename = { "string", "string" } Then just loop through the table and check if any of the words match. Use string.gmatch or string.find. Link to comment
ArmedGuy Posted July 19, 2009 Share Posted July 19, 2009 rofl ok.. here it is 1. swears = { ["fodido"]=true, ["puta"]=true, ["PUTA"]=true, ["puto"]=true, ["PUTO"]=true, ["ass"]=true, ["wanker"]=true, ["@"]=true, ["666"]=true, ["amina koyayim"]=true, ["asshole"]=true, ["bicha"]=true, ["bitch"]=true, ["cabron"]=true, ["carechimba"]=true, ["chinga"]=true, ["chupamela"]=true, ["cook"]=true, ["cunt"]=true, ["donkey"]=true, ["cum"]=true, ["estupido"]=true, ["foda"]=true, ["fuck"]=true, ["fuckers"]=true, ["fuckin"]=true, ["gay"]=true, ["gonorrea"]=true, ["guevon"]=true, ["hpd"]=true, ["hijueputa"]=true, ["hotmail"]=true, ["hps"]=true, ["ibne"]=true, ["maldita"]=true, ["maldito"]=true, ["malnarcido"]=true, ["malparido"]=true, ["marica"]=true, ["maricon"]=true, ["marik"]=true, ["marika"]=true, ["mierda"]=true, ["monda"]=true, ["msn"]=true, ["n00b"]=true, ["noob"]=true, ["orospu cocugu"]=true, ["pija"]=true, ["pirobo"]=true, ["pussy"]=true, ["retard"]=true, ["shit"]=true, ["sik"]=true, ["siktir"]=true, ["slut"]=true, ["twat"]=true, ["wanker"]=true, ["whore"]=true, ["wtf"]=true } function chat() if outputChatBox ==(swears) and getElementType(source)=="player" then outputChatBox ("PLEASE DONT SWEAR ON NRNS SERVERS!!!!... U CAN GET KICKED/BANNED", 255, 0, 0 ) end end addEventHandler ("onPlayerChat",source, chat ) this gives the WARNING arris was talking about but.. i made another one that may me abit better swears = { ["fodido"]=true, ["puta"]=true, ["PUTA"]=true, ["puto"]=true, ["PUTO"]=true, ["ass"]=true, ["wanker"]=true, ["@"]=true, ["666"]=true, ["amina koyayim"]=true, ["asshole"]=true, ["bicha"]=true, ["bitch"]=true, ["cabron"]=true, ["carechimba"]=true, ["chinga"]=true, ["chupamela"]=true, ["cook"]=true, ["cunt"]=true, ["donkey"]=true, ["cum"]=true, ["estupido"]=true, ["foda"]=true, ["fuck"]=true, ["fuckers"]=true, ["fuckin"]=true, ["gay"]=true, ["gonorrea"]=true, ["guevon"]=true, ["hpd"]=true, ["hijueputa"]=true, ["hotmail"]=true, ["hps"]=true, ["ibne"]=true, ["maldita"]=true, ["maldito"]=true, ["malnarcido"]=true, ["malparido"]=true, ["marica"]=true, ["maricon"]=true, ["marik"]=true, ["marika"]=true, ["mierda"]=true, ["monda"]=true, ["msn"]=true, ["n00b"]=true, ["noob"]=true, ["orospu cocugu"]=true, ["pija"]=true, ["pirobo"]=true, ["pussy"]=true, ["retard"]=true, ["shit"]=true, ["sik"]=true, ["siktir"]=true, ["slut"]=true, ["twat"]=true, ["wanker"]=true, ["whore"]=true, ["wtf"]=true } function chat_bad(message, messageType) if message ==(swears) and getElementType(source)=="player" then outputChatBox ("PLEASE DONT SWEAR ON NRNS SERVERS!!!!... U CAN GET KICKED/BANNED, 255, 0, 0 ) end end addEventHandler ("onPlayerChat", getElementRoot(), chat_bad ) thou i havent debugged the latest one lol... its 2 Am here... been scripting for 13 hours today rofl Link to comment
Slothman Posted July 19, 2009 Share Posted July 19, 2009 i have nothing to contribute to the discussion of how to censor people, but I got a lot to say about you should. Link to comment
Thehookerkiller01 Posted July 19, 2009 Share Posted July 19, 2009 swears = (All the swears are here) function chat (thePlayer) if outputChatBox ==(swears) and getElementType(source)=="player" then outputChatBox ("PLEASE DONT SWEAR ON NRNS SERVERS!!!!... U CAN GET KICKED/BANNED", 255, 0, 0, source) end end addEventHandler ("onPlayerChat", getRootElement(), chat ) Link to comment
robhol Posted July 19, 2009 Share Posted July 19, 2009 Oh, come ON! Half of those aren't even remotely offensive, and more still aren't swear words at all! Why would you block "donkey"? Roflmao. If you don't intend to host a kindergarten server, screw this. If I came into a server that censored me, I'd gtfo VERY quickly. And Thehookerkiller01, you still don't know what you're talking about, as evidenced by the horrendous example you posted. Will you please shut the fuck up and stop spreading misinformation? Link to comment
The_Ex Posted July 19, 2009 Share Posted July 19, 2009 (edited) I think this should work. Someone should correct me if it's wrong. flameWords = {"fuck", "bitch", "cocksucker"} function disallowFlame(message) for key, value in pairs(flameWords) do if string.find(string.lower(message), value) then outputChatBox("YOU HAVE BEEN WARNED!",source) -- do whatever you want here end end end addEventHandler("onPlayerChat", getRootElement(), disallowFlame) Edited July 19, 2009 by Guest Link to comment
knash94 Posted July 19, 2009 Share Posted July 19, 2009 Oh, come ON! Half of those aren't even remotely offensive, and more still aren't swear words at all! Why would you block "donkey"? Roflmao.If you don't intend to host a kindergarten server, screw this. If I came into a server that censored me, I'd gtfo VERY quickly. And Thehookerkiller01, you still don't know what you're talking about, as evidenced by the horrendous example you posted. Will you please shut the fuck up and stop spreading misinformation? Hmm and Cook... TBH why make a censor script? Its a waste of time and seeings GTA is rated 18+. 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