this is for ak47 you need to edit the path of the models to match yours
Untested :
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#define SKIN_ACCESS ADMIN_LEVEL_H
new const m_rgpPlayerItems_CWeaponBox[ 6 ] = { 34 , 35 , ... };
new const XO_CWEAPONBOX = 4;
new g_iMaxPlayers
#define IsPlayer(%0) ( 1 <= (%0) <= g_iMaxPlayers )
#define V_MODEL "models/v_ak_gold.mdl"
#define P_MODEL "models/p_ak_gold.mdl"
#define W_MODEL "models/w_ak_gold.mdl"
public plugin_precache()
{
precache_model(V_MODEL)
precache_model(P_MODEL)
precache_model(W_MODEL)
}
public plugin_init()
{
register_plugin( "Skins", "0.0.1", "JustGo" )
RegisterHam(Ham_Touch, "weaponbox", "OnCWeaponBox_Touch")
RegisterHam(Ham_Item_Deploy, "weapon_ak47", "fw_Item_Deploy_Post", 1)
register_forward(FM_SetModel, "fw_SetModel")
g_iMaxPlayers = get_maxplayers()
}
public OnCWeaponBox_Touch( weaponbox , id )
{
if( !pev_valid(weaponbox) ) return HAM_IGNORED
if( IsPlayer(id) && is_user_alive(id) && pev(weaponbox, pev_flags) & FL_ONGROUND )
{
new weapon = get_pdata_cbase(weaponbox, m_rgpPlayerItems_CWeaponBox[5], XO_CWEAPONBOX)
if( !weapon ) return HAM_IGNORED
if (get_user_flags(id) & SKIN_ACCESS) return HAM_IGNORED
static WpnModel[64]
pev(weaponbox, pev_model, WpnModel, charsmax(WpnModel))
if( equal(WpnModel, W_MODEL ))
return HAM_SUPERCEDE
}
return HAM_IGNORED
}
public fw_Item_Deploy_Post(Ent)
{
if(pev_valid(Ent) != 2)
return
static id; id = get_pdata_cbase(Ent, 41, 4)
if(get_pdata_cbase(id, 373) != Ent)
return
if(!(get_user_flags(id) & SKIN_ACCESS))
return
set_pev(id, pev_viewmodel2, V_MODEL)
set_pev(id, pev_weaponmodel2, P_MODEL)
}
public fw_SetModel(entity, model[])
{
if(!pev_valid(entity))
return FMRES_IGNORED
new className[33]
pev(entity, pev_classname, className, charsmax(className))
if(!equal(className, "weaponbox"))
return FMRES_IGNORED
static iOwner
iOwner = pev(entity, pev_owner)
if (!(get_user_flags(iOwner) & SKIN_ACCESS)) return FMRES_IGNORED
if(equal(model, "models/w_ak47.mdl"))
{
engfunc(EngFunc_SetModel, entity, W_MODEL)
return FMRES_SUPERCEDE
}
return FMRES_IGNORED
}
__________________