Raised This Month: $ Target: $400
 0% 

AddEntityHasValue mod func


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 11-12-2014 , 11:18   AddEntityHasValue mod func
Reply With Quote #1

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::Killvoid )
{
    
CBasePlayerItem *pWeapon;
    
int i;

    
// destroy the weapons
    
for ( MAX_ITEM_TYPES i++ )
    {
        
pWeapon m_rgpPlayerItems];

        while ( 
pWeapon )
        {
            
pWeapon->SetThink(&CBasePlayerItem::SUB_Remove);
            
pWeapon->pev->nextthink gpGlobals->time 0.1;
            
pWeapon pWeapon->m_pNext;
        }
    }

    
// remove the box
    
UTIL_Removethis );

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)
__________________

Last edited by HamletEagle; 11-12-2014 at 11:26.
HamletEagle is offline
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 17:34.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode