#pragma semicolon 1
#include <amxmodx>
#include <hamsandwich>
#include <reapi>
public plugin_init()
{
register_clcmd("weapon_deagle", "@Command_WeaponDeagle");
RegisterHookChain(RG_CBasePlayer_GiveAmmo, "@CBasePlayer_GiveAmmo_Pre", false);
RegisterHam(Ham_Spawn, "weapon_usp", "@CUSP_Spawn_Post", true);
RegisterHam(Ham_Item_AddToPlayer, "weapon_usp", "@CUSP_AddToPlayer_Post", true);
RegisterHam(Ham_Weapon_Reload, "weapon_usp", "@CUSP_Reload_Pre", false);
}
@Command_WeaponDeagle(id)
{
engclient_cmd(id, "weapon_usp");
return PLUGIN_HANDLED;
}
@CBasePlayer_GiveAmmo_Pre(id, amount, name[], max)
{
// usp check
SetHookChainArg(3, ATYPE_STRING, "50AE");
}
@CUSP_Spawn_Post(id)
{
rg_set_iteminfo(id, ItemInfo_pszAmmo1, "50AE");
rg_set_iteminfo(id, ItemInfo_iMaxAmmo1, 35);
rg_set_iteminfo(id, ItemInfo_iMaxClip, 7);
}
@CUSP_AddToPlayer_Post(id, player)
{
SendWeaponList
(
player,
"weapon_deagle",
get_member(id, m_Weapon_iPrimaryAmmoType),
rg_get_iteminfo(id, ItemInfo_iMaxAmmo1),
-1,
-1,
1,
4,
get_member(id, m_iId),
0
);
}
@CUSP_Reload_Pre(id)
{
new player = get_member(id, m_pPlayer);
// Avoid the check
// https://github.com/s1lentq/ReGameDLL_CS/blob/master/regamedll/dlls/wpn_shared/wpn_usp.cpp#L248
set_member(player, ammo_45acp, 1);
}
SendWeaponList(id, const name[], ammo1, maxAmmo1, ammo2, maxAmmo2, slot, position, any:weaponId, flags)
{
static msg;
if (!msg)
msg = get_user_msgid("WeaponList");
message_begin(MSG_ONE, msg, _, id);
write_string(name);
write_byte(ammo1);
write_byte(maxAmmo1);
write_byte(ammo2);
write_byte(maxAmmo2);
write_byte(slot);
write_byte(position);
write_byte(weaponId);
write_byte(flags);
message_end();
}