AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Remove Entity and Unprecache before map load (https://forums.alliedmods.net/showthread.php?t=325188)

Celena Luna 06-11-2020 11:50

Remove Entity and Unprecache before map load
 
Is there anyway to remove entities and unprecache their models before the map even load?
I look through the forum and only saw the unprecache part which only prevent from precaching but if the entity was in the map first then it will crash and return "Host_Error: no precache" error

Here is what I got so far.

PHP Code:

new const Remove_Obj[][] =
{
    
"custom_moodel1",
    
"custom_moodel2",
    ...
}

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
Remove_Ent()
}

public 
plugin_precache( ) 
{
    
register_forwardFM_PrecacheModel"fw_PrecacheModel" )    
}

public 
fw_PrecacheModel( const Model[ ] ) 

    new 
Contain
    
for( new 0sizeofRemove_Obj ); i++ ) 
    { 
        
Contain containi(ModelRemove_Obj[i])
        if(
Contain != -1
            return 
FMRES_SUPERCEDE
    
}
    
    return 
FMRES_IGNORED 
}

public 
Remove_Ent()
{
    new const 
MAXENTS get_global_int(GL_maxEntities)
    new 
Model[64]
    new 
CountContain
    
for(new ent 1ent MAXENTSent++) 
    {
        for( new 
0sizeofRemove_Obj ); i++ ) 
        { 
            if (!
is_valid_ent(ent))
                continue
            
            
pev(entpev_modelModelcharsmax(Model))
            
Contain contain(ModelRemove_Obj[i])
            if(
Contain != -1
            {
                
remove_entity(ent)
                
server_print("ID: %i | Model: %s"entModel)
                
Count++
                continue
            }
        }
    }

    
server_print("Total: %i"Count)


This will remove the object and unprecache it IF the map was loaded.
But I want to remove it BEFORE that map was load to bypass the 512 precache limit.

Natsheh 06-11-2020 14:01

Re: Remove Entity and Unprecache before map load
 
Try to Hook FM_SetModel Pre in plugin_precache check if it's the required model and then block the call and remove the entity.

Celena Luna 06-11-2020 14:56

Re: Remove Entity and Unprecache before map load
 
It is work!
But then it got AllocBlock:Full error.
Oh well, thank you so much for your reply~


All times are GMT -4. The time now is 17:13.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.