Answered How do you change starting pistol in zombies?

Discussion in 'Redacted T6' started by Victor Koulikov, May 23, 2018.

  1. Victor Koulikov

    Victor Koulikov Member

    16
    2
    8
    Credits:
    152
    I've managed to change the perk limit by making my own script, by using BO3 tutorials and figuring out that "inti()" is like "main()" (At least that's how it seemed when I changed the perk limit). But when I applied the same logic to changing the starting weapon, nothing worked. I tried one line, level.start_weapon = getWeapon("m1911_zm") I tried this,
    startingWeapon = "m1911_zm";
    weapon = getWeapon(startingWeapon);
    level.start_weapon = (weapon);
    "
    I tried different spacing between level.perk_purchase_limit = 13; and the weapon line(s), nothing worked. I tried using a custom loadout function, but I think that's only in BO3. I don't understand why this simple code doesn't work. I would highly appreciate if someone knew how to code this specifically in BO2. If anyone is curious, this is the whole script. And in case anyone is wondering, I want to change it to the already default starting pistol because I want to have it in Origins for the Mustang and Sally.

    //
    //

    init()
    {
    thread onplayerconnect();
    //SetDvar("r_enablePlayerShadow", 1); // Causes laser flickering
    level.perk_purchase_limit = 13;
    }

    onplayerconnect()
    {
    while(true)
    {
    level waittill("connecting", player);
    player thread onplayerspawned();
    player thread showConnectMessage();
    }
    }

    onplayerspawned()
    {
    self endon( "disconnect" );
    displayMessage = true;
    while(true)
    {
    self waittill( "spawned_player" );

    }
    }

    showConnectMessage()
    {
    self endon( "disconnect" );
    self waittill( "spawned_player" );
    self iprintln("^1Redacted^7: " + self.name);
    }
     
  2. candy

    candy G59 Terrorist Donator

    1,086
    724
    398
    Credits:
    5,954
    Just do this.
    Code:
    onPlayerSpawned()
    {
        self waittill("spawned_player");
        self takeWeapon("m1911_zm");
        self giveWeapon(<weapon name>);
        self switchToWeapon(<weapon name>);
    }
     
  3. Victor Koulikov

    Victor Koulikov Member

    16
    2
    8
    Credits:
    152
    It doesn't work for me for some reason. I tried the whole script with just onPlayerSpawned() changed, I've tried it like this
    Code:
    onplayerspawned()
    {
        self endon( "disconnect" );
        displayMessage = true;
        while(true)
        {
            self waittill( "spawned_player" );
            self takeWeapon("m1911_zm");
            self giveWeapon(<weapon name>);
            self switchToWeapon(<weapon name>);
        }
    }
    After some more looking I saw that ("spawned_player"); was actually ( "spawned_player" ) in the BO2 code (as I was pasting the code you wrote), I thought that would fix it, but no change, map doesn't load. My onplayspawn section looks like
    Code:
    onPlayerSpawned()
    {
        self waittill( "spawned_player" );
        self takeWeapon("m1911_zm");
        self giveWeapon(<weapon name>);
        self switchToWeapon(<weapon name>);
    }
     
  4. candy

    candy G59 Terrorist Donator

    1,086
    724
    398
    Credits:
    5,954
    Well you need to actually replace <weapon name> thats just a place holder so you can put the weapon name you want there.
     
  5. Victor Koulikov

    Victor Koulikov Member

    16
    2
    8
    Credits:
    152
    I'm stupid. Well, I changed it and the map loads, but the starting pistol is still the Mauser.
    Code:
    onPlayerSpawned()
    {
        self waittill("spawned_player");
        self takeWeapon("m1911_zm");
        self giveWeapon("m1911_zm");
        self switchToWeapon("m1911_zm");
    }
    EDIT: I have tested the Ray Gun Mark II, and it works. I feared that because the M1911 isn't in the map, it might not even be in the map code, so it doesn't work. :/ I really wanted to use the Mustang and Sally on Origins.
     
    Last edited: May 23, 2018
  6. candy

    candy G59 Terrorist Donator

    1,086
    724
    398
    Credits:
    5,954
    Ya I don't think its in that map at all. Its been replaced with the Mauser, like you said.
     
  7. Victor Koulikov

    Victor Koulikov Member

    16
    2
    8
    Credits:
    152
    I wish I was knowledgeable enough on how to mod Redacted, so I can make map specific mods, where I can add the m1911. The help you gave me was still useful, I can spawn with the m1911 (or Mauser) and B23R at the same time.

    There's one other line of code that I would really appreciate it if you could help me with. I want to increase player health in zombies, so it takes 3 hit to get down without Jugg. In inti() I wrote this line
    Code:
    SetDvar("g_player_maxhealth", 5000);
    The map loads, so at least the code isn't wrong, but it doesn't have an effect, still 2 hits down. This seems like the code that should change it. If you don't know how to help with this code, that's fine. I appreciate your help, I was not expecting a response so soon. Thank you :smile:
     
  8. candy

    candy G59 Terrorist Donator

    1,086
    724
    398
    Credits:
    5,954
    Code:
    self.health = 300;
    self.maxhealth = self.health;
     
  9. Victor Koulikov

    Victor Koulikov Member

    16
    2
    8
    Credits:
    152
    Map loads, still 2 hits to down. I've increased it to 1,000. Why doesn't it work? :confused:
     
  10. candy

    candy G59 Terrorist Donator

    1,086
    724
    398
    Credits:
    5,954
    gimme a couple min, I'll test it.
     
  11. candy

    candy G59 Terrorist Donator

    1,086
    724
    398
    Credits:
    5,954
    It works fine for me, show me how you're doing it.
     
  12. Victor Koulikov

    Victor Koulikov Member

    16
    2
    8
    Credits:
    152
    Code:
    init()
    {
        thread onplayerconnect();
        //SetDvar("r_enablePlayerShadow", 1); // Causes laser flickering
        level.perk_purchase_limit = 13;
        self.health = 1000;
        self.maxhealth = self.health;
    }
    Sorry for late reply, internet went out for a bit.
     
  13. candy

    candy G59 Terrorist Donator

    1,086
    724
    398
    Credits:
    5,954
    Yeah don't run it on 'init' because that runs before player connection & spawning. You have to run it on onPlayerSpawned or after.
     
  14. Victor Koulikov

    Victor Koulikov Member

    16
    2
    8
    Credits:
    152
    Thank you... very much. I have plenty of other questions, but I'll just open a separate topic for it, hopefully someone else can help out. Thank you. :smile:
     
  15. candy

    candy G59 Terrorist Donator

    1,086
    724
    398
    Credits:
    5,954
    I'll keep an eye out then. :y:
     
    Victor Koulikov likes this.
  16. Victor Koulikov

    Victor Koulikov Member

    16
    2
    8
    Credits:
    152
    You've made my day. :smile: Have a good one!
     
    candy likes this.
  17. candy

    candy G59 Terrorist Donator

    1,086
    724
    398
    Credits:
    5,954
    @Victor Koulikov If there related similarly to this thread, BO2 gsc, then post them here instead.
    Please login or register to view links or downloads!
     
  18. Victor Koulikov

    Victor Koulikov Member

    16
    2
    8
    Credits:
    152
    Oh, thank you VERY much. I was hoping to find a BO2 scripting forum, I thought I would only find those in Redacted related forums. Thank you :smile:
     
    candy likes this.
  19. Victor Koulikov

    Victor Koulikov Member

    16
    2
    8
    Credits:
    152
    I do apologize, but I have an issue, with the map Mob of the Dead. The health increase doesn't work, I believe it's because the code is set to when to player spawns, when you first spawn in MotD you are in Afterlife mode. I assume the health increase is set on Afterlife mode, it didn't seem to increase time or health in afterlife mode however.

    It functions on every map, 4 hits down (also playing with a friend who hasn't play zombies since the BO1 days, want something easier to get them into the grooves again.), except on Nuketown, takes 5 hits down, tested several times. I tried adding the self.health code in the OnPlayerConnected section, map loads, and no health changes whatsoever are in effect.

    Is there a function you know of that will allow the health to be set after the player is revived by themselves in Afterlife? Mob of the Dead was the map I wanted the health increase the most on, if you get downed without Jugg, on a round higher than 10, if you don't have money you're done for (If you're not really experienced and really good). I hope there is a function you might know of that can work. Regardless, thank you for trying, and helping me. :smile:
     
  20. candy

    candy G59 Terrorist Donator

    1,086
    724
    398
    Credits:
    5,954
    Yes, the health is automatically reset back to 100 when a player enters afterlife mode.

    Here you go.
    Code:
    healthLoop()
    {
        self.isHealthSet = undefined;
        while( true )
        {
            if(!self.afterlife && !isDefined(self.isHealthSet))
            {
                self.isHealthSet = true;
                self.health = 400;
                self.maxhealth = self.health;
            }
            else if(self.afterlife && isDefined(self.isHealthSet))
                self.isHealthSet = undefined;
            wait .05;
        }
    }
     
    Last edited: May 24, 2018

Share This Page