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

Thread: RCON Command to Shuffle Teams

  1. #11

    Default

    Quote Originally Posted by Criminal View Post
    Yo, zappa, does Morpheus interpreter care about ";"?

    Also if you could explain what this line do, because I'm not so sure that I can go to other languages for explanation.

    local.bounds = local.lower::local.upper;
    yes, if you want to do something like this

    local.r = 0; local.g = 1; local.b = 1;
    $world farplane_color ( local.r local.g local.b );


    although they are not necessary at the end of the line.
    and i like to follow Sor's scripting style xD


    Script Files.txt from Mohaatools says:
    Code:
    1) Constant array
    Created by expression of the form entry_1::entry_2::entry_3:: ... :: entry_n
    Constant arrays start their indexing at 1.
    Once created a constant array can not be changed but it can be read for its values.

  2. #12

    Default

    About several instructions I knew, I use it in bindings becaue I'm lazy and clicking two buttons is too much. Ty for explanation of ::.
    Feel like talking to me? DM me on:
    a) Facebook
    b) Discord tag: Criminal#9220

  3. #13

    Default

    I don't think the description is true. The values can be changed after the fact AFAIK.

  4. #14

    Default

    Thanks everyone. I'd like to find a way to keep the weapon selection, if you had a kar, keep a kar, if you had a springfield, keep a springfield etc.. but this is good for now. I've wrapped it around a loop for executing via rcon - here's that if anyone is interested:


    // RCON support for "randomly" shuffling teams - thanks to X-Null community
    // rcon shuffle_teams 1 to execute

    main:
    setcvar "shuffle_teams" ""

    while (1)
    {
    local.cvar = getcvar "shuffle_teams"

    if(local.cvar != "")
    {
    teamswitchdelay 0;
    for (local.i = 1; local.i <= $player.size; local.i++) {
    local.player = $player[local.i];
    local.player spectator;
    }
    wait 1
    for (local.i = 1; local.i <= $player.size; local.i++) {
    local.array[local.i] = local.i;
    }

    local.array = waitthread Shuffle local.array local.array[1] local.array.size;

    for (local.i = 1; local.i <= local.array.size; local.i++) {
    local.player = $player[local.array[local.i]];
    if (local.i % 2)
    local.player join_team allies;
    else
    local.player join_team axis;
    local.player primarydmweapon sniper;
    local.player respawn;
    }
    setcvar "shuffle_teams" ""
    }
    wait 0.5
    }
    end;

    Shuffle local.array local.lower local.upper:
    local.bounds = local.lower::local.upper;
    for (local.i = local.bounds[2]; local.bounds[1] <= local.i; local.i--) {
    local.swapIdx = randomint(abs(local.i)) + local.bounds[1];
    local.tmp = local.array[local.i];
    local.array[local.i] = local.array[local.swapIdx];
    local.array[local.swapIdx] = local.tmp;
    }
    end local.array;
    Last edited by [cB]SplatterGuts; February 10th, 2019 at 12:29 PM.

  5. #15

    Default

    BTW, you could delete that thing from your script, it will run without it, and it hurts eyes. It could be changed to local also, global variables are often unnecesary evil.

    if(level.rcon_shuffle_teams == 1)
    end

    level.rcon_shuffle_teams = 1
    Last edited by Criminal; February 10th, 2019 at 12:28 PM.
    Feel like talking to me? DM me on:
    a) Facebook
    b) Discord tag: Criminal#9220

  6. #16

    Default

    Gone! Thanks, sometimes I just add things because I've "always added them" - must've been in one of the first rcon commands I built with help from xnul so I just keep copy/pasting it from my existing work without questioning why.

  7. #17

    Default

    I have no idea if it shouldn't be != tho. It's trick of old scripters, one of explanations to this which I heard is: It makes sure that script will be executed. But let's face it, if script is not total crap and if it's executed properly it will run no matter what.
    Feel like talking to me? DM me on:
    a) Facebook
    b) Discord tag: Criminal#9220

  8. #18
    Developer RyBack's Avatar
    Join Date
    Apr 2014
    Location
    In Front of the screen
    Posts
    1,458

    Default

    Quote Originally Posted by Criminal View Post
    BTW, you could delete that thing from your script, it will run without it, and it hurts eyes. It could be changed to local also, global variables are often unnecesary evil.

    if(level.rcon_shuffle_teams == 1)
    end

    level.rcon_shuffle_teams = 1
    dmprecache gets called twice, and dmprecache calls the script. To avoid getting your script being called twice, you add that simple check. Level.* vars are shared among all scripts, like level.time.

Posting Permissions

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