View Single Post
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