--- "\320\227\320\260\320\262\320\260\320\275\321\202\320\260\320\266\320\265\320\275\320\275\321\217/weapons_skins_manager/weapons_skins_manager.sma" 2017-01-19 00:08:49.000000000 +0200
+++ weapons_skins_manager.sma 2017-12-11 13:26:10.548847280 +0200
@@ -21,6 +21,12 @@
#define SetModel(%1,%2) engfunc(EngFunc_SetModel,%1,%2)
#define IsPlayer(%1) (1 <= %1 <= g_iMaxPlayers)
+#define PEV_CUSTOM_MODEL pev_iuser3
+#define PEV_ADD_COUNTER pev_iuser4
+
+const m_rgpPlayerItems_CWeaponBox = 34;
+const XO_CBASEPLAYERWEAPON = 4;
+
new Trie:g_tViewModels
new Trie:g_tWeaponModels
new Trie:g_tWorldModels
@@ -76,6 +82,7 @@
szWeaponClass,
RegisterHam(Ham_Item_Deploy, szWeaponClass, "ItemDeploy_Post", true)
)
+ RegisterHam(Ham_AddPlayerItem, "player", "AddPlayerItem_Pre", 0)
}
format(szViewModel, charsmax(szViewModel), "models/%s.mdl", szViewModel)
if(file_exists(szViewModel))
@@ -141,7 +148,7 @@
const m_pPlayer = 41
new id = get_pdata_cbase(wEnt, m_pPlayer, .linuxdiff = 4)
- if(IsPlayer(id) && get_user_flags(id) & g_iAccess)
+ if(IsPlayer(id) && pev(wEnt, PEV_CUSTOM_MODEL))
{
new iszNewModel, szWeaponClass[32]
pev(wEnt, pev_classname, szWeaponClass, charsmax(szWeaponClass))
@@ -162,21 +169,38 @@
}
}
+public AddPlayerItem_Pre(player, weapon)
+{
+ if ((get_user_flags(player) & g_iAccess) && !pev(weapon, PEV_ADD_COUNTER)) {
+ set_pev(weapon, PEV_CUSTOM_MODEL, 1)
+ }
+
+ set_pev(weapon, PEV_ADD_COUNTER, 1)
+}
+
public SetModel_Pre(iEnt, const szModel[])
{
// if(!pev_valid(iEnt))
// return FMRES_IGNORED
new id = pev(iEnt, pev_owner)
- if(!IsPlayer(id) || ~get_user_flags(id) & g_iAccess)
+ if(!IsPlayer(id))
return FMRES_IGNORED
- new szNewModel[MAX_MODEL_LENGTH]
- if(TrieGetString(g_tWorldModels, szModel, szNewModel, charsmax(szNewModel)))
- {
- SetModel(iEnt, szNewModel)
- return FMRES_SUPERCEDE
+ #define MAX_ITEM_TYPES 6
+ for(new i, weapon; i < MAX_ITEM_TYPES; i++) {
+ weapon = get_pdata_cbase(iEnt, m_rgpPlayerItems_CWeaponBox + i, XO_CBASEPLAYERWEAPON);
+
+ if (pev_valid(weapon) == 2 && pev(weapon, PEV_CUSTOM_MODEL)) {
+ new szNewModel[MAX_MODEL_LENGTH]
+ if(TrieGetString(g_tWorldModels, szModel, szNewModel, charsmax(szNewModel)))
+ {
+ SetModel(iEnt, szNewModel)
+ return FMRES_SUPERCEDE
+ }
+ }
}
+
return FMRES_IGNORED
}