LUA 188
V1+ Chat Block Filter 1.0 By xdedeone on 26th February 2019 07:15:30 PM
  1.  
  2. -- The words we want to block go here. Make sure they are all LOWER CASE!!
  3. exact_swear_table = {"fuck", "faggot", "shit", "cock", "fk", "fuk", "ass", "asswipe", "damn", "bastard", "dick", "dickk", "dickslap", "dicks", "dumass", "dumbass", "fag", "gayass", "gay", "homo", "ho", "whore", "mothafucka", "mothafuka", "motherfucker", "mofo", "ballsack", "nigga", "nigger", "pussy", "queerhole", "queer", "stfu", "testicle", "testicles", "testical", "testicles", "twat", "vagina", "wank"}
  4.  
  5. anywhere_swear_table = {"fuck", "fag", "shit", "cock", "damn", "asswipe", "bitch", "goddamn", "goddamnit"}
  6.  
  7. function GetRequiredVersion()
  8.         return 10058
  9. end
  10.  
  11. -- called when the script is loaded
  12. function OnScriptLoad(process)
  13.  
  14. end
  15.  
  16. -- called when the script is unloaded
  17. -- Do not return a value
  18. function OnScriptUnload()
  19.  
  20. end
  21.  
  22. -- called when a game is starting (before any players join)
  23. -- Do not return a value.
  24. function OnNewGame(map)
  25.  
  26. end
  27.  
  28. -- called when a game is ending
  29. -- Do not return a value.
  30. function OnGameEnd(mode)
  31.         -- mode 1 = score menu (F1) is being displayed to clients, they are still ingame
  32.         -- mode 2 = post game menu appeared
  33.         -- mode 3 = players can quit via the post game score card
  34.  
  35. end
  36.  
  37. -- Called when there is chat within the server
  38. -- It must return a value which indicates whether or not the chat is sent.
  39. function OnServerChat(player, chattype, message)
  40.  
  41.         -- this is a LOCAL variable that we use to track whether or not to send the message to the server
  42.         local AllowChat = 1
  43.  
  44.         -- get the number of tokens in the word
  45.         local count = gettokencount(message, " ")
  46.  
  47.         --declare the new message variable
  48.         local newmessage = ""
  49.  
  50.         -- loop through each word in the message (starting at 0 until count-1)
  51.         for i = 0, count-1 do
  52.  
  53.                 -- get the word
  54.                 local word = gettoken(message, " ", i)
  55.  
  56.                 -- now loop through the swear table
  57.                 local exacttableSize = table.getn(exact_swear_table)
  58.                 local anywheretableSize = table.getn(anywhere_swear_table)
  59.  
  60.                 local found = false
  61.  
  62.                 -- loop through the table and check if the words match any substr
  63.                 for x = 1, exacttableSize do
  64.  
  65.                         -- check if the word matches
  66.                         if string.lower(word) == exact_swear_table[x] then
  67.  
  68.                                 -- block the message
  69.                                 AllowChat = 0
  70.  
  71.                                 --get the length of the word/phrase
  72.                                 local length = string.len(exact_swear_table[x])
  73.  
  74.                                 --make a local variable storing ****s
  75.                                 local stars = ""
  76.  
  77.                                 --insert the correct length of stars into the string
  78.                                 for j = 1,length do
  79.                                         stars = stars .. "*"
  80.                                 end
  81.  
  82.                                 --replace the word with stars
  83.                                 word = stars
  84.  
  85.                                 --already found the word, we do not need to check in the anywheretable
  86.                                 found = true
  87.  
  88.                                 -- stop this loop as we need not continue
  89.                                 break
  90.                         end
  91.                 end
  92.  
  93.                 if AllowChat == 1 then
  94.  
  95.                         for x = 1,anywheretableSize do
  96.  
  97.                                 -- check if the phrase is found anywhere in the word
  98.                                 if string.find(string.lower(word), anywhere_swear_table[x]) ~= nil then
  99.  
  100.                                         --get the length of the word/phrase
  101.                                         local length = string.len(anywhere_swear_table[x])
  102.  
  103.                                         --make a local variable storing ****s
  104.                                         local stars = ""
  105.  
  106.                                         --insert the correct length of stars into the string
  107.                                         for j = 1,length do
  108.                                                 stars = stars .. "*"
  109.                                         end
  110.  
  111.                                         --replace the word with stars
  112.                                         word = word:gsub(string.lower(anywhere_swear_table[x]), stars)
  113.                                         word = word:gsub(string.upper(anywhere_swear_table[x]), stars)
  114.  
  115.                                         AllowChat = 0
  116.  
  117.                                 end
  118.                         end
  119.                 end
  120.  
  121.                 if newmessage == "" then
  122.                         newmessage = word
  123.                 else
  124.                         newmessage = newmessage .. " " .. word
  125.                 end
  126.  
  127.         end
  128.  
  129.         if AllowChat == 0 then
  130.                 return newmessage
  131.         end
  132.  
  133.         return AllowChat -- allow all chat, 0 would block the chat
  134. end
  135.  
  136. -- Called when a server command is being executed
  137. -- It must return a value which indicates whether or not the command should be processed
  138. -- Note: It is only called when an authenticated (and allowed) player attempts to use the command.
  139. --               player is -1 when being executed via the server console.
  140. function OnServerCommand(player, command)
  141.         return 1
  142. end
  143.  
  144. -- Called when a player's team is being chosen as the join the server.
  145. -- It must return a value which indicates the team the player is to be put on.
  146. -- Note: this function being called doesn't guarantee that the player will be able to successfully join.
  147. function OnTeamDecision(cur_team)
  148.  
  149.         return cur_team
  150. end
  151.  
  152. -- Called when a player joins the server.
  153. -- Do not return a value.
  154. function OnPlayerJoin(player, team)
  155.  
  156. end
  157.  
  158. -- Called when a player the server.
  159. -- Do not return a value.
  160. function OnPlayerLeave(player, team)
  161.  
  162. end
  163.  
  164. -- called when a player kills another, 'killer' is the index of the killing player, 'victim' is the index of the dead player
  165. -- Do not return a value.
  166. function OnPlayerKill(killer, victim, mode)
  167.  
  168. end
  169.  
  170. -- called when a player gets a double kill, killing spree etc
  171. function OnKillMultiplier(player, multiplier)
  172.         -- values for multiplier
  173.         --0x07 = double kill
  174.         --0x09 = triple kill
  175.         --0x0a = killtacular
  176.         --0x0b = killing spree
  177.         --0x0c = running riot
  178.         --0x0d = betrayed
  179.         --0x0e = killtacular with score
  180.         --0x0f = triple kill with score
  181.         --0x10 = double kill with score
  182.         --0x11 = running riot with score
  183.         --0x12 = killing spree with score
  184. end
  185.  
  186. -- Called when a player spawns (after object is created, before players are notified)
  187. -- Do not return a value
  188. function OnPlayerSpawn(player, m_objectId)
  189.  
  190. end
  191.  
  192. -- Called after clients have been notified of a player spawn
  193. -- Do not return a value
  194. function OnPlayerSpawnEnd(player, m_objectId)
  195.  
  196. end
  197.  
  198. -- Called when a player is attempting to change team.
  199. -- A value must be returned. The return value indicates whether or not the player is allowed the change team.
  200. -- Notes: If relevant is 1 the return value is considered, if it's 0 then the return value is ignored.
  201. function OnTeamChange(relevant, player, team, dest_team)
  202.  
  203.         return 1
  204. end
  205.  
  206. -- Called when a player interacts with an object
  207. -- It can be called while attempting to pick the object up
  208. -- It is also called when standing above an object so can be called various times quickly
  209. function OnObjectInteraction(player, m_ObjectId, tagType, tagName)
  210.  
  211.         return 1
  212. end
  213.  
  214. -- Called when a player attempts to reload their weapon.
  215. -- A value must be returned. The return value indicates whether or not the player is allowed to reload.
  216. -- Notes: If player is -1 then the weapon being reload wasn't located (it could be a vehicle's weapon)
  217. function OnWeaponReload(player, weapon)
  218.  
  219.         return 1
  220. end
  221.  
  222.  
  223. -- Called when a player attempts to enter a vehicle.
  224. -- A value must be returned. The return value indicates whether or not the player is allowed to enter.
  225. function OnVehicleEntry(player)
  226.  
  227.         return 1
  228. end
  229.  
  230. -- Called when damage is being done to an object. This doesn't always need to be a player.
  231. -- Do not return a value
  232. function OnDamageLookup(receiving_obj, causing_obj, tagdata, tagname)
  233.  
  234. end
  235.  
  236. -- Called when a player is being assigned a weapon (usually when they spawn)
  237. -- A value must be returned. The return value is the id of the weapon they're to spawn with. Return zero if the weapon shouldn't change.
  238. -- Notes:       This is called for all spawn weapons the player has
  239. --                      This is also called with player 255 when vehicles are being assigned weapons.
  240. --                      This is only considered if in gametype, the weapon set is 'generic' if not this has no effect.
  241. function OnWeaponAssignment(player, object, count, tag)
  242.  
  243.         return 0
  244. end
  245.  
  246. -- Called when a object is created, it may not always be for a player.
  247. -- Do not return a value.
  248. function OnObjectCreation(owningPlayer, owningObject, m_weapon, tag)
  249.  
  250. end
  251.  
  252. function OnClientUpdate(player, m_objectId)
  253.  
  254. end

HaloNet.Net is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.