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

cs_set_user_bpammo not working


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
LondoN
Senior Member
Join Date: Dec 2015
Location: Roman, Romania.
Old 01-17-2021 , 18:18   cs_set_user_bpammo not working
Reply With Quote #1

Plugin Header

Code:
#define GUN_BITS (1<<CSW_P228|1<<CSW_GLOCK18|1<<CSW_USP|1<<CSW_DEAGLE|1<<CSW_FIVESEVEN|1<<CSW_ELITE|1<<CSW_M3|1<<CSW_XM1014|1<<CSW_TMP|1<<CSW_MP5NAVY|1<<CSW_MAC10|1<<CSW_UMP45|1<<CSW_P90|1<<CSW_AK47|1<<CSW_M4A1|1<<CSW_SCOUT|1<<CSW_SG552|1<<CSW_SG550|1<<CSW_GALIL|1<<CSW_FAMAS|1<<CSW_AWP|1<<CSW_G3SG1|1<<CSW_M249)

new const g_cPrimaryWeaponsName [ ] [ ]  =
{
	"M4A1 Automatic",
	"AK47 Kalashnikov",
	"Famas",
	"Galil",
	"M249 Machine Gun"
};

new const g_cPrimaryWeaponsEntity [ ] [ ] =
{
	"weapon_m4a1",
	"weapon_ak47",
	"weapon_famas",
	"weapon_galil",
	"weapon_m249"
};
where don't work:

Code:
public PRIMARY_WEAPONS_HANDLER ( iEntity, iMenu, iKey )
{
	if ( iKey == MENU_EXIT )
	{
		menu_destroy ( iMenu );
		return;
	}

	give_item ( iEntity, g_cPrimaryWeaponsEntity [ iKey ] );

	new iWeaponID = get_user_weapon ( iEntity );

	if ( GUN_BITS & (1<<iWeaponID) )
		cs_set_user_bpammo ( iEntity, iWeaponID, 90 );
}
it give's me the right weapon but don't give 90 bpammo for that weapon
__________________
LondoN is offline
Old 01-17-2021, 18:45
OciXCrom
This message has been deleted by OciXCrom.
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 01-18-2021 , 08:32   Re: cs_set_user_bpammo not working
Reply With Quote #2

If the give_item is from the fun module, this may fix the problem. If not, just make sure give_item returns the weapon entity index. If it doesn't work, try debbuging your code.

Code:
public PRIMARY_WEAPONS_HANDLER ( iEntity, iMenu, iKey ) {     if ( iKey == MENU_EXIT )     {         menu_destroy ( iMenu );         return;     }     new iWeaponEntity = give_item ( iEntity, g_cPrimaryWeaponsEntity [ iKey ] );     //new iWeaponID = get_user_weapon ( iEntity );     new iWeaponID = cs_get_weapon_id( iWeaponEntity );     if ( GUN_BITS & (1<<iWeaponID) )         cs_set_user_bpammo ( iEntity, iWeaponID, 90 ); }

By the way, you should be returning PLUGIN_HANDLED in menu handlers, as stated in the docs.
Quote:
* The handler function should always return PLUGIN_HANDLED to block
* any old menu handlers from potentially feeding on the menu, unless
* that is the desired functionality.
https://www.amxmodx.org/api/newmenus/menu_create
__________________









Last edited by CrazY.; 01-18-2021 at 08:41.
CrazY. is offline
LondoN
Senior Member
Join Date: Dec 2015
Location: Roman, Romania.
Old 01-18-2021 , 12:00   Re: cs_set_user_bpammo not working
Reply With Quote #3

Code:
new iWeaponEntID = fm_find_ent_by_owner ( -1, g_cPrimaryWeaponsEntity [ iKey ], iEntity )

	if ( iWeaponEntID && pev_valid ( iWeaponEntID ) )
		cs_set_user_bpammo ( iEntity, cs_get_weapon_id ( iWeaponEntID ), 90 );
i've changed the code this way, it's only solution that's working. i wan't to do the fastest way to give weapons in the handler. it was more good that i can work only with single module, not 3 (fun,fakemeta,cstrike)

If anyone can show me up a way to use single module natives to do this handler im opened<3
__________________
LondoN is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 01-18-2021 , 13:11   Re: cs_set_user_bpammo not working
Reply With Quote #4

You may use whatever amount of modules is needed, but avoid fakemeta_util.
__________________








CrazY. 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 00:26.


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