View Single Post
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 06-14-2021 , 00:05   Re: ERROR: SV_Modelindex Model not prechached
Reply With Quote #3

I am not sure but try to put plugin_precache() after plugin_init()

Also, it is a bit out of topic but you shouldn't change weapon model at Event_CurWeapon since it will call many time cause increase in server usage. This way is out-dated.
Now we used Ham_Item_Deploy to set weapon model only once when you switch to that specific weapon only

PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <fakemeta> 

new const model_1[] = "models/model_1.mdl"
new const model_2[] = "models/model_2.mdl"

public plugin_init()
{
    
RegisterHam(Ham_Item_Deploy"weapon_usp""fw_Weapon_Deploy"1//change weapon_usp to the weapon you want to replace
}

public 
plugin_precache(){
    
precache_model(model_1)
    
precache_model(model_2)

    
public 
fw_Weapon_Deploy(ent)
{
    if(
pev_valid(ent) != 2)
        return
    static 
idid get_pdata_cbase(ent414//Get ID
    
if(get_pdata_cbase(id373) != ent//373 = m_pActiveItem. This check if current weapon is correct or not
        
return

    
set_pev(idpev_viewmodel2model_1)
    
set_pev(idpev_weaponmodel2model_2)

Edit: This is assuming you are try to make CS weapon.
__________________
My plugin:

Last edited by Celena Luna; 06-14-2021 at 00:30.
Celena Luna is offline