#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" )
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,bind_cmd)
}
}