Raised This Month: $51 Target: $400
 12% 

Plugin efficiency


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
r4ndomz
Senior Member
Join Date: Jul 2009
Location: The Hood
Old 04-15-2012 , 19:30   Plugin efficiency
Reply With Quote #1

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);

__________________
HideNSeek bug fixed here:http://forums.alliedmods.net/showpos...&postcount=951

PM me if you want a nice HideNSeek shop
NEED PLUGIN TESTERS PM ME

Last edited by r4ndomz; 04-15-2012 at 19:32.
r4ndomz is offline
Send a message via Skype™ to r4ndomz
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-15-2012 , 19:43   Re: Plugin efficiency
Reply With Quote #2

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.
__________________

Last edited by fysiks; 04-15-2012 at 19:44.
fysiks 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 09:02.


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