|
发表于 2006-11-22 20:25:02
|
显示全部楼层
|阅读模式
来自 中国–福建–福州
各位兄弟,我用CS1.5服务器,AMXX1.71测试了"客户端执行client_exec",结果如下:
1:当玩家连接游戏时,执行 client_exec_on_connect.cfg 中的内容正常执行.
2:进入游戏与出生时,执行 client_exec_on_putinserv.cfg 中的内容全部全失效.不知道是不是这个插件还不支持CS1.5,希望可以像以前的ADMIN.SMA文件一样,能修改一下,支持一下我们CS1.5吧.谢谢您.
原代码如下:
/* Client Exec When Connect or Put In Server */
/*
* Client exec some commands when connect or put in server.
*
* The config files are "client_exec_on_connect.cfg" and "client_exec_on_putinserv.cfg"
* in AMX Mod X configs dir.
*
*/
#include <amxmodx>
#include <amxmisc>
// don't exec commands on loopback
#define LOOPBACK_NOT_EXEC 1
new const PLUGIN_NAME[] = "Client Exec When Connect or Put In Server"
new const PLUGIN_VERSION[] = "1.0"
new const PLUGIN_AUTHOR[] = "KinSprite"
new const cfg_file_connect[] = "client_exec_on_connect.cfg"
new const cfg_file_putinserv[] = "client_exec_on_putinserv.cfg"
#define MAX_EXEC_CHARS 128
#define MAX_EXEC_LINES_CONNECT 128
#define MAX_EXEC_LINES_PUTINSERV 128
new const cl_exec_connect[MAX_EXEC_LINES_CONNECT][MAX_EXEC_CHARS]
new const cl_exec_putinserv[MAX_EXEC_LINES_PUTINSERV][MAX_EXEC_CHARS]
new g_execNum_connect
new g_execNum_putinserv
new g_client_exec
public plugin_init() {
register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)
register_event("ResetHUD", "player_spawn", "b")
g_client_exec = register_cvar("amx_client_exec", "1")
}
public plugin_cfg() {
set_task(2.0, "read_exec_cfg")
}
public read_exec_cfg() {
new cfg_dir[128], cfg_path[192], is_on_connect, max_lines, max_chars
get_configsdir(cfg_dir, 127)
max_chars = MAX_EXEC_CHARS
format(cfg_path, 191, "%s/%s", cfg_dir, cfg_file_connect) // connect to server
is_on_connect = 1
max_lines = MAX_EXEC_LINES_CONNECT
g_execNum_connect = read_lines(cfg_path, is_on_connect, max_lines, max_chars)
format(cfg_path, 191, "%s/%s", cfg_dir, cfg_file_putinserv) // put in server
is_on_connect = 0
max_lines = MAX_EXEC_LINES_PUTINSERV
g_execNum_connect = read_lines(cfg_path, is_on_connect, max_lines, max_chars)
}
stock read_lines(filepath[], is_on_connect, read_max_lines, max_chars) {
if (!file_exists(filepath))
return 0
new line, curline, txtlen
new max_line = file_size(filepath, 1)
new no_end = 1
while (no_end) {
curline = line
if (is_on_connect)
line = read_file(filepath, line, cl_exec_connect[curline], max_chars, txtlen)
else
line = read_file(filepath, line, cl_exec_putinserv[curline], max_chars, txtlen)
if (line==0 || line==max_line || max_line == read_max_lines)
no_end = 0
}
return curline + 1
}
public client_connect(id) {
if (!get_pcvar_num(g_client_exec) || is_user_bot(id))
return PLUGIN_CONTINUE
#if LOOPBACK_NOT_EXEC == 1
if (is_user_loopback(id))
return PLUGIN_CONTINUE
#endif
for (new i = 0; i < g_execNum_connect; ++i)
client_cmd(id, cl_exec_connect)
return PLUGIN_CONTINUE
}
public client_putinserver(id) {
if (!get_pcvar_num(g_client_exec) || is_user_bot(id))
return PLUGIN_CONTINUE
#if LOOPBACK_NOT_EXEC == 1
if (is_user_loopback(id))
return PLUGIN_CONTINUE
#endif
for (new i = 0; i < g_execNum_putinserv; ++i)
client_cmd(id, cl_exec_putinserv)
return PLUGIN_CONTINUE
}
public player_spawn(id) {
if (!get_pcvar_num(g_client_exec) || is_user_bot(id))
return PLUGIN_CONTINUE
#if LOOPBACK_NOT_EXEC == 1
if (is_user_loopback(id))
return PLUGIN_CONTINUE
#endif
for (new i = 0; i < g_execNum_putinserv; ++i)
client_cmd(id, cl_exec_putinserv)
return PLUGIN_CONTINUE
}
#if LOOPBACK_NOT_EXEC == 1
stock is_user_loopback(id)
{
new ips[32]
get_user_ip(id, ips, 31, 1)
return equal(ips, "loopback")
}
#endif |
|