Raised This Month: $32 Target: $400
 8% 

Solved Remove Entity and Unprecache before map load


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 06-11-2020 , 11:50   Remove Entity and Unprecache before map load
Reply With Quote #1

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.
__________________
My plugin:

Last edited by Celena Luna; 06-11-2020 at 14:57.
Celena Luna is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 06-11-2020 , 14:01   Re: Remove Entity and Unprecache before map load
Reply With Quote #2

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.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 06-11-2020 at 14:05.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 06-11-2020 , 14:56   Re: Remove Entity and Unprecache before map load
Reply With Quote #3

It is work!
But then it got AllocBlock:Full error.
Oh well, thank you so much for your reply~
__________________
My plugin:
Celena Luna is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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