...

View Full Version : variable variables not working



GO ILLINI
07-20-2007, 09:31 AM
$lines = file("{$directories['srcds']}/cstrike/cfg/server.cfg");

foreach ($lines as $line_num => $line) {
if(strstr($line,'// END CVAR LISTING'))
{
break;
}
$line = explode(" ", $line,2);
$$line[0] = $line[1];
}
Some of the config file(server.cfg)

hostname "Counter-Strike Server"
rcon_password ""
mp_friendlyfire 0
mp_footsteps 1
mp_autoteambalance 1
mp_autokick 0
mp_flashlight 0
mp_tkpunish 1
mp_forcecamera 0
sv_alltalk 0
sv_pausable 0
sv_cheats 0
sv_consistency 1
sv_allowupload 1
sv_allowdownload 1
sv_maxspeed 320
mp_limitteams 2

Now I want to be able to get the variables like $mplimitteams, but only some of them are created. Im not sure whats going on because i dont get any errors, and some of them work, and some dont.

Thanks,
-Adam

GJay
07-20-2007, 01:52 PM
your "$$line[0]" is ambiguous, so PHP won't know what to do. You want to use:
${$line[0]} instead.

GO ILLINI
07-20-2007, 06:01 PM
I changed that, and it still didnt work, then I added quotes to the second variable, still didnt work.


-Adam

Mwnciau
07-20-2007, 07:37 PM
I think the variable name would be '$mp_limitteams' ?

GO ILLINI
07-20-2007, 09:24 PM
sorry yeah... that was a typo in the post... but in the page, ive been copy and pasting variables directly from the cfg file.

-Adam

GO ILLINI
07-20-2007, 10:06 PM
I found the problem... The thing that generated the config files removes the cvar completely if the option set is the default.

Sorry bout that...

-Adam



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum