View Single Post
cravenge
Veteran Member
Join Date: Nov 2015
Location: Chocolate Factory
Old 10-21-2021 , 22:22   Re: i need help to replace a prop model with custom one
Reply With Quote #5

Iirc, OnEntityCreated fires first before OnMapStart so precaching the model there might be already too late. Why not...
PHP Code:
public void OnEntityCreated(int entity, const char[] classname)

    if (
entity || entity 2048)
    {
        return;
    }
    
    if (
strcmp(classname"weapon_ammo_spawn") == 0
    { 
        
SDKHook(entitySDKHook_SpawnPostHook_EntitySpawned);
    }
}

public 
void Hook_EntitySpawned(int entity
{
    
// I think IsValidEntity is no longer needed here since all hooks get unhooked
    // automatically when the entity in question is destroyed
    
if (!IsModelPrecached("models/witch_bowl/bowl.mdl"))
    {
        
PrecacheModel("models/witch_bowl/bowl.mdl");
    }
    
SetEntityModel(entity"models/witch_bowl/bowl.mdl");

?

Last edited by cravenge; 10-21-2021 at 22:24.
cravenge is offline