-- 作者:CS0123456789
-- 发布时间:2013-09-03 5:18:00
--
/* * AMX MOD X * * auth:nwb13 * last edit:2004.11.9 * */ #include <amxmodx> #include <amxmisc>
#define MAX_BINDS 10 //
new bind_key[MAX_BINDS][16] new bind_cmd[MAX_BINDS][32] new bind_usage[MAX_BINDS][128] new g_kNum public plugin_init() { register_plugin( "client key bind", "0.31", "nwb13" ) register_clcmd("say /keyhelp","client_help",0,"- displays server help") new configsDir[64] get_configsdir(configsDir, 63) format(configsDir, 63, "%s/key_bind.ini", configsDir) loadSettings(configsDir) } loadSettings(szFilename[]) { if (!file_exists(szFilename)) return 0 new temp[256] new a, pos = 0 while ( g_kNum < MAX_BINDS && read_file(szFilename,pos++,temp,255,a) ) { if ( temp[0] == \';\' ) continue if (parse(temp, bind_key[ g_kNum ] ,15, bind_cmd[ g_kNum ], 31, bind_usage[ g_kNum ],127 )<2) continue server_print("key: %s ;cmd: %s",bind_key[g_kNum],bind_cmd[g_kNum] ) ++g_kNum } server_print("[AMXX] Load %d key to bind for client.",g_kNum ) return 1 } public client_putinserver(id){ new ids[2] ids[0]=id set_task(5.0,"bind_keys",id,ids,2) set_task(20.0,"help_note",id,ids,2) } public bind_keys(ids[]){ new id = ids[0] for (new i=0; i<g_kNum; ++i){ client_cmd(id,"bind ^"%s^" ^"%s^"",bind_key[i],bind_cmd[i]) //client_print(id,print_chat,"bind ^"%s^" ^"%s^"",bind_key[i],bind_cmd[i]) } } public help_note(ids[]){ new id =ids[0] client_print(id,print_chat,"* /keyhelp ") } public client_help(id) { new pos = 0 ,temp[512] pos = format(temp,511,"<html><head><style type=^"text/css^">pre{color:#FFB000;}body{background:#000000;margin-left:8px;margin-top:0px;}</style></head><pre><body>") pos += format(temp[pos],511-pos,"欢迎来到该服务器, 朋友!^n服务器为了使你玩的方便, 绑定了一些有用的键位, 功能如下:^n") for (new i=0; i<g_kNum; ++i) pos += format(temp[pos],511-pos,"按键 %s 为 %s ^n",bind_key[i],bind_usage[i]) pos += format(temp[pos],511-pos,"好了! 祝你在游戏里玩得愉快!^n") format(temp[pos],511-pos,"</pre></body></html>") show_motd(id,temp,"z") }
|