i'm making a custom weapon models plugin
the problem is that when i buy,pick or drop a shield
the weapon returns to it's original model
and when i shoot or swich the weapon and then swich back
it returns to it's custom one
the script :
============================================= =========================
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <engine>
#include <fakemeta>
#define PLUGIN "Custom Weapon Models"
#define VERSION "1.0"
#define AUTHOR "FL@ME"
#define OLD_MODEL_DEAGLE_V "models/v_deagle.mdl"
#define NEW_MODEL_DEAGLE_V "models/custom_weapons/v_deagle.mdl"
#define OLD_MODEL_DEAGLE_P "models/p_deagle.mdl"
#define NEW_MODEL_DEAGLE_P "models/custom_weapons/p_deagle.mdl"
#define OLD_MODEL_DEAGLE_W "models/w_deagle.mdl"
#define NEW_MODEL_DEAGLE_W "models/custom_weapons/w_deagle.mdl"
#define OLD_MODEL_DEAGLE_VSH "models/shield/v_shield_deagle.mdl"
#define NEW_MODEL_DEAGLE_VSH "models/custom_weapons/shield/v_shield_deagle.mdl"
#define OLD_MODEL_DEAGLE_PSH "models/shield/p_shield_deagle.mdl"
#define NEW_MODEL_DEAGLE_PSH "models/custom_weapons/shield/p_shield_deagle.mdl"
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_event("CurWeapon","SetCWM","be")
}
public plugin_precache() {
precache_model("models/custom_weapons/v_deagle.mdl")
precache_model("models/custom_weapons/p_deagle.mdl")
precache_model("models/custom_weapons/w_deagle.mdl")
precache_model("models/custom_weapons/shield/v_shield_deagle.mdl")
precache_model("models/custom_weapons/shield/p_shield_deagle.mdl")
register_forward(FM_SetModel,"SetCWMW")
}
public SetCWMW(edict, const model[]) {
if (!is_valid_ent(edict))
return FMRES_IGNORED
if(equal(model, OLD_MODEL_DEAGLE_W))
{
entity_set_model(edict, NEW_MODEL_DEAGLE_W)
return FMRES_SUPERCEDE
}
return FMRES_IGNORED
}
public SetCWM(id) {
new vmodel[32],pmodel[32]
entity_get_string(id,EV_SZ_viewmodel,vmodel,1 00)
if (equal(vmodel,OLD_MODEL_DEAGLE_V)) {
entity_set_string(id,EV_SZ_viewmodel,NEW_MODE L_DEAGLE_V)
}
else if (equal(vmodel,OLD_MODEL_DEAGLE_VSH)) {
entity_set_string(id,EV_SZ_viewmodel,NEW_MODE L_DEAGLE_VSH)
}
entity_get_string(id,EV_SZ_weaponmodel,pmodel ,100)
if (equal(pmodel,OLD_MODEL_DEAGLE_P)) {
entity_set_string(id,EV_SZ_weaponmodel,NEW_MO DEL_DEAGLE_P)
}
else if (equal(pmodel,OLD_MODEL_DEAGLE_PSH)) {
entity_set_string(id,EV_SZ_weaponmodel,NEW_MO DEL_DEAGLE_PSH)
}
}
============================================= =========================
|