/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

const m_pPlayer = 41
const m_iId = 43

native eg_set_p_model_ent(id, model[], body, anim)
native eg_visibility_p_model_ent(id, visible = 1)

#define P_MODEL_PISTOLS "models/sub/p_pistols.mdl" //ваша субмодель 

new const weapon_name[][] = {  
	"weapon_glock18",  
	"weapon_p228",
	"weapon_usp",
	"weapon_fiveseven",
	"weapon_deagle",
	"weapon_elite"
}

public plugin_init() {
	for(new i=0;i<sizeof weapon_name;i++) {
	        RegisterHam(Ham_Item_Deploy, weapon_name[i], "fw_Item_Deploy_Post", 1); //Момент доставания оружия
	        RegisterHam(Ham_Item_Holster, weapon_name[i], "fw_Item_Holster"); //Момент убирания оружия
	}
}
public plugin_precache() {
	engfunc(EngFunc_PrecacheModel, P_MODEL_PISTOLS);
}
public fw_Item_Deploy_Post(ent) { 
	if(pev(ent, pev_impulse) != 0) return HAM_IGNORED; //Проверка на кастомные пушки
	switch(get_pdata_int(ent, m_iId, 4)) { //Получаем тип оружия
		case CSW_GLOCK18: {
		        set_p_model(get_pdata_cbase(ent, m_pPlayer, 4), P_MODEL_PISTOLS, 0, 0); //Устанавливаем модель
		}
		case CSW_P228: {
		        set_p_model(get_pdata_cbase(ent, m_pPlayer, 4), P_MODEL_PISTOLS, 1, 1);
		}
		case CSW_USP: {
		        set_p_model(get_pdata_cbase(ent, m_pPlayer, 4), P_MODEL_PISTOLS, 2, 2);
		}
		case CSW_FIVESEVEN: {
		        set_p_model(get_pdata_cbase(ent, m_pPlayer, 4), P_MODEL_PISTOLS, 3, 3);
		}
		case CSW_DEAGLE: {
		        set_p_model(get_pdata_cbase(ent, m_pPlayer, 4), P_MODEL_PISTOLS, 4, 4);
		}
		case CSW_ELITE: {
		        set_p_model(get_pdata_cbase(ent, m_pPlayer, 4), P_MODEL_PISTOLS, 5, 5);
		}
	}
	return HAM_IGNORED;
}

public fw_Item_Holster(ent) {
	if(pev(ent, pev_impulse) != 0) return HAM_IGNORED; //Проверка на кастомные пушки
	eg_visibility_p_model_ent(get_pdata_cbase(ent, m_pPlayer, 4), 0); //Прячем модель
	return HAM_IGNORED;
}
stock set_p_model(id, model[], body, sequence) {
	eg_set_p_model_ent(id, model, body, sequence);
	eg_visibility_p_model_ent(id);
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1049\\ f0\\ fs16 \n\\ par }
*/
