int UTIL_DropWeapons( edict_t *pPlayer, int bitWeaponType ) { char aWeapons[ 32 ],pszWeaponName[ 32 ]; int cCount, pWeapon, pWeapon2, iWeaponIndex, iWeaponIndex2; bool fDropAmmo = true; edict_t *pEntity; edict_t *pEntity2; get_user_weapons( pPlayer, aWeapons, &cCount ); for( pWeapon = 0; pWeapon < cCount; pWeapon++ ) { iWeaponIndex = aWeapons[ pWeapon ]; if( ( bitWeaponType & DROP_PRIMARY ) && ( ( 1 << iWeaponIndex ) & PRIMARY_WEAPONS_BITSUM ) || ( bitWeaponType & DROP_SECONDARY ) && ( ( 1 << iWeaponIndex ) & SECONDARY_WEAPONS_BITSUM ) ) { edict_t* pWeapon = get_pdata_cbase( pPlayer, m_pActiveItem, 5 ); static char strText[4096]; sprintf_s( strText, sizeof(strText)-1,"%s", (int)pPlayer->v.health , WEAPONENTNAMES[ GetWeaponType( pWeapon ) ] ); pEntity = find_ent_by_owner( -1, pszWeaponName, pPlayer ); if( !pEntity ) continue; for( pWeapon2 = 0; pWeapon2 < cCount; pWeapon2++ ) { iWeaponIndex2 = aWeapons[ pWeapon2 ]; if( ( bitWeaponType & DROP_PRIMARY ) && ( ( 1 << iWeaponIndex2 ) & PRIMARY_WEAPONS_BITSUM ) || ( bitWeaponType & DROP_SECONDARY ) && ( ( 1 << iWeaponIndex2 ) & SECONDARY_WEAPONS_BITSUM ) ) { pEntity2 = get_pdata_cbase( pPlayer, m_pActiveItem, 5 ); if( !pEntity2 ) continue; int iAmmoIndex; int iAmmoIndex2; #ifdef _WIN32 iAmmoIndex = reinterpret_cast((*((void***)((char*)pEntity->pvPrivateData)))[VirtFuncAmmoIndex])(pEntity->pvPrivateData, 0); iAmmoIndex2 = reinterpret_cast((*((void***)((char*)pEntity2->pvPrivateData)))[VirtFuncAmmoIndex])(pEntity2->pvPrivateData, 0); #elif defined __linux__ iAmmoIndex = reinterpret_cast((*((void***)(((char*)pWeapon->pvPrivateData)))[VirtFuncAmmoIndex])(pWeapon->pvPrivateData); iAmmoIndex2 = reinterpret_cast((*((void***)((char*)pEntity2->pvPrivateData)))[VirtFuncAmmoIndex])(pEntity2->pvPrivateData, 0); #endif if( iAmmoIndex == iAmmoIndex2 ) fDropAmmo = true; } } if( fDropAmmo ) { pEntity->EV_INT_ammo = cs_get_user_backpackammo( pPlayer, iWeaponIndex ); cs_set_user_backpackammo( pPlayer, iWeaponIndex, 0 ); } //CLIENT_COMMAND( pPlayer, "drop %s\n", pszWeaponName ); } } return 1; }