PHP Code:
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <amxmisc>
#include <cswpn_ultilities>
#include <fakemeta>
#include <celltrie>
#include <hamsandwich>
#include <cstrike>
#include <cstrike_pdatas>
#include <g4u_wpn>
#define PLUGIN "Block Default Model"
#define VERSION "1.0"
#define AUTHOR "Nguyen Duy Linh"
stock DEFAULT_WPN_MODEL[][] =
{
"REDPLANE-DARKTEMPLAR",
"p228.mdl",
"DARKTEMPLAR-REDPLANE",
"scout.mdl",
"hegrenade.mdl",
"xm1014.mdl",
"c4.mdl",
"mac10.mdl",
"aug.mdl",
"smokegrenade.mdl",
"elite.mdl",
"fiveseven.mdl",
"ump45.mdl",
"sg550.mdl",
"galil.mdl",
"famas.mdl",
"usp.mdl",
"glock18.mdl",
"awp.mdl",
"mp5.mdl",
"m249.mdl",
"m3.mdl",
"m4a1.mdl",
"tmp.mdl",
"g3sg1.mdl",
"flashbang.mdl",
"deagle.mdl",
"sg552.mdl",
"ak47.mdl",
"knife.mdl" ,
"p90.mdl"
}
stock DEFAULT_WPN_DRAW_ANIM[] =
{
-1,
6,
-1,
4,
3,
6,
1,
2,
2,
3,
15,
5,
2,
4,
2,
2,
14,
8,
5,
2,
4,
6,
12,
2,
4,
3,
5,
2,
2,
3 ,
2
}
#define PRIMARY_WEAPONS (1<<CSW_SCOUT | 1<<CSW_MAC10 | 1<<CSW_AUG | 1<<CSW_UMP45 | 1<<CSW_SG550 | 1<<CSW_GALIL | 1<<CSW_FAMAS | 1<<CSW_AWP | 1<<CSW_MP5NAVY | 1<<CSW_M249 | 1<<CSW_M4A1 | 1<<CSW_TMP | 1<<CSW_G3SG1 | 1<<CSW_SG552 | 1<<CSW_AK47 | 1<<CSW_P90)
#define SECONDARY_WEAPONS (1<<CSW_DEAGLE | 1<<CSW_USP | 1<< CSW_GLOCK18 | 1<<CSW_P228 | 1<<CSW_ELITE | 1<<CSW_FIVESEVEN)
#define SHOTGUNS (1<<CSW_M3 | 1<<CSW_XM1014)
#define HEGRENADE (1<<CSW_HEGRENADE)
#define SMOKEGRENADE (1<<CSW_SMOKEGRENADE)
#define FLASHBANG (1<<CSW_FLASHBANG)
#define IsRifle(%1) (PRIMARY_WEAPONS & (1<<%1))
#define IsPistol(%1) (SECONDARY_WEAPONS & (1<<%1))
#define IsShotgun(%1) (SHOTGUNS & (1<<%1))
#define IsHegrenade(%1) (HEGRENADE & (1<<%1))
#define IsSmokegrenade(%1) (SMOKEGRENADE & (1<<%1))
#define IsFlashBang(%1) (FLASHBANG & (1<<%1))
new Trie:iRegisteredModel
const m_szAnimExtention = 492
public plugin_precache()
{
iRegisteredModel = TrieCreate()
for (new i = 0; i < sizeof DEFAULT_WPN_MODEL; i++)
{
if (i < CSW_P228 || i > CSW_P90 || i == 2)
continue
new szFullModel[128]
// Register Player Model
formatex(szFullModel, sizeof szFullModel - 1, "models/p_%s", DEFAULT_WPN_MODEL[i])
TrieSetCell(iRegisteredModel, szFullModel, 1)
}
register_forward(FM_PrecacheModel, "fw_PrecacheModelPre")
}
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_event("CurWeapon","Event_CurWeapon","be","1=1")
}
public fw_PrecacheModelPre(szModel[])
{
if (TrieKeyExists(iRegisteredModel, szModel))
{
forward_return(FMV_CELL, 0)
return FMRES_SUPERCEDE
}
return FMRES_IGNORED
}
public Event_CurWeapon(id)
{
new iWeaponId = read_data(2)
new iCanUpdateModel = 1
if (IsPistol(iWeaponId))
{
if (g4u_user_has_pistol(id) > -1)
iCanUpdateModel = 0
}
else if (IsShotgun(iWeaponId))
{
if (g4u_user_has_shotgun(id) > -1)
iCanUpdateModel = 0
}
else if (IsRifle(iWeaponId))
{
if (g4u_user_has_riffle(id) > -1)
iCanUpdateModel = 0
}
if (iWeaponId == CSW_HEGRENADE)
{
if (g4u_get_user_hegrenade(id) > -1)
iCanUpdateModel = 0
}
if (iWeaponId == CSW_SMOKEGRENADE)
{
if (g4u_user_has_smokegrenade(id) > -1)
iCanUpdateModel = 0
}
if (iWeaponId == CSW_KNIFE)
iCanUpdateModel = 0
if (iCanUpdateModel)
{
new szViewModel[128]
formatex(szViewModel, sizeof szViewModel - 1, "models/v_%s", DEFAULT_WPN_MODEL[iWeaponId])
set_pev(id, pev_viewmodel2, szViewModel)
}
}
public csred_WpnDeploy_Pre(id, iEnt, iWeaponId)
{
if (!is_user_connected(id))
return PLUGIN_HANDLED
return PLUGIN_HANDLED
}
public csred_WpnDeploy_Post(id, iEnt, iWeaponId)
{
if (!is_user_connected(id))
return PLUGIN_HANDLED
new iCanUpdateModel = 1
if (IsPistol(iWeaponId))
{
if (g4u_user_has_pistol(id) > -1)
iCanUpdateModel = 0
}
else if (IsShotgun(iWeaponId))
{
if (g4u_user_has_shotgun(id) > -1)
iCanUpdateModel = 0
}
else if (IsRifle(iWeaponId))
{
if (g4u_user_has_riffle(id) > -1)
iCanUpdateModel = 0
}
if (iWeaponId == CSW_HEGRENADE)
{
if (g4u_get_user_hegrenade(id) > -1)
iCanUpdateModel = 0
}
if (iWeaponId == CSW_SMOKEGRENADE)
{
if (g4u_user_has_smokegrenade(id) > -1)
iCanUpdateModel = 0
}
if (iCanUpdateModel)
{
new szViewModel[128]
formatex(szViewModel, sizeof szViewModel - 1, "models/v_%s", DEFAULT_WPN_MODEL[iWeaponId])
set_pev(id, pev_viewmodel2, szViewModel)
new iLastItemId = get_pdata_cbase(id, m_pLastItem, 5)
if (iLastItemId && pev_valid(iLastItemId))
set_pev(iLastItemId, pev_effects, pev(iLastItemId, pev_effects) | EF_NODRAW)
set_pdata_cbase(id, m_pActiveItem, iEnt, 5)
set_pdata_float(id, m_flNextAttack, 0.75)
set_pdata_float(iEnt, m_flNextPrimaryAttack, 0.75)
set_pdata_float(iEnt, m_flNextSecondaryAttack, 0.75)
set_pdata_float(iEnt, m_flTimeWeaponIdle, 1.0)
new iDecResult = ExecuteHamB(Ham_Weapon_UseDecrement, iEnt)
if (iWeaponId == CSW_M4A1)
{
if (!cs_get_weapon_silen(iEnt))
play_weapon_anim(iEnt, DEFAULT_WPN_DRAW_ANIM[iWeaponId], iDecResult, 0)
else play_weapon_anim(iEnt, DEFAULT_WPN_DRAW_ANIM[iWeaponId] - 7, iDecResult, 0)
}
else if (iWeaponId == CSW_USP)
{
if (!cs_get_weapon_silen(iEnt))
play_weapon_anim(iEnt, DEFAULT_WPN_DRAW_ANIM[iWeaponId], iDecResult, 0)
else play_weapon_anim(iEnt, DEFAULT_WPN_DRAW_ANIM[iWeaponId] - 8, iDecResult, 0)
}
else UT_PlayWeaponAnim(id, DEFAULT_WPN_DRAW_ANIM[iWeaponId])
ExecuteHamB(Ham_Item_UpdateClientData, iEnt, id)
}
return PLUGIN_HANDLED
}
stock play_weapon_anim(iEnt, iAnim, iSkipLocal, iBody)
return ExecuteHam(Ham_Weapon_SendWeaponAnim, iEnt, iAnim, iSkipLocal, iBody)
This is my code. And in game , this is :