Hi everyone.
I am using this function to give weapon --
Code:
give_user_weapon( index , iWeaponTypeID , iClip=0 , iBPAmmo=0 )
{
if ( !( CSW_P228 <= iWeaponTypeID <= CSW_P90 ) || ( iClip < 0 ) || ( iBPAmmo < 0 ) || !is_user_alive( index ) )
return -1;
new szWeaponName[ 20 ] , iWeaponEntity , bool:bIsGrenade;
const GrenadeBits = ( ( 1 << CSW_HEGRENADE ) | ( 1 << CSW_FLASHBANG ) | ( 1 << CSW_SMOKEGRENADE ) | ( 1 << CSW_C4 ) );
if ( ( bIsGrenade = bool:!!( GrenadeBits & ( 1 << iWeaponTypeID ) ) ) )
iClip = clamp( iClip ? iClip : iBPAmmo , 1 );
get_weaponname( iWeaponTypeID , szWeaponName , charsmax( szWeaponName ) );
if ( ( iWeaponEntity = user_has_weapon( index , iWeaponTypeID ) ? find_ent_by_owner( -1 , szWeaponName , index ) : give_item( index , szWeaponName ) ) > 0 )
{
if ( iWeaponTypeID != CSW_KNIFE )
{
if ( iClip && !bIsGrenade )
cs_set_weapon_ammo( iWeaponEntity , iClip );
if ( !iClip && !iBPAmmo )
b_uAmmo[index] = true;
else
b_uAmmo[index] = false;
if ( iWeaponTypeID == CSW_C4 )
cs_set_user_plant( index , 1 , 1 );
else
cs_set_user_bpammo( index , iWeaponTypeID , bIsGrenade ? iClip : iBPAmmo );
}
}
return iWeaponEntity;
}
Here, b_uAmmo is a global variable.
And, I want it to work like when I use function with 3rd and 4th parameters, then I want to work it as usual which is working fine.
And I want when I am using this function without 3rd and 4th parameters, then it set the variable to true and then in CurWeapon, I can set unlimited Ammo according to the Variable. i did according to the plan, but its not working.
Please help me.
Here is the CurWeapon part --
Code:
public message_cur_weapon(id)
{
// Not alive or zombie
if (!g_isalive[id] || g_zombie[id])
return;
if (!g_zombie[id] || g_sniper[id])
return;
if (b_uAmmo[id])
set_pdata_int(get_pdata_cbase(id, 373), 51, 100, 4)
}