Jump to content

Remplazar palabras en onPlayerChat


Sasu

Recommended Posts

Posted
local badWords = {puto, marica} --Perdonen por las palabras ._. 
  
addEventHandler("onPlayerChat", root, 
function(msg) 
if string.find(msg, badWords[msg]) then 
--Aqui remplazar las malas palabras por *(cuantas letras tenga) por ejemplo -> puto -> **** o marica -> ****** 
end 
end 
) 

Como puedo remplazar malas palabras por asteriscos?

State: Inactive

Posted

Ese codigo esta mal, vas a tener que buscar cada palabra en el mensaje que escribio.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
string.gsub(variableAModificar, patronABuscar, patronaReemplazar) 
-- Ejemplo 
string.gsub("hola ke ase gato ase loco", "ase", "*****") 
-- Resultado: hola ke gato loco 

Para reemplazar por la cantidad de letras (no se si funcionara de todas formas, prueba a ver si va esto

string.gsub(oracion, palabraInsultativa[i], crearInsulto(#palabraInsultativa[i]) 
  
function crearInsulto(q) 
     local olakase = "" 
     for i = 1, q do 
           olakase = olakase .. "*" 
     end 
     return olakase 
end 

Posted

Tambien puede usar:

local str = "HOLA MUNDO" 
local str = str:rep ( "*", str:len ( ) ) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

  • Recently Browsing   0 members

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