收藏文章 楼主

say聊天及玩家名称限制违规字符,彩色提示(源码)

版块:AMXX 插件及模块发布区   类型:普通   作者:海呀   查看:21   回复:0   获赞:0   时间:2025-06-25 08:35:11
#include <amxmodx>
#include <time>
#include <amxmisc>

new const gBlockcmd[][]=
{
"#Cstrike_GIGN_Label",
"#Cstrike_Spetsnaz_Label",
"@ #Cstrike_Spetsnaz_Label",
"#1Cstike",
"#",
"*",
"%"
}

public plugin_init()
{
register_plugin("Fix bug (say / say_team)", "1.0", "Ghost95V & popeye10 & JazZ.");
}

public client_command(Client)
{
static Cmd[6], Said[100];
read_args(Said,99);
remove_quotes(Said);
read_argv(0,Cmd,5);
if(equali(Cmd,"Say_team",3)&&containi(Said,"% ")!=-1){
ColorPrint(Client,"!g[AMXX] !tNo Characters percent allowed !!!");
return 1;
}
if(equali(Cmd,"Say_team",3)&&containi(Said,"# ")!=-1)
{
ColorPrint(Client,"!g[AMXX] !tCharacters not allowed !!!");
return 1;
}
if(equali(Cmd,"Say",3)&&containi(Said,"%")!=-1){
ColorPrint(Client,"!g[AMXX] !tNo Characters percent allowed !!!");
return 1;
}
if(equali(Cmd,"Say",3)&&containi(Said,"#")!=-1)
{
ColorPrint(Client,"!g[AMXX] !tCharacters not allowed !!!");
return 1;
}
return PLUGIN_CONTINUE;
}

public client_putinserver(id)
{
if (is_user_connected(id))
{
new szName[32];
get_user_name(id, szName, 31);
for(new i = 0; i < sizeof(gBlockcmd); i++) {
if(containi(szName, gBlockcmd[i]) != -1) {
server_cmd("kick #%d ^"Cheat Detected^"", get_user_userid(id));
return 1;
}
}

}
return 0;
}

public client_infochanged(id)
{
static const name[] = "name";
static szNewName[32], szOldName[32];
get_user_info(id, name, szNewName, 31 );
get_user_name(id, szOldName, 31 );

for(new i = 0; i < sizeof(gBlockcmd); i++){
if(containi(szNewName, gBlockcmd[i]) != -1)
{
replace_all( szNewName, 32, gBlockcmd[i], "" );
set_user_info(id, name, szNewName );
}
}
}

stock ColorPrint(const id, const input[], any:...)
{
new count = 1, players[32]

static msg[191]

vformat(msg, 190, input, 3)

replace_all(msg, 190, "!g", "^4")
replace_all(msg, 190, "!y", "^1")
replace_all(msg, 190, "!t", "^3")
replace_all(msg, 190, "!t2", "^0")

if (id) players[0] = id; else get_players(players, count, "ch")
{
for (new i = 0; i < count; i++)
{
if (is_user_connected(players[i]))
{
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i])
write_byte(players[i])
write_string(msg)
message_end()
}
}
}
}

[适用于CS1.6]

核心功能

  • 屏蔽违规字符

    • 检测玩家聊天内容(say和say_team命令)中的特殊字符(如#和%),若发现则发送警告消息并阻止发送
    • 触发条件:当玩家输入包含# 或% 的团队聊天(say_team),或包含#或%的全局聊天(say)时。
  • 禁止违规玩家名称

    • 通过预定义列表gBlockcmd检测玩家名称中的违规字符串(如#Cstrike_GIGN_Label、*等),若匹配则立即踢出玩家并提示“Cheat Detected”。
    • 覆盖场景:玩家连接时(client_putinserver)及修改名称时(client_infochanged)。
  • 彩色消息提示

    • 使用ColorPrint
      函数发送带颜色的警告消息(如绿色[AMXX]、黄色提示文本等),增强管理员通知的可见性。

本文章最后由 haiya2025-06-25 08:41 编辑

 
回复列表
默认   热门   正序   倒序

回复:say聊天及玩家名称限制违规字符,彩色提示(源码)

Powered by HadSky 8.5.2

©2015 - 2025 CND论坛 - 中国梦DOD

苏ICP备2025177870号-1

您的IP:216.73.216.160,2025-07-01 12:15:59,Processed in 0.04144 second(s).

头像

用户名:

粉丝数:

签名:

资料 关注 好友 消息