Raised This Month: $ Target: $400
 0% 

About plugin_precache()


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
epic .
Senior Member
Join Date: Oct 2009
Location: China
Old 05-08-2010 , 09:48   About plugin_precache()
Reply With Quote #1

Code:
public plugin_init()
{
    register_plugin("Sample", "100.0", "epic")
    ABC_enable = register_cvar("ABC_enable", "1") 
}
public plugin_precache()
{
    lightning = precache_model("sprites/lgtning.spr")
    precache_sound("ambience/thunder_clap.wav")
    if( get_pcvar_num(ABC_enable) == 1 ) 
    {
        g_spriteSmoke = precache_model("sprites/wall_puff4.spr")
    }
}
When I use this code, it only precache the lightning.spr and thunder_clap.wav. But the g_spriteSmoke doesn`t precache, why ?

Thanks
__________________
Quote:
Destinies in my AWP sight are all alike;
Destinies out of my AWP sight in its own way.
epic . is offline
Send a message via ICQ to epic .
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 05-08-2010 , 10:09   Re: About plugin_precache()
Reply With Quote #2

plugin_precache() is called before plugin_init(), so the first time it won't work because the cvar was not registered yet.
__________________
Arkshine is offline
epic .
Senior Member
Join Date: Oct 2009
Location: China
Old 05-08-2010 , 10:21   Re: About plugin_precache()
Reply With Quote #3

Quote:
Originally Posted by Arkshine View Post
plugin_precache() is called before plugin_init(), so the first time it won't work because the cvar was not registered yet.
Really thanks
__________________
Quote:
Destinies in my AWP sight are all alike;
Destinies out of my AWP sight in its own way.
epic . is offline
Send a message via ICQ to epic .
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 05-08-2010 , 10:40   Re: About plugin_precache()
Reply With Quote #4

You can precache things in plugin_init() by using EngFunc_PrecacheModel, EngFunc_PrecacheSound, or EngFunc_PrecacheGeneric.
__________________
Arkshine is offline
Reply


Thread Tools
Display Modes

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 03:50.


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