AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   About plugin_precache() (https://forums.alliedmods.net/showthread.php?t=126331)

epic . 05-08-2010 09:48

About plugin_precache()
 
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

Arkshine 05-08-2010 10:09

Re: About plugin_precache()
 
plugin_precache() is called before plugin_init(), so the first time it won't work because the cvar was not registered yet.

epic . 05-08-2010 10:21

Re: About plugin_precache()
 
Quote:

Originally Posted by Arkshine (Post 1174403)
plugin_precache() is called before plugin_init(), so the first time it won't work because the cvar was not registered yet.

Really thanks
:)

Arkshine 05-08-2010 10:40

Re: About plugin_precache()
 
You can precache things in plugin_init() by using EngFunc_PrecacheModel, EngFunc_PrecacheSound, or EngFunc_PrecacheGeneric.


All times are GMT -4. The time now is 03:50.

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