AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   pcvar help (https://forums.alliedmods.net/showthread.php?t=133046)

sphott 07-21-2010 08:48

pcvar help
 
1 Attachment(s)
I have created a plugin and a guy sad use pcvar etc...
and I tried use pcvar first and i don't know my work is ok, or dont.
if you have some time, plz check it out
I dont know when I use global and local variables too.
its complicated for me at first time, how to use string and others
I dont want to create crap
ty

drekes 07-21-2010 10:15

Re: pcvar help
 
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"); // Register your cvar and store it in cvar_on
    // Do your other stuff
}

public 
client_connect(id)
{
    if(
get_pcvar_num(cvar_on)) // If your cvar is on
    
{
        
// do stuff
    
}



sphott 07-21-2010 12:37

Re: pcvar help
 
Quote:

Originally Posted by drekes (Post 1246656)
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?

Alucard^ 07-21-2010 13:02

Re: pcvar help
 
PHP Code:

public dob1(id

   new 
string[3
   
string get_pcvar_string(cvar_on,string,3
   
client_print.... 


-->

PHP Code:

public dob1(id

   new 
string[3
   
get_pcvar_string(cvar_on,string,3
   
client_print(idprint_chat"string: %s"string);



fysiks 07-21-2010 13:55

Re: pcvar help
 
Quote:

Originally Posted by Alucard^ (Post 1246822)
PHP Code:

public dob1(id

   new 
string[3
   
string get_pcvar_string(cvar_on,string,3
   
client_print.... 


-->

PHP Code:

public dob1(id

   new 
string[3
   
get_pcvar_string(cvar_on,string,3
   
client_print(idprint_chat"string: %s"string);



:arrow:

PHP Code:

public dob1(id

   new 
string[3
   
get_pcvar_string(cvar_on,string,charsmax(string)) 
   
client_print(idprint_chat"string: %s"string);



Alucard^ 07-21-2010 14:28

Re: pcvar help
 
Oh, didn't paid attention to the 3, sry.


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

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