ITEM_FLAG_EXHAUSTIBLE flag usage

Сообщения
219
Реакции
42
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
Код:
#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);
}
 
Сообщения
1,668
Реакции
1,495
Помог
24 раз(а)
You need to use item info flags, not entvar. Try to use:
Код:
    /*
    * Description:      -
    * Return type:      int
    * Get params:       rg_get_iteminfo(const ent, ItemInfo_iFlags);
    * Set params:       rg_set_iteminfo(const ent, ItemInfo_iFlags, const value);
    */
    ItemInfo_iFlags,
28 Мар 2020
Код:
public fw_Item_AddToPlayer_Post(ent, id)
{
    new iActiveItem = get_pdata_cbase(id, m_pActiveItem)
ent == iActiveItem
 
Сообщения
1,668
Реакции
1,495
Помог
24 раз(а)
Ok. Why do you need activeitem there?
Use ham instead reapi natives.
 
Сообщения
1,668
Реакции
1,495
Помог
24 раз(а)
SetHamItemInfo or SetHamParamItemInfo
 
Сообщения
1,668
Реакции
1,495
Помог
24 раз(а)
Скажите ему, что без регеймдлл не будет работать?
 
Сообщения
219
Реакции
42
SetHamItemInfo or SetHamParamItemInfo
Finally working
Код:
#include < amxmodx >
#include < cstrike >
#include < engine >
#include < fakemeta >
#include < hamsandwich >

// Flags
//const ITEM_FLAG_EXHAUSTIBLE = 16   // A player can totally exhaust their ammo supply and lose this weapon

public plugin_init( ) {
    register_plugin( "BPAmmo on Weapon", "0.1", "RauliTop" );
  
    register_clcmd("say /test", "clcmd_saytest");
    RegisterHam(Ham_Item_GetItemInfo, "weapon_usp", "fw_Item_GetItemInfo", 1);
}

public clcmd_saytest(id)
{
    cs_set_user_bpammo(id, CSW_USP, 0)
}

public fw_Item_GetItemInfo(pItem, iItemInfo)
{
    SetHamItemInfo(iItemInfo, Ham_ItemInfo_iFlags, ITEM_FLAG_EXHAUSTIBLE)
}
Скажите ему, что без регеймдлл не будет работать?
Yes, GSClient has installed.
 

Пользователи, просматривающие эту тему

Сейчас на форуме нет ни одного пользователя.
Сверху Снизу