Untested. If this doesn't work, type "amx_showrcon amxx list" without the quotes in your console and output the result in [code] tags.
Code:
#include <amxmodx>
new const filename[] = "yourfile.cfg"
public plugin_init()
{
register_plugin( "Cvar Config Example", "1.0", "Wrecked" )
if( !Read_Cvar_File() )
{
set_fail_state( "Error loading config file!" )
}
}
Read_Cvar_File()
{
if( !file_exists( filename ) )
{
return 0;
}
new f = fopen( filename, "r" )
if( !f )
{
return 0;
}
new info[64]
new cvarname[32]
new val[8]
while( !feof( f ) )
{
fgets( f, info, 63 )
trim( info )
if( info[0] == ';' || !info[0] )
{
continue;
}
parse( info, cvarname, 31, val, 7 )
register_cvar( cvarname, val )
}
fclose( f )
return 1;
}
The config file should look like this and be located in your cstrike dir. If you'd like it in your config directory then just tell me. You asked for server.cfg so I figured you'd want it in here.
Code:
;cvar_name value
;semicolon prefixes are skipped
hero_health 250
other_cvar 90
To test it you can just type "amx_cvar hero_health" or whatever your cvar name and see if it gives you the value or tells you if it's an invalid cvar.
Sorry if I made any careless typos in the code.
__________________