Quote:
Originally Posted by The Specialist
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.
__________________