Yes exactly, if the player isn't vip he's going to see the default CS models. The first quote is the weapon name, the second is the view model, the one you see in your hands, almost always is the one that starts with
v_ in the file name and the third quote is the weapon model, this is what other players will see when you're holding that weapon, this is almost always the model starting with
p_ in the file name and yes, it will work with any weapon even with c4, except for shield. If you need it to work with shield I'll have to modify the plugin. Just make sure you enable the plugin after any other that also changes the weapon models. With that I mean just set it below other plugins in plugins.ini file
You're getting that error because of your amxmodx version. The code below will work with amxmodx 1.8.2, I guess this is the version you are using. You should consider updating amxmodx to 1.9 or later but this is more to a suggestion than a requirement.
Code:
#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <fakemeta>
enum _:weaponmodel_e
{
WeaponVModel[64],
WeaponPModel[64],
}
new Trie:g_models
const m_pPlayer = 41
const CBasePlayerItem = 4
public plugin_init()
{
register_plugin("VIP Weapon Models", "1.0", "Ainsley Harriott")
for (new i = CSW_P228, weapon_name[32]; i <= CSW_P90; i++)
{
get_weaponname(i, weapon_name, charsmax(weapon_name))
if (!TrieKeyExists(g_models, weapon_name))
{
continue
}
RegisterHam(Ham_Item_Deploy, weapon_name, "OnItemDeployPost", 1)
}
}
public plugin_precache()
{
g_models = TrieCreate()
LoadConfigFile()
}
public plugin_end()
{
TrieDestroy(g_models)
}
public OnItemDeployPost(weapon)
{
new player = get_pdata_cbase(weapon, m_pPlayer, CBasePlayerItem)
if (!(get_user_flags(player) & ADMIN_LEVEL_H))
{
return
}
new data[weaponmodel_e], weapon_name[32]
pev(weapon, pev_classname, weapon_name, charsmax(weapon_name))
if (!TrieGetArray(g_models, weapon_name, data, sizeof data))
{
return
}
if (data[WeaponVModel][0])
{
set_pev(player, pev_viewmodel2, data[WeaponVModel])
}
if (data[WeaponPModel][0])
{
set_pev(player, pev_weaponmodel2, data[WeaponPModel])
}
}
LoadConfigFile()
{
new filename[128]
get_configsdir(filename, charsmax(filename))
add(filename, charsmax(filename), "/vip_models.ini")
new file = fopen(filename, "rt")
if (!file)
{
return
}
new buffer[200], weapon_name[32], data[weaponmodel_e]
while (fgets(file, buffer, charsmax(buffer)))
{
trim(buffer)
if (!buffer[0] || buffer[0] == ';' || buffer[0] == '#')
{
continue
}
if (parse(buffer, weapon_name, charsmax(weapon_name), data[WeaponVModel], charsmax(data[WeaponVModel]), data[WeaponPModel], charsmax(data[WeaponPModel])) < 2)
{
continue
}
if (data[WeaponVModel][0])
{
if (!file_exists(data[WeaponVModel]))
{
log_amx("Couldn't find file '%s'", data[WeaponVModel])
data[WeaponVModel][0] = EOS
}
else
{
precache_model(data[WeaponVModel])
}
}
if (data[WeaponPModel][0])
{
if (!file_exists(data[WeaponPModel]))
{
log_amx("Couldn't find file '%s'", data[WeaponPModel])
data[WeaponPModel][0] = EOS
}
else
{
precache_model(data[WeaponPModel])
}
}
TrieSetArray(g_models, weapon_name, data, sizeof data)
}
fclose(file)
}
__________________