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

[ H3LP ] Loop through client weapons


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 12-18-2017 , 10:25   [ H3LP ] Loop through client weapons
Reply With Quote #1

Hello, how I can loop through player weapons? I need the entity of the weapon, not its index corresponding to the CSW *.

Last edited by CrazY.; 12-18-2017 at 10:25.
CrazY. is offline
NiHiLaNTh
Way Past Expiration
Join Date: May 2009
Location: Latvia
Old 12-19-2017 , 07:33   Re: [ H3LP ] Loop through client weapons
Reply With Quote #2

Code:
#include <amxmodx>
#include <fakemeta>

#include <cstrike> // cs_get stuff

public plugin_init()
{
	register_clcmd("say /showwpn", "test");
}

public test(player)
{
	static entity
	for (new i = CS_WEAPONSLOT_PRIMARY; i <= CS_WEAPONSLOT_C4; i++)
	{
		// m_rgpPlayerItems array pointing to weapon ents in each slot
		entity = get_ent_data_entity(player, "CBasePlayer", "m_rgpPlayerItems", i);
	
		while (entity > 0)
		{
			server_print("ENT: %d | WEAPON ID: %d | CLIP: %d", entity, cs_get_weapon_id(entity), cs_get_weapon_ammo(entity));
		
			// points to the next weapon in the SAME slot (if the weapon does exist)
			entity = get_ent_data_entity(entity, "CBasePlayerItem", "m_pNext");
		}
	}
}
__________________

NiHiLaNTh is offline
Send a message via Skype™ to NiHiLaNTh
Depresie
Veteran Member
Join Date: Nov 2013
Old 12-19-2017 , 14:26   Re: [ H3LP ] Loop through client weapons
Reply With Quote #3

Btw the code above is only for 1.8.3
__________________

Last edited by Depresie; 12-19-2017 at 14:27.
Depresie is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 12-19-2017 , 14:43   Re: [ H3LP ] Loop through client weapons
Reply With Quote #4

No problems since I'm using the 1.8.3 version.
CrazY. is offline
Reply


Thread Tools
Display Modes

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 07:46.


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