Here's the framework, you just need to fill in the weapon level function, and delete my get_user_level() since you have your own. I have the get user level and get weapon level returning dummy values for testing purposes.
PHP Code:
#include <amxmodx>
#include <cstrike>
#include <hamsandwich>
#include <engine>
new const Version[] = "0.1";
#define MAX_PLAYERS 32
#define XO_CWEAPONBOX 4
new const m_rgpPlayerItems_CWeaponBox[ 6 ] = { 34 , 35 , ... };
enum WeaponInfo
{
WeaponBoxIndex,
ReturnType
}
new g_iLastTouched[ MAX_PLAYERS + 1 ][ WeaponInfo ];
public plugin_init()
{
register_plugin( "Weapon Pickup Level" , Version , "0.1" );
register_touch( "weaponbox" , "player" , "PlayerTouchWeaponbox" );
}
public PlayerTouchWeaponbox( iEntity , iPlayer )
{
if ( g_iLastTouched[ iPlayer ][ WeaponBoxIndex ] == iEntity )
{
return g_iLastTouched[ iPlayer ][ ReturnType ];
}
else
{
g_iLastTouched[ iPlayer ][ WeaponBoxIndex ] = iEntity;
return ( g_iLastTouched[ iPlayer ][ ReturnType ] = ( ( get_user_level( iPlayer ) < get_weapon_level( cs_get_weaponbox_type( iEntity ) ) ) ? PLUGIN_HANDLED : PLUGIN_CONTINUE ) );
}
}
public get_user_level( id )
{
return 7;
}
public get_weapon_level( iCSWeaponIndex )
{
//iCSWeaponIndex holds CSW_ weapon index.
return 6;
}
cs_get_weaponbox_type( iWeaponBox )
{
new iWeaponEntity , iWeaponID;
for ( new i = 1 ; i <= 5 ; i++ )
{
if ( ( iWeaponEntity = get_pdata_cbase( iWeaponBox , m_rgpPlayerItems_CWeaponBox[ i ] , XO_CWEAPONBOX ) ) > 0 )
{
iWeaponID = cs_get_weapon_id( iWeaponEntity );
break;
}
}
return iWeaponID;
}
__________________