Fixed custom weapon scripts on client

This commit is contained in:
Peter Covington 2022-04-18 17:24:41 -04:00
parent 332856e37e
commit f58b599020
2 changed files with 11 additions and 2 deletions

View File

@ -151,6 +151,13 @@ int C_BaseCombatWeapon::GetWorldModelIndex( void )
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void C_BaseCombatWeapon::OnDataChanged( DataUpdateType_t updateType ) void C_BaseCombatWeapon::OnDataChanged( DataUpdateType_t updateType )
{ {
#ifdef MAPBASE
if (updateType == DATA_UPDATE_CREATED)
{
Precache();
}
#endif // MAPBASE
BaseClass::OnDataChanged(updateType); BaseClass::OnDataChanged(updateType);
CHandle< C_BaseCombatWeapon > handle = this; CHandle< C_BaseCombatWeapon > handle = this;

View File

@ -164,7 +164,9 @@ void CBaseCombatWeapon::GiveDefaultAmmo( void )
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void CBaseCombatWeapon::Spawn( void ) void CBaseCombatWeapon::Spawn( void )
{ {
#if !defined(CLIENT_DLL) || !defined(MAPBASE)
Precache(); Precache();
#endif // !defined(CLIENT_DLL) || !defined(MAPBASE)
BaseClass::Spawn(); BaseClass::Spawn();
@ -239,7 +241,7 @@ const unsigned char *CBaseCombatWeapon::GetEncryptionKey( void )
void CBaseCombatWeapon::Precache( void ) void CBaseCombatWeapon::Precache( void )
{ {
#if defined( CLIENT_DLL ) #if defined( CLIENT_DLL )
Assert( Q_strlen( GetClassname() ) > 0 ); Assert( Q_strlen(GetWeaponScriptName() ) > 0 );
// Msg( "Client got %s\n", GetClassname() ); // Msg( "Client got %s\n", GetClassname() );
#endif #endif
m_iPrimaryAmmoType = m_iSecondaryAmmoType = -1; m_iPrimaryAmmoType = m_iSecondaryAmmoType = -1;
@ -321,7 +323,7 @@ void CBaseCombatWeapon::Precache( void )
else else
{ {
// Couldn't read data file, remove myself // Couldn't read data file, remove myself
Warning( "Error reading weapon data file for: %s\n", GetClassname() ); Warning( "Error reading weapon data file for: %s\n", GetWeaponScriptName() );
// Remove( ); //don't remove, this gets released soon! // Remove( ); //don't remove, this gets released soon!
} }
} }