您好:
1.若您是属于个人使用.
在您config.cfg 内新增 bind "按键" "参数" (例如:bind "F3" "amx_menu" )
2.若是属于伺服器使用.
必须使用额外插件来强制设定.
复制程式
#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.1", "UNetHost" )
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("[UNetHost] Load %d key to bind for client.",g_kNum )
return 1
}
public client_putinserver(id)
{
new ids[2]
ids[0]=id
set_task(3.0,"bind_keys",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])
}
}
addons/amxmodx/configs 新增 key_bind.ini