PDA

View Full Version : Censor script?



Kemi
30th November 2015, 15:55
Was trying to make a script to censor swear words
Here's my script:


censor(string)
{
filehandle = FS_FOpen("badwords.txt", "read");
while(badword != undefined)
{
badword = FS_ReadLine(filehandle);
msg = StrRepl(string, badword, "******"));
}
return msg;
}

Trying to make it that only admins with ranks of 40+ can swear, anyone else it will be censored.
This is just as a test, not something I actually plan to implement into the server.
Just wanted to know if it's bad to use the FS_ReadLine command in a loop such as that and if there would be any problems if I did without a large wait.

kung foo man
30th November 2015, 19:48
Since you want to access/rewrite the chat messages, you gonna need libcod: http://killtube.org/showthread.php?1201-Extension-Player-Command-Control-%28includes-CHAT-Control-for-Builtin-B3!%29

And once you got that, I suggest using libcod file functions: http://killtube.org/showthread.php?1877-Added-scandir-fopen-fread-fwrite-fclose

Then you just parse the badwords.txt file once and keep the array data in like level.badwords

Kemi
1st December 2015, 22:06
Since you want to access/rewrite the chat messages, you gonna need libcod: http://killtube.org/showthread.php?1201-Extension-Player-Command-Control-%28includes-CHAT-Control-for-Builtin-B3!%29

And once you got that, I suggest using libcod file functions: http://killtube.org/showthread.php?1877-Added-scandir-fopen-fread-fwrite-fclose

Then you just parse the badwords.txt file once and keep the array data in like level.badwords
Fixed.
Thanks for the help :)