您好:
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