0 Members and 5 Guests are viewing this topic.
//configconst NumWarnings = 3; //number of times a player can curse before getting kicked or banned FileName = 'BadWordsList.txt'; //file which holds the badwords, each seperated with a space Ban = false; //When a player reaches the curse limit, ban the player? (true or false) KillOnOffense = true; //With each offense, kill the player? (true or false) TextColor = $ffff00001; //color of messages told to player BanLength = 15; //minutes a player will be banned for, if the Ban = true;//......//whenever someone says something, check it.procedure OnPlayerSpeak(PlayerID: Byte; Text: string);var i: integer;var Bad: boolean;begin //do we any badwords to check? if not HaveBadWords then exit; //for now, make it false Bad := false; //check it! for i := 0 to GetArrayLength(BadWords) - 1 do begin //if it is a bad word, make it known that we cursed if ContainsString(UpperCase(Text), BadWords[i]) then //we're making what they said upercase so the badwords are case insensitive Bad := true; end; //saying something naughty? if Bad then begin //increase number of warnings used inc(Warnings[PlayerID], 1); //reached limit if Warnings[PlayerID] = NumWarnings then begin //reset limit for this id Warnings[PlayerID] := 0; //Ban or kick? if Ban then begin BanPlayer(PlayerID, 15); exit; end; KickPlayer(PlayerID); exit; end; //under limit.. if Warnings[PlayerID] < NumWarnings then begin //should we kill him / her? if KillOnOffense then DoDamage(PlayerID, 4000); //notify player of this WriteConsole(PlayerID, 'You have been warned for offensive language.', TextColor); WriteConsole(PlayerID, 'If you curse '+inttostr(NumWarnings - Warnings[PlayerID])+' more time(s), you will be '+iif(Ban,'banned','kicked')+'.', TextColor); end; end;end;
Edit: The swear filter works - partly
Quote from: Markus Quär on July 24, 2008, 05:47:15 pmEdit: The swear filter works - partlyWhat do you mean 'partly'? I spent a while making sure it didn't have bugs, but seeing as this is my second pascal program bugs are likely.
Now I see what you are saying about the regex, can someone please point me in the direction I need to go to rewrite the word detecting part of the program? Thanks in advance.
Anyhoo I made a suggestion for EnEsCe in the suggestions thread that you should be able to modify the result of OnPlayerSpeak and similar things, so that you could actually filter stuff instead of just warning people.
Quote from: Markus Quär on July 24, 2008, 05:47:15 pmEdit: The swear filter works - partlyWhat do you mean 'partly'? I spent a while making sure it didn't have bugs, but seeing as this is my second pascal program bugs are likely.Now I see what you are saying about the regex, can someone please point me in the direction I need to go to rewrite the word detecting part of the program? Thanks in advance.