|
发表于 2012-12-24 11:36:29
|
显示全部楼层
来自 中国–浙江–杭州
- #include <amxmodx>
- #include <amxmisc>
- #define PLUGIN "Shield"
- #define VERSION "1.0"
- #define AUTHOR "k1nader"
- #define LOADING "^n^t%s v%s, Copyright (C) 2012 by %s^n"
- new configfile[64];
- public plugin_init()
- {
- register_plugin(PLUGIN, VERSION, AUTHOR);
- server_print(LOADING, PLUGIN, VERSION, AUTHOR);
- register_clcmd("say", "say_hook");
- register_clcmd("say_team", "say_hook");
-
- get_configsdir(configfile, charsmax(configfile));
- formatex(configfile, charsmax(configfile), "%s/shield.ini", configfile);
- // Add your code here...
- }
- public say_hook(id)
- {
- new text[512], onshow[32];
- read_args(text, charsmax(text));
- remove_quotes(text);
- if(is_containi(text, onshow, charsmax(onshow)))
- {
- client_print(id, print_chat, "此次发言中包含敏感词汇:%s", onshow);
- return PLUGIN_HANDLED;
- }
- return PLUGIN_CONTINUE;
- }
- public client_connect(id)
- {
- new name[32], onshow[32];
- get_user_name(id, name, charsmax(name));
- if(is_containi(name, onshow, charsmax(onshow)))
- kick_player(id, "名字中包含敏感词汇:%s", onshow);
- }
- public client_infochanged(id)
- {
- new name[32], onshow[32];
- get_user_info(id, "name", name, charsmax(name));
- if(is_containi(name, onshow, charsmax(onshow)))
- kick_player(id, "名字中包含敏感词汇:%s", onshow);
- }
- bool:is_containi(const szname[], result[], resultlen)
- {
- new bool:result_boolean = false;
- if (file_exists(configfile))
- {
- new message[32], len, line = 0;
- while(read_file(configfile, line++, message, charsmax(message), len))
- {
- if(containi(szname, message) != -1)
- {
- formatex(result, resultlen, message);
- result_boolean = true;
- break;
- }
- }
- }
- return result_boolean;
- }
- stock kick_player(id, Message[], any:...)
- {
- new msg_content[512];
- vformat(msg_content, 511, Message, 3);
- message_begin(MSG_ONE, SVC_DISCONNECT, {0,0,0}, id);
- write_string(msg_content);
- message_end();
- }
复制代码 未测试,使用方法:
在config文件夹内创建 shield.ini 的文件。
一行一个你需要屏蔽的词汇。 |
|