Weapon script reloading in Source SDK

In Source SDK you have to restart after editing a weapon script, this can be a pain when messing around with ammo or custom features you've added. I'm not 100% sure if everything works after reloading the script but it sure helps.

First of all we're going to add a function called ReloadScheme to the basecombatweapon class so in basecombatweapon_shared.h add this in the public section:

virtual void ReloadScheme()
    ReadWeaponDataFromFileForSlot(filesystem, GetClassname(), &m_hWeaponFileInfo, GetEncryptionKey(), true);

also make sure this is at the top:

#include "weapon_parse.h"

in weapon_parse.h add a reset boolean to ReadWeaponDataFromFileForSlot like so:

// The weapon parse function
bool ReadWeaponDataFromFileForSlot( IFileSystem* filesystem, const char *szWeaponName, 
    WEAPON_FILE_INFO_HANDLE *phandle, const unsigned char *pICEKey = NULL, bool reset = false );

then in the code for the function in weapon_parse.cpp add a check for the reset boolean:

if (reset)
    unsigned short lookup = m_WeaponInfoDatabase.Find(szWeaponName);
    if (lookup != m_WeaponInfoDatabase.InvalidIndex())
        delete m_WeaponInfoDatabase[lookup];

under the return false at the top of the function. Then to wrap it all together add the console command to the top of the basecombatweapon_shared.cpp file within #if !defined( CLIENT_DLL )

void CC_ReloadScript(void)
    CBasePlayer* pPlayer = UTIL_GetCommandClient();
    if (pPlayer == NULL)

    CBaseCombatWeapon *pWeapon = pPlayer->GetActiveWeapon();
    if (pWeapon == NULL)


static ConCommand weapon_reloadscript("weapon_reloadscript", CC_ReloadScript);