AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   native error @ plugin_precache (https://forums.alliedmods.net/showthread.php?t=83481)

xPaw 01-10-2009 11:00

native error @ plugin_precache
 
Quote:

Originally Posted by Server
L 01/10/2009 - 17:47:03: Invalid CVAR pointer
L 01/10/2009 - 17:47:03: [AMXX] Displaying debug trace (plugin "EgdeBugStats.amxx")
L 01/10/2009 - 17:47:03: [AMXX] Run time error 10: native error (native "get_pcvar_num")
L 01/10/2009 - 17:47:03: [AMXX] [0] EgdeBugStats.sma::plugin_precache (line 134)

PHP Code:

// [..]
new gCvar_Sounds;

public 
plugin_precache()
    
gCvar_Sounds        register_cvar("kz_eb_sounds",        "1");

public 
plugin_precache() {
    
gBeamSprite precache_model("sprites/dot.spr");
    
    if( 
get_pcvar_num(gCvar_Sounds) ) {    // line 134.
        
precache_sound("misc/mod_godlike.wav");
        
precache_sound("misc/mod_wickedsick.wav");
        
precache_sound("misc/mod_perfect.wav");
        
precache_sound("misc/mod_impressive.wav");
        
precache_sound("misc/double.wav");
        
precache_sound("misc/triple.wav");
    }


howto fix?

danielkza 01-10-2009 11:05

Re: native error @ plugin_precache
 
plugin_precache happens before plugin_init, so the cvars may not exist yet. And you can't have plugin_precache twice, merge it in a single block. (I don't even know if you can register cvars in precache. If not, you should use a text file instead)

Arkshine 01-10-2009 11:07

Re: native error @ plugin_precache
 
To avoid to miss with pointer in such function, you should try to declare your cvar in plugin_init () and precaching all sounds using EngFunc_PrecacheSound, in plugin_init() or plugin_cfg().

xPaw 01-10-2009 11:19

Re: native error @ plugin_precache
 
ok ty fixed.


All times are GMT -4. The time now is 01:55.

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