|
发表于 2007-4-24 03:57:44
|
显示全部楼层
|阅读模式
来自 中国–广西–柳州–柳南区
由于对名字字符检测不懂,所以通过对名字长度的检测有没有SXE,可测试总没通过,请各位指点指点,谢谢。源代码:#include <amxmodx>
#include <amxmisc>
#define PLUGIN "Advanced Motd"
#define VERSION "1.2"
#define AUTHOR "KinSprite"
#define MAX_MOTD_SUPPORT 5
#define MOTD_FOLDER "motd"
#define MOTD_HEADER_CONFIG "motd_header.cfg"
new g_advancedmotd
new motd[MAX_MOTD_SUPPORT][1200]
new motd_header[MAX_MOTD_SUPPORT][32]
new max_motd
new showmotd_counter[33]
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_concmd("amx_reloadmotd","cmd_reloadmotd",ADMIN_IMMUNITY," - reload Advanced Motd")
g_advancedmotd = register_cvar("amx_advancedmotd","1")
set_task(1.2,"load_motd")
register_event("DeathMsg", "show_Advmotd","a")
register_cvar( "amx_namelen", "10")
return PLUGIN_CONTINUE
}
public load_motd(id)
{
new cfg_path[128]
get_configsdir(cfg_path,127)
new motd_path[160]
format(motd_path,159,"%s/%s",cfg_path,MOTD_FOLDER)
new path[64]
new handle = open_dir(motd_path,path,63)
if(handle!=0)
{
new buff[MAX_MOTD_SUPPORT+2][64]
new i
for(i=0;i<MAX_MOTD_SUPPORT+2;i++)
{
if(next_file(handle, buff, 63))
max_motd++
else
continue
}
close_dir(handle)
max_motd-- // include parent dir,so max_motd -1
new path_name[256]
for(i=0;i<max_motd;i++)
{
format(path_name,255,"%s/%s",motd_path,buff[i+1])
read_motdfile(path_name,motd)
}
}
return PLUGIN_HANDLED
}
// read motd file into memory; not nead to read file again every show motd.
stock read_motdfile(filename[],out_text[])
{
new handle = fopen(filename,"rt")
if(handle!=0)
{
new line_len = file_size(filename,1)
new text_buff[1200],buffer[1024]
new line
for(;line<line_len;line++)
{
fgets(handle, buffer, 1023)
add(text_buff,1199,buffer)
}
fclose(handle)
copy(out_text,1199,text_buff)
}
}
public cmd_reloadmotd(id,level,cid)
{
if (!cmd_access(id, level, cid, 1))
return PLUGIN_HANDLED
}
public show_Advmotd(id)
{
new szName[32];
get_user_info( id, "name", szName, 31);
new nMaxLen = get_cvar_num("amx_namelen");
if( strlen( szName) > nMaxLen)
{
new player = read_data(2)
new param[2]
param[0]=player
set_task(1.8,"client_show_motd",5532+player,param,1)
}
return PLUGIN_HANDLED
}
public client_show_motd(param[])
{
new counter = showmotd_counter[param[0]]
show_motd(param[0],motd[counter],motd_header[counter])
} |
|