Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: RCON Menu - Linkcvar for Server Variables

  1. #1

    Default RCON Menu - Linkcvar for Server Variables

    Hello guys. I was looking to update the Weapons Control section of my admin mod. Currently there are 8 different "styles" to play. For example, cbweapons 1 will allow stock weapon choices, cbweapons 2 will give a sniper/rifle no matter what weapon you pick, cbweapons 3 will give you only a rifle.... the list goes on until you have the option to play with each of the weapons exclusively. I'd like to update this to something like "cb_rifles" with 1 or 0, "cb_shotty" with 1 or 0, so that I can allow admins to more dynamically assign weapon choices per map. I can take care of that no issue. But I don't want my admins to have to type "cb_rifles 1" "cb_shotty 0" "cb_sniper 0" "cb_pistol 0" every time... you get the idea. I was thinking of adding something like this to my RCON menu with commands linked for each weapon in a checkbox:

    resource CheckBox
    {
    title "Pistols"
    name "Default"
    rect 455 235 100 20
    fgcolor 0.70 0.90 0.00 1.00
    bgcolor 0.00 0.00 0.00 0.80
    borderstyle "3D_BORDER"
    linkcvar "rcon pistols"
    }


    But the last line: linkcvar "rcon pistols", doesn't do anything. Linkcvar is only for user variables, like ui_minicon or forced models. Is there any way of using something like linkcvar so it shows a "live status" (checked for on, unchecked for off) of which variables are set to 1 and which are set to 0? I like the visual aspect of doing it this way.

    As always, I appreciate any help in advance.

    Thanks,
    Last edited by [cB]SplatterGuts; December 29th, 2018 at 01:48 AM. Reason: xcode

  2. #2

    Default

    yea, linkcvar is for clientside only.
    you need to send feedback to the admins via 'stufftext' every time a command change to make it work

    also, it should be linkcvar "pistols", without the "rcon"

    Edit: that would be for the visual feedback only
    you will still need to send the command to the server from a button or something else
    Last edited by Zappa; December 29th, 2018 at 03:44 AM.

  3. #3

    Default

    To send a command to the server you have to use stuffcommand "rcon pistols 1".

  4. #4

    Default

    Thanks double, sending the command isn't a problem, I know how to do that. It's the visual part I can't figure out.

    Zappa, thanks for the reply but I don't think I understand. What stufftext would I send to enable the checkbox to update for all admins in their menu?

  5. #5

    Default

    Here's what I'm trying:

    servercommandhandler.scr

    servercommand local.player local.command local.args:

    switch(local.command)
    {
    case "cb_rifle":
    if(local.player isadmin)
    {
    //local.text = (local.command + " " + local.args)
    local.text = ("toggle " + local.command)
    local.cb_riflestatus = getcvar(cb_rifle)
    local.admin_name = netname local.player
    setcvar "currentAdmin" local.admin_name
    wait 1
    stuffsrv local.text
    wait 1
    for(local.i = 1; local.i <= $player.size; local.i++)
    {
    local.player = $player[local.i]
    if(local.i == 1 && local.player.dmteam == spectator)
    {
    // do nothing
    // because this might be a fake player
    // on a 'virgin' dedicated server
    // stufftexting will eventually crash the server
    }
    else
    {
    local.player stufftext ("setu cb_rifle" + " " + local.cb_riflestatus)
    }
    }
    }
    break
    }


    rcontool.urc

    resource
    CheckBox
    {
    title "cb_rifle"
    name "Default"
    rect 455 235 100 20
    fgcolor 0.70 0.90 0.00 1.00
    bgcolor 0.00 0.00 0.00 0.80
    borderstyle "3D_BORDER"
    linkcvar "cb_rifle"
    stuffcommand "scmd cb_rifle"
    }


    It all seems to work except the display on the menu resets to unchecked every time I close the menu. Any thoughts?

  6. #6

    Default

    you have to exit the menu by pressing a button with this inside: stuffcommand "popmenu 0"
    if you close it by pressing the Escape key, the checkbox value won't be saved

  7. #7

    Default

    Good to know. I would have never guessed that.

    I think another issue was I was getting the cvar before I was actually changing it, so I reordered a few things in the servercommandhandler:


    servercommand local.player local.command local.args:

    switch(local.command)
    {
    case "cb_rifle":
    if(local.player isadmin)
    {
    local.text = ("toggle " + local.command)
    local.admin_name = netname local.player
    setcvar "currentAdmin" local.admin_name
    wait 1
    stuffsrv local.text
    wait 1
    local.cb_riflestatus = getcvar(cb_rifle)
    for(local.i = 1; local.i <= $player.size; local.i++)
    {
    local.player = $player[local.i]
    if(local.player != NULL)
    {
    local.player stufftext ("setu cb_rifle" + " " + local.cb_riflestatus)
    }
    }
    }
    break
    }


    And that seems to keep the checkbox showing an accurate variable. scmd cb_rifle toggles the setting on/off just like it should and that updates the local variable through the stufftext. Now I just need to use the connect event to push the stufftext to all the new people joining the server (or new admins authing in to use rcon).

    Thanks for your help. I'll post this up when it's done for anyone interested.

  8. #8

    Default

    just one more thing
    will be better if you use set instead of setu in the stufftext, so you leave the players .userinfo intact

  9. #9

    Default

    Good to know.

    I was wondering if there's a way to make this more fluid, so I didn't have to make a case for each weapon selection. Something like this:


    case "cb_rifle":
    if(local.player isadmin)
    {
    local.text = ("toggle " + local.command)
    local.admin_name = netname local.player
    setcvar "currentAdmin" local.admin_name
    wait 1
    stuffsrv local.text
    wait 1
    ("local." + local.command + "status") = ("getcvar(" + local.command + ")")
    for(local.i = 1; local.i <= $player.size; local.i++)
    {
    local.player = $player[local.i]
    if(local.player != NULL)
    {
    local.player stufftext ("set " + local.command + " " + ("local." + local.command + "status")
    }
    }
    }


    But no luck with that. Is something like this possible? Or will I need to make a new case for each weapon I want to toggle?

  10. #10

    Default

    yes, try with this


    servercommand local.player local.command local.args:
    if (local.player isadmin) {
    switch (local.command) {
    case "cb_rifle":
    case "cb_shotty":
    case "cb_sniper":
    case "cb_pistol":
    local.admin_name = netname local.player
    setcvar "currentAdmin" local.admin_name
    stuffsrv ("toggle " + local.command)
    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)))
    }
    }
    break;
    default:
    break;
    }
    }
    end


    there you can add more 'cases' like this:
    case "cb_rifle":
    case "cb_shotty":
    case "cb_sniper":
    case "cb_pistol":
    without changing the rest of the code

Posting Permissions

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