/* AMX Mod X
* HL Change Weapon Slot
*
* http://aghl.ru/forum/ - Russian Half-Life and Adrenaline Gamer Community
*
* This file is provided as is (no warranties)
*/
#pragma semicolon 1
#pragma ctrlchar '\'
#include <amxmodx>
#include <amxmisc>
#include <hlsdk_const>
#define PLUGIN "HL Change Weapon Slot"
#define VERSION "1.0"
#define AUTHOR "KORD_12.7 & DJ_WEST"
new Trie: g_WpnSlot, Trie: g_WpnSlotPosition;
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR);
new filepath[128]; get_configsdir(filepath, charsmax(filepath));
add(filepath, charsmax(filepath), "/weapon_slot.ini");
new file = fopen(filepath, "rt");
if (!file) return PLUGIN_CONTINUE;
g_WpnSlot = TrieCreate();
g_WpnSlotPosition = TrieCreate();
new buffer[32], wpnname[19], slot[2], position[3];
while (!feof(file))
{
fgets(file, buffer, charsmax(buffer));
trim(buffer) ;
if (buffer[0] != ';' && buffer[0] > 0)
{
parse(buffer, wpnname, charsmax(wpnname), slot, charsmax(slot), position, charsmax(position));
TrieSetCell(g_WpnSlot, wpnname, str_to_num(slot));
TrieSetCell(g_WpnSlotPosition, wpnname, str_to_num(position));
}
}
fclose(file);
register_message(get_user_msgid("WeaponList"), "HookWeaponList");
return PLUGIN_CONTINUE;
}
public plugin_end()
{
TrieDestroy(g_WpnSlot);
TrieDestroy(g_WpnSlotPosition);
}
public HookWeaponList(msg_id, msg_dest, msg_entity)
{
new WeaponName[19], SlotID, NumberInSlot;
get_msg_arg_string(1, WeaponName, charsmax(WeaponName));
if (TrieGetCell(g_WpnSlot, WeaponName, SlotID))
set_msg_arg_int(6, 0, SlotID - 1);
if (TrieGetCell(g_WpnSlotPosition, WeaponName, NumberInSlot))
set_msg_arg_int(7, 0, NumberInSlot - 1);
return PLUGIN_CONTINUE;
}