As you may already know custom entities(created by amxx) are not taken into account by the dll, because it cache the ent list. So, if you create a weaponbox ent during a round and you want it to be deleted by the game it won't.
A solution my be to redo the WeaponBoxKill function, and to do the things as the game:
PHP Code:
void CWeaponBox::Kill( void )
{
CBasePlayerItem *pWeapon;
int i;
// destroy the weapons
for ( i = 0 ; i < MAX_ITEM_TYPES ; i++ )
{
pWeapon = m_rgpPlayerItems[ i ];
while ( pWeapon )
{
pWeapon->SetThink(&CBasePlayerItem::SUB_Remove);
pWeapon->pev->nextthink = gpGlobals->time + 0.1;
pWeapon = pWeapon->m_pNext;
}
}
// remove the box
UTIL_Remove( this );
}
Source:
https://github.com/alliedmodders/hls...ls/weapons.cpp
But I don't like to reinvent the wheel and by searching a bit I found that we can call with okapi/orpheu AddEntityHasValue for our custom entity so the game will take it into account.
From here the problem starts,
I think that this function use some unsuported param by okapi/orpheu.
Here is my code:
Code:
#include <amxmodx>
#include <okapi>
new funcAddEntityHasValue
public plugin_init()
{
new okapiHandleFunc
new const AddEntityHasValueSymbol[ ] = "AddEntityHashValue__FP9entvars_sPCc12hash_types_e"
new const AddEntityHasValueSignature[ ] = {0x56,0x57,0xDEF,0xDEF,0xDEF,0xDEF,0x57,0xDEF,0xDEF,0xDEF,0xDEF,0xDEF,0xDEF,0x8B,0xF0,0x83}
if
(
(okapiHandleFunc = okapi_mod_get_symbol_ptr(AddEntityHasValueSymbol)) ||
(okapiHandleFunc = okapi_mod_find_sig(AddEntityHasValueSignature, charsmax(AddEntityHasValueSignature)))
)
{
funcAddEntityHasValue = okapi_build_function(okapiHandleFunc, arg_entvars, arg_string, .... )
}
}
The function header is:
Code:
AddEntityHashValue(entvars_s *,char const *,hash_types_e)
In okapi_const I didn't found an argument for hash_types_e so I think it's not suported. Correct me if I'm wrong. I also think if the windows signature is correct, can't test until my code is ready.
My question is: it's possible to register that function with okapi/orpheu so I can call it on my custom entity and solve the problem ? If not, do you have another alternative( without re-doing the c++ code ), which is here if anyone needs it:
Code:
if(!pev_valid(wpnBoxEnt))
{
return
}
new iWpnIndex
for(new Iter; Iter < MAX_ITEM_TYPES; Iter++)
{
iWpnIndex = get_pdata_cbase(wpnBoxEnt, m_rgpPlayerItems[Iter], XO_CWEAPONBOX)
if(pev_valid(iWpnIndex))
{
set_pev(iWpnIndex, pev_flags, FL_KILLME)
}
}
//Maybe better to call think on this weaponbox ?
set_pev(wpnBoxEnt, pev_flags, FL_KILLME)
__________________