Raised This Month: $ Target: $400
 0% 

PCvars?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 11-07-2006 , 09:14   Re: PCvars?
Reply With Quote #6

Quote:
Originally Posted by The Specialist View Post
a pcvar is basicly amxmodx's verrsion of a pointer . hooking a varaible directly to cvars . the only time you need to use them is if you use a get_cvar_num("whatever") more then once. if you only use the cvars once in a script theres no need to make a varaible to handle it . becasue everytime a varaible is declared , memory is alocated to handle the variable. so if you use the same cvar more then once , you can use a "pointer" to get and find the varaibles easyier .
Not really. Your sacrificing memory for speed. set/get_pcvar_* is a lot faster than set/get_cvar_*.

Code:
#include <amxmodx> new pHello; public plugin_init() {     register_forward(FM_PlayerPreThink, "_FM_PlayerPreThink");     pHello = register_cvar("Hello", "1"); } public _FM_PlayerPreThink(player) {     if(!get_pcvar_num(pHello)     {     }     return FMRES_IGNORED; }

Even if this was all the code. I would still use pcvar in this situation. It also depends on the situation to. Even though the cvar is only use once in this situation. I would do this even though it only use once in this plugin.

Code:
#include <amxmodx> public plugin_init() { } public plugin_cfg() {     new host[64], db[64], user[64], pass[64];         get_cvar_string("host", host, 63);     get_cvar_string("db", db, 63);     get_cvar_string("user", user, 63);     get_cvar_string("pass", pass, 63);         // Do db connection. }

I would not use pcvar here if your not going to use it more than once. Since this is only start of the plugin. Other than that I would only use normal set/get_cvar_* in plugin_init or plugin_cfg.
__________________
No private support via Instant Message
GunGame:SM Released
teame06 is offline
Send a message via AIM to teame06
 



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 06:57.


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