Quote:
Originally Posted by drekes
pcvars work like this.
PHP Code:
#include <amxmodx>
new cvar_on // Make a global var to store your cvar
public plugin_init()
{
cvar_on = register_cvar("amx_stuff", "1");
}
public client_connect(id)
{
if(get_pcvar_num(cvar_on)) // If your cvar is on
{
// do stuff
}
}
|
Its ok, but most of my cvars are string and I don't know how to use string pcvars. What is the optimal store of string in global or in local variable.
I think the local, but what is the number of local equal a global cpu usage.
in your example:
PHP Code:
#include <amxmodx>
new cvar_on // Make a global var to store your cvar
public plugin_init()
{
cvar_on = register_cvar("amx_stuff", "doh"); // Register your cvar and store it in cvar_on
// Do your other stuff
}
public dob1(id)
{
new string[3]
string = get_pcvar_string(cvar_on,string,3)
client_print....
}
public dob2(id)
{
new string[3]
string = get_pcvar_string(cvar_on,string,3)
client_print....
}
...
...
public dobx(id)
{
new string[3]
string = get_pcvar_string(cvar_on,string,3)
client_print....
}
And why is this solution works better with string, than cvar. Or is another way?
__________________