View Single Post
kadet.89
Veteran Member
Join Date: Nov 2012
Location: Serbia
Old 06-16-2021 , 14:27   Re: [CS:GO] Crash after giving weapon_healthshot
Reply With Quote #7

"game_type" = "0"
"game_mode" = "0"
Iteration code is written in c++:

PHP Code:
void CPlayer::OnPlayerRunCmd(CUserCmd/*cmd*/void/*moveHelper*/)
{
    for(
int i 0!= MAX_WEAPONS_CSGO; ++i)
    {
        
CBaseEntityweapon GetMyWeaponHandle(i);
        if(!
weapon)
            continue;

        
std::string name(weapon->GetClassName());
        if (
name.rfind("weapon_"0) == 0)
            continue;

        if (
name.rfind("item_"0) == 0)
            continue;

        const 
int index weapon->Index();

        
LogMsg("Improper item \"%s\" with index %i in the invenory of %s"name.c_str(), indexGetName());
    }

    
RETURN_META(MRES_IGNORED);


Here is what under the hood of the GetMyWeaponHandle function:
PHP Code:
CFakeHandleCBaseCombatCharacter::GetMyWeaponHandle(int index) const
{
    return 
m_hMyWeapons[index];

PHP Code:
class CFakeHandle : public CBaseHandle
{
public:
    
operator CBaseEntity* () const
    {
        if (!
IsValid())
            return 
nullptr;

        const 
int index GetEntryIndex();

        const 
cell_t ref gamehelpers->IndexToReference(index);
        if(
ref == -1)
            return 
nullptr;

        return 
gamehelpers->ReferenceToEntity(ref);
    }
}; 

Last edited by kadet.89; 06-16-2021 at 16:00.
kadet.89 is offline
Send a message via Skype™ to kadet.89