AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Plugin efficiency (https://forums.alliedmods.net/showthread.php?t=182977)

r4ndomz 04-15-2012 19:30

Plugin efficiency
 
Would it be more efficient for this code if I were to take the pcvar and make a global variable for its value to be used instead of calling the get_pcvar_num fuction every time I need the value for a pcvar? I know I would have to change the map for the cvar to be updated.

Like this:

PHP Code:

#include <amxmodx>

new pcvar
new g_pcvarvalue

public plugin_init()
{
    
register_plugin("efficient","1.0","r4ndomz")

    
pcvar register_cvar("qwerty""1");
}

public 
plugin_cfg()
{
    
g_pcvarvalue get_pcvar_num(pcvar);
}

public function(
id)
{
    
client_print(idprint_chat"%i"g_pcvarvalue);



fysiks 04-15-2012 19:43

Re: Plugin efficiency
 
Yes but it's likely it won't be significant unless you have many and are called very often like in a think forward or something.


All times are GMT -4. The time now is 07:42.

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