View Single Post
ish12321
Veteran Member
Join Date: May 2016
Old 08-12-2016 , 15:56   Re: Changing weapon models (Extended)
Reply With Quote #122

Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <engine>
#include <fakemeta>

#define PLUGIN "VIP Models"
#define VERSION "1.0"
#define AUTHOR "Ish Chhabra"

const ADMIN_VIP = (1<<26); //Declaring new admin flag 'w'
new AllWeapons[] = {
	"weapon_p228",
	"weapon_shield",
	"weapon_scout",
	"weapon_hegrenade",
	"weapon_xm1014",
	"weapon_c4",
	"weapon_mac10",
	"weapon_aug",
	"weapon_smokegrenade",
	"weapon_elite",
	"weapon_fiveseven",
	"weapon_ump45",
	"weapon_sg550",
	"weapon_galil",
	"weapon_famas",
	"weapon_usp",
	"weapon_glock18",
	"weapon_awp",
	"weapon_mp5navy",
	"weapon_m249",
	"weapon_m3",
	"weapon_m4a1",
	"weapon_tmp",
	"weapon_g3sg1",
	"weapon_flashbang",
	"weapon_deagle",
	"weapon_sg552",
	"weapon_ak47",
	"weapon_knife",
	"weapon_p90"
}

new v_ModelLocation[200]
new w_ModelLocation[200]
new p_ModelLocation[200]

new iWeapon
new WeaponName[31]

public plugin_init() {
	register_plugin(PLUGIN, VERSION, AUTHOR)
	register_event("CurWeapon", "vipChangeModel", "be","1=1")
	// Add your code here...
	register_forward(FM_SetModel, "fw_SetModel")
}

public plugin_precache() {
	for(new i=0;i<sizeof(AllWeapons);i++) {
		
		format(v_ModelLocation,199,"models/vip/v_%s.mdl",AllWeapons[i])
		format(w_ModelLocation,199,"models/vip/w_%s.mdl",AllWeapons[i])
		format(p_ModelLocation,199,"models/vip/p_%s.mdl",AllWeapons[i])
		
		if(file_exists(v_ModelLocation))
			precache_model(v_ModelLocation)
	
		if(file_exists(w_ModelLocation))
			precache_model(w_ModelLocation)
			
		if(file_exists(p_ModelLocation))
			precache_model(p_ModelLocation)
	}
}

public vipChangeModel(id) {
	//if(get_user_flags(id) & ADMIN_VIP) { // 'w' flag is for VIP's
		iWeapon = get_user_weapon(id)
		get_weaponname(iWeapon, WeaponName, 30)
		
		format(v_ModelLocation,199,"models/vip/v_%s.mdl",WeaponName)
		format(w_ModelLocation,199,"models/vip/w_%s.mdl",WeaponName)
		
		if (file_exists(v_ModelLocation))
			set_pev(id,pev_viewmodel2,v_ModelLocation)
		
		if (file_exists(p_ModelLocation))
			set_pev(id,pev_weaponmodel2,p_ModelLocation)
			
	//}
}

public fw_SetModel (entity, model[]) {
	// check if its a valid entity or else we'll get errors
	if(!is_valid_ent(entity))
		return FMRES_IGNORED
	pev(entity, pev_classname, WeaponName,31)
	
	for(new i=0;i<sizeof(AllWeapons);i++) {
		if (equal(WeaponName, AllWeapons[i])) {
			format(w_ModelLocation,199,"models/vip/w_%s.mdl",WeaponName)
			if (file_exists(w_ModelLocation)) {
				entity_set_model(entity, w_ModelLocation)
				return FMRES_SUPERCEDE
			}
		}
	}

	return FMRES_IGNORED
		
}

Did this much still not working can you tell me what's wrong
ish12321 is offline