Jump to content

[HELP] Tables.


Bilal135

Recommended Posts

Hi, so today I was trying to make some anti insult script. But this doesn't seem to work.

local badWord = { } 
      badWord[1] = "fuck" 
      badWord[2] = "bitch" 
function getMessage(message, messageType) 
         if messageType == 0 then 
         if message == badWord then 
         killPed(source) 
end 
end 
end 
addEventHandler("onPlayerChat", getRootElement(), getMessage) 

This one works but only with one word ("fuck")

local badWord = { } 
      badWord[1] = "fuck" 
      badWord[2] = "bitch" 
function getMessage(message, messageType) 
         if messageType == 0 then 
         if message == badWord[1] then 
         killPed(source) 
end 
end 
end 
addEventHandler("onPlayerChat", getRootElement(), getMessage) 

Do u guys have any solution for this?

Link to comment
local badWord = { } 
      badWord[1] = "fuck" 
      badWord[2] = "bitch" 
      badWord[3] = "fucktard" 
      badWord[4] = "fucker" 
      badWord[5] = "dickhead" 
      badWord[6] = "hijo de puta" 
      badWord[7] = "puta" 
  
function getMessage(message, messageType) 
         for placeNumber, stringData in ipairs(badWord) do 
         setPlayerMuted(source, true) 
         outputChatBox(getPlayerName(source).." Was Muted For Saying a Bad Word!", source) 
end 
end 
addEventHandler("onPlayerChat", getRootElement(), getMessage) 

Says the same thing 7 times.

Link to comment

You don't need a loop for such a small thing.

  
  
local badWord = { 
[":O" ]= true , 
["lol"] = true  
} 
  
local function getMessage(message, messageType) 
  
         if messageType == 0 then 
  
         if badWord[message] then 
  
         killPed(source) 
  
end 
  
end 
  
end 
  
addEventHandler("onPlayerChat", getRootElement(), getMessage) 
  

EDIT: Fixed a typo.

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...