|
发表于 2006-6-21 01:15:55
|
显示全部楼层
|阅读模式
来自 中国–广东–深圳–南山区
这插件不是对所有键绑定都有效果,比如F12绑定不了,还望高手修改下哈。我想把F1-F12绑定为:"say 告訴你小子,本服務器禁止作弊."還有把"home" "end" "insert" "pageup" "pagedown" "delete"也綁定為 "say 你想做幣嗎?"
- /*
- * 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") //鐜╁璇?keyhelp寮€甯姪
- 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,"* 鏈嶅姟鍣ㄧ粰浣犵粦瀹氫簡涓€浜涙寜閿? 璇锋寜 Y 杈撳叆 /keyhelp 鏉ユ煡鐪?) //鎻愮ず鐜╁璇?help
- }
- public client_help(id) { //褰撶帺瀹惰/keyhelp鍚庢樉绀虹殑鍐呭
- 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,"鏈嶅姟鍣ㄦ寜閿府鍔?)
- }
复制代码 |
|