Raised This Month: $51 Target: $400
 12% 

Solved Why this doesn't work ?


Post New Thread Reply   
 
Thread Tools Display Modes
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
supertrio17
Senior Member
Join Date: May 2020
Location: Serbia
Old 08-03-2020 , 17:20   Re: Why this doesn't work ?
Reply With Quote #2

Post your whole code.
__________________
Contact! || Discord:
Mr_Boopsy_#2066
supertrio17 is offline
Abhinash
Senior Member
Join Date: Jan 2015
Location: India,kolkata
Old 08-04-2020 , 01:57   Re: Why this doesn't work ?
Reply With Quote #3

Quote:
Originally Posted by supertrio17 View Post
Post your whole code.
These are the only places, where it is used. And g_uammo[33] is global variable. And about full code, it's just default Zp 4.3 .
Can anyone help ?
Abhinash is offline
Reply



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 09:59.


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