Page 2 of 2 FirstFirst 12
Results 11 to 17 of 17

Thread: RCON Menu - Linkcvar for Server Variables

  1. #11

    Default

    Ah duh... I was over-complicating it. Thanks for your help! I'll give that a shot.

  2. #12

    Default

    That works great. Now running into a new issue. When I turn on"Rifles Only" I want all the other "only" selections to be off. I would have thought something like this would work:


    case "cb_rifleonly":
    if (local.player isadmin)
    {
    local.admin_name = netname local.player
    setcvar "driving" local.admin_name
    stuffsrv ("toggle " + local.command)
    wait 1
    if(getcvar(local.command) == 1)
    {
    setcvar "cb_sniperonly" "0"
    setcvar "cb_smgonly" "0"
    setcvar "cb_mgonly" "0"
    setcvar "cb_rocketonly" "0"
    setcvar "cb_shotgunonly" "0"
    setcvar "cb_pistolonly" "0"
    setcvar "cb_dualrifle" "0"
    setcvar "cb_boltaction" "0"
    setcvar "cb_allweapons" "0"
    setcvar "cb_bashonly" "0"
    }
    wait 1
    for (local.i = 1; local.i <= $player.size; local.i++)
    {
    local.player = $player[local.i]
    if (local.player)
    {
    local.player stufftext ("set " + local.command + " " + (getcvar(local.command)))
    if(getcvar(local.command) == 1)
    {
    local.player stufftext ("set cb_sniperonly 0")
    local.player stufftext ("set cb_smgonly 0")
    local.player stufftext ("set cb_mgonly 0")
    local.player stufftext ("set cb_rocketonly 0")
    local.player stufftext ("set cb_shotgunonly 0")
    local.player stufftext ("set cb_pistolonly 0")
    local.player stufftext ("set cb_dualrifle 0")
    local.player stufftext ("set cb_boltaction 0")
    local.player stufftext ("set cb_allweapons 0")
    local.player stufftext ("set cb_bashonly 0")
    }
    }
    }
    }
    break


    but it's not setting server or client variables when I turn "Sniper Only" to 1 and "Rifle Only" to 1 (expected behavior is that sniper only would go to 0 when rifle only goes to 1).

    Does anything stick out at you for why this wouldn't be setting the variables?

    help.png

  3. #13

    Default

    probably the command values are stated as a string, not as an integer
    try changing this

    if(getcvar(local.command) == 1)

    to this

    if(getcvar(local.command) == "1")

  4. #14

    Default

    Any cvar you get will always retrieve as string unless you convert first to the type you whant:

    if(getcvar(int(local.command) == 1)
    Last edited by DoubleKill; January 1st, 2019 at 02:57 AM.

  5. #15

    Default

    Quote Originally Posted by DoubleKill View Post
    Any cvar you get will always retrieve as string unless you convert first to the type you whant:

    if(getcvar(int(local.command) == 1)
    yes, but that example is bad.
    you are converting the command name (local.command) to int and a parenthesis is missing.
    should be like this

    if(int(getcvar(local.command)) == 1)

  6. #16

    Default

    Is there an advantage to returning an integer vs a string for my purposes?

  7. #17

    Default

    in this case both ways lead to the same result, so not really
    just different ways to check the same thing

Posting Permissions

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