Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder GO ILLINI's Avatar
    Join Date
    Jun 2005
    Location
    USA
    Posts
    634
    Thanks
    0
    Thanked 7 Times in 7 Posts

    variable variables not working

    PHP Code:
    $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)
    Code:
    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
    Why not thank me?

    http://adamsworld.name

  • #2
    Senior Coder
    Join Date
    Sep 2005
    Posts
    1,791
    Thanks
    5
    Thanked 36 Times in 35 Posts
    your "$$line[0]" is ambiguous, so PHP won't know what to do. You want to use:
    ${$line[0]} instead.
    My thoughts on some things: http://codemeetsmusic.com
    And my scrapbook of cool things: http://gjones.tumblr.com

  • #3
    Regular Coder GO ILLINI's Avatar
    Join Date
    Jun 2005
    Location
    USA
    Posts
    634
    Thanks
    0
    Thanked 7 Times in 7 Posts
    I changed that, and it still didnt work, then I added quotes to the second variable, still didnt work.


    -Adam
    Why not thank me?

    http://adamsworld.name

  • #4
    Regular Coder
    Join Date
    May 2006
    Location
    Wales
    Posts
    820
    Thanks
    1
    Thanked 82 Times in 79 Posts
    I think the variable name would be '$mp_limitteams' ?

  • #5
    Regular Coder GO ILLINI's Avatar
    Join Date
    Jun 2005
    Location
    USA
    Posts
    634
    Thanks
    0
    Thanked 7 Times in 7 Posts
    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
    Why not thank me?

    http://adamsworld.name

  • #6
    Regular Coder GO ILLINI's Avatar
    Join Date
    Jun 2005
    Location
    USA
    Posts
    634
    Thanks
    0
    Thanked 7 Times in 7 Posts
    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
    Why not thank me?

    http://adamsworld.name


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •