I'm trying to set ITEM_FLAG_EXHAUSTIBLE to a weapon.
The objective is pack ammo for dropped weapon:
https://github.com/s1lentq/ReGameDLL_CS/issues/520#issuecomment-599097794
I think it can be achive by hooking DropPlayerItem in Orpheu or ReAPI.
But I'm trying another method:
Apply the flag when getting the weapon
Why isn't working?
Function is called. But after dropping, write /test and pickup weapon; his bpammo is 0
The objective is pack ammo for dropped weapon:
https://github.com/s1lentq/ReGameDLL_CS/issues/520#issuecomment-599097794
I think it can be achive by hooking DropPlayerItem in Orpheu or ReAPI.
But I'm trying another method:
Apply the flag when getting the weapon
Why isn't working?
Function is called. But after dropping, write /test and pickup weapon; his bpammo is 0
Код:
#include < amxmodx >
#include < cstrike >
#include < engine >
#include < fakemeta >
#include < hamsandwich >
// Flags
const ITEM_FLAG_EXHAUSTIBLE = (1<<4) // A player can totally exhaust their ammo supply and lose this weapon
// Offset
const m_pActiveItem = 373
#define XO_PLAYER 5
#define MAX_WEAPON_SLOTS 6
new const m_rgpPlayerItems[ MAX_WEAPON_SLOTS ] = { 367, 368, ... };
public plugin_init( ) {
register_plugin( "BPAmmo on Weapon", "0.1", "RauliTop" );
register_clcmd("say /test", "clcmd_saytest");
register_clcmd("say /test2", "clcmd_saytest2");
RegisterHam(Ham_Item_AddToPlayer, "weapon_usp", "fw_Item_AddToPlayer_Post", 1);
}
public clcmd_saytest(id)
{
cs_set_user_bpammo(id, CSW_USP, 0)
}
public clcmd_saytest2(id)
{
new iEnt, szWeapon[32]
for( new i = 1 ; i < MAX_WEAPON_SLOTS ; i ++ )
{
iEnt = get_pdata_cbase( id, m_rgpPlayerItems[ i ], XO_PLAYER );
if( iEnt > 0 )
{
entity_get_string( iEnt, EV_SZ_classname, szWeapon, charsmax( szWeapon ) );
client_print(0, print_chat, "rgpPlayerItems: %d %s", iEnt, szWeapon)
}
}
new weapon = find_ent_by_owner(-1, "weapon_usp", id)
client_print(0, print_chat, "find: %d", weapon)
}
public fw_Item_AddToPlayer_Post(ent, id)
{
new iActiveItem = get_pdata_cbase(id, m_pActiveItem)
//if (!iActiveItem) return;
client_print(0, print_chat, "AddToPlayer. ent = %d ActiveItem = %d", ent, iActiveItem)
entity_set_int(ent, EV_INT_flags, entity_get_int(ent, EV_INT_flags) | ITEM_FLAG_EXHAUSTIBLE);
}