Raised This Month: $ Target: $400
 0% 

Solved Why this doesn't work ?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Abhinash
Senior Member
Join Date: Jan 2015
Location: India,kolkata
Old 08-03-2020 , 15:42   Why this doesn't work ?
Reply With Quote #1

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)
}

Last edited by Abhinash; 08-04-2020 at 18:44.
Abhinash is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 13:46.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode