Left 4 Dead 2

Left 4 Dead 2

Talking shit in chat attracts infected
kurochama 9 月 11 日 上午 10:29
A random idea suggestion for an alternative
I noticed that some people wished to have another one that punishes people when using bad words. So, I'd like to give you some few hints in case if you're interested. I used this trick on my other mods to create some configurable chat commands. You can use this trick to make that alternative version:
function OnGameEvent_player_say(event) { local entDamage = {} local kent = GetPlayerFromUserID(event.userid); local chat = null; if("text" in event) { chat = event["text"]; local files = FileToString(cfgfilename); if(!files) return; local toggles = split(files, "\r\n"); if(kent.GetZombieType() == 9) { foreach(toggle in toggles) { if(toggle && toggle != "" && toggle != "//") { toggle = strip(toggle); //if this word is found, trigger the penalty if(chat.find(toggle) != null) { //just an example, you can use "RushVictim" too for the friendlier penalty kent.HitWithVomit(); //another alternative penalty if(toggle.find("tank") != null) { ZSpawn( { type = 8, pos = (kent.GetOrigin() + Vector(0,0,1) + (kent.GetAngles().Forward() * 50)) } ); } if(toggle.find("motherf") != null) { //spawns an angry witch in front of the culprit ZSpawn( { type = 7, pos = (kent.GetOrigin() + Vector(0,0,1) + (kent.GetAngles().Forward() * 50)) } ); for(local witch; witch = Entities.FindByClassnameWithin(witch, "witch", kent.GetOrigin(), 100); ) { if(NetProps.GetPropFloat(witch, "m_rage") < 1.0) { NetProps.SetPropFloat(witch, "m_rage", 1.0); if(IsPlayerABot(kent)) { CommandABot({ cmd = DirectorScript.BOT_CMD_ATTACK, bot = witch, target = kent }); } else { CommandABot({ cmd = DirectorScript.BOT_CMD_ATTACK, bot = witch, target = kent }); witch.TakeDamage(1,6,kent); } } if(NetProps.GetPropFloat(witch, "m_wanderrage") < 1.0) { NetProps.SetPropFloat(witch, "m_wanderrage", 1.0); } } } } } } } } }

As you can see, the idea is to make the "player_say" event function to load the content in the cfg file. However, as each word on the cfg file will be read, you have at least 2 options:
  1. Manually add the forbidden words (see the "another alternative penalty" for the formats): You can add explanations on this option, but the bad words are limited to only what you write on the vscript file. People can't add more bad words & they need to make suggestions to you about what words to add.
  2. Let people freely add words: People can list forbidden words freely, but you can't add explanations in the cfg file, as those explanations will also be read as the forbidden words when typing the same words in the chat.

You can make experiments on the examples above. Probably you might need to edit too, as I wrote it spontaneously without checking first. Normally it should work. If it doesn't just check the console as usual.
< >
正在显示第 1 - 3 条,共 3 条留言
RoninMac 9 月 17 日 下午 7:16 
Holy mole
Mapleleaf11 9 月 24 日 下午 3:24 
excuse me did you just leak pentagon files
Alexei Tarasov 10 月 14 日 上午 3:54 
guys what the h*ck!!! dont say bad wors my mama is nera!!111
< >
正在显示第 1 - 3 条,共 3 条留言
每页显示数: 1530 50