//----------------------------------------------------------------------------- // Purpose: If we're picked up by another pla`yer, give resources to that team //----------------------------------------------------------------------------- void CResourceChunk::ChunkTouch( CBaseEntity *pOther ) { if ( pOther->IsPlayer() || pOther->GetServerVehicle() ) { // Give the team the resources int iAmountPerPlayer = ((CTFTeam *)pOther->GetTeam())->AddTeamResources( GetResourceValue(), TF_PLAYER_STAT_RESOURCES_ACQUIRED_FROM_CHUNKS ); TFStats()->IncrementTeamStat( pOther->GetTeamNumber(), TF_TEAM_STAT_RESOURCE_CHUNKS_COLLECTED, GetResourceValue() ); pOther->EmitSound( "ResourceChunk.Pickup" ); // Tell the player CSingleUserRecipientFilter user( (CBasePlayer*)pOther ); UserMessageBegin( user, "PickupRes" ); WRITE_BYTE( iAmountPerPlayer ); MessageEnd(); // Tell our zone to remove this chunk from it's list if ( m_hZone ) { m_hZone->RemoveChunk( this, false ); m_hZone = NULL; } // Remove this chunk SetTouch( NULL ); UTIL_Remove( this ); return; } }
CString FuncGetStringFromIDS(const char* szSection, const char * szIDS) { CString strRet=""; std::string rKey; if(szIDS) rKey = szIDS; std::string sRet= GetResourceValue(rKey); strRet = sRet.c_str(); return strRet; }
// --[ Method ]--------------------------------------------------------------- // // - Class : CEffect // - prototype : CResource* FindResource(CResourceList* pResourceList, const std::string& strName, const std::string& strClassName) // // - Purpose : Returns a resource interface from the list given its name and // class name. // // ----------------------------------------------------------------------------- CResource* CEffect::FindResource(CResourceList* pResourceList, const std::string& strName, const std::string& strClassName) { if(!pResourceList) { FXLoadError("Error accessing resource \"%s\" (No resource list available)", strName.data()); return NULL; } CResource* pResource; std::string strResValue; int i; // Get resource index if(-1 == (i = GetResourceIndex(strName))) { FXLoadError("Resource \"%s\" not found", strName.data()); return NULL; } // Get value (string) if(!GetResourceValue(i, &strResValue)) { FXLoadError("Error getting resource \"%s\" value", strName.data()); return NULL; } // Get resource from list if(!(pResource = pResourceList->GetResource(strResValue))) { FXLoadError("Error getting resource \"%s\" (%s) from list", strName.data(), strResValue.data()); return NULL; } // Check validity if(pResource->GetClassName() != strClassName) { FXLoadError("Resource \"%s\" (%s) is not from class %s", strName.data(), strResValue.data(), strClassName); return NULL; } return pResource; }