AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   How to Get Cvar String and Set Cvar String(and Num Float) (https://forums.alliedmods.net/showthread.php?t=207978)

wwzw 02-08-2013 18:53

How to Get Cvar String and Set Cvar String(and Num Float)
 
Who wants to help me, teach me how to get Cvar String (num, float), And set Cvar String (num, float).
Thank you very much!

11530 02-08-2013 19:32

Re: How to Get Cvar String and Set Cvar String(and Num Float)
 
PHP Code:

    //Get convar as string
    
new String:buffer[128];
    
GetConVarString(somehandlebuffersizeof(buffer));
    
    
//Set convar as string
    
SetConVarString(somehandle"some string");

    
//Get convar as int
    
new value GetConVarInt(somehandle);

    
//Set convar as int (e.g. 100)
    
SetConVarInt(somehandle100);

    
//Get convar as float
    
new Float:value2 GetConVarFloat(somehandle);

    
//Set convar as float, (e.g. 100.0)
    
SetConVarFloat(somehandle100.0);

    
//For completion's sake, get convar as boolean
    
new bool:value3 GetConVarBool(somehandle);

    
//Set convar as boolean (e.g. true)
    
SetConVarBool(somehandletrue); 


wwzw 02-08-2013 19:52

Re: How to Get Cvar String and Set Cvar String(and Num Float)
 
I would like to ask how to obtain "somehandle"?
For example, I want to obtain and modify the "hostname", specifically, how to do it?

I would like to access or modify some Cvar in "core.cfg". For example: the value of the PassInfoVar, how can I do?

Please teach me in detail, the best is the complete code, thank you!

RedSword 02-08-2013 20:18

Re: How to Get Cvar String and Set Cvar String(and Num Float)
 
FindConVar

wwzw 02-08-2013 21:40

Re: How to Get Cvar String and Set Cvar String(and Num Float)
 
Thank's very much for 11530 and RedSword help me.
I think I can:

new Handle: H_PassInfoVar = FindConVar ("PassInfoVar");
new PassInfoVar [64];
GetConVarString (H_PassInfoVar, PassInfoVar, sizeof (PassInfoVar));

SetConVarString (H_PassInfoVar, "_siteuserpassword");

RedSword 02-08-2013 21:52

Re: How to Get Cvar String and Set Cvar String(and Num Float)
 
Quote:

Originally Posted by wwzw (Post 1890550)
new PassInfoVar [64];

-->

Code:

new String:PassInfoVar [64];
(or decl, but devs will slaps your fingers)

11530 02-08-2013 23:21

Re: How to Get Cvar String and Set Cvar String(and Num Float)
 
I didn't think PassInfoVar was a convar.

wwzw 02-10-2013 09:36

Re: How to Get Cvar String and Set Cvar String(and Num Float)
 
Yes ! PassInfoVar is Invalid convar!
But , How can I get "PassInfoVal" value ?

mcpan313 02-11-2013 06:08

Re: How to Get Cvar String and Set Cvar String(and Num Float)
 
Quote:

Originally Posted by wwzw (Post 1891565)
How can I get "PassInfoVal" value ?

I guess you need this

wwzw 02-12-2013 20:32

Re: How to Get Cvar String and Set Cvar String(and Num Float)
 
Thank you very much!I tested this function is working properly!
But I look at this is to use regular expressions to get content from the text.
Is not the only way we can? SourceMod not the content loaded core.cfg for variables?


All times are GMT -4. The time now is 23:57.

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