Answered How do you change starting pistol in zombies?

Messages
17
Points
8
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);
}
 

candy

G59 Terrorist
Staff member
Donator
Messages
1,299
Points
548
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);
}
Just do this.
Code:
onPlayerSpawned()
{
    self waittill("spawned_player");
    self takeWeapon("m1911_zm");
    self giveWeapon(<weapon name>);
    self switchToWeapon(<weapon name>);
}
 
Messages
17
Points
8
Just do this.
Code:
onPlayerSpawned()
{
    self waittill("spawned_player");
    self takeWeapon("m1911_zm");
    self giveWeapon(<weapon name>);
    self switchToWeapon(<weapon name>);
}
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>);
}
 

candy

G59 Terrorist
Staff member
Donator
Messages
1,299
Points
548
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>);
}
Well you need to actually replace <weapon name> thats just a place holder so you can put the weapon name you want there.
 
Messages
17
Points
8
Well you need to actually replace <weapon name> thats just a place holder so you can put the weapon name you want there.
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:

candy

G59 Terrorist
Staff member
Donator
Messages
1,299
Points
548
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.
Ya I don't think its in that map at all. Its been replaced with the Mauser, like you said.
 
Messages
17
Points
8
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.
Ya I don't think its in that map at all. Its been replaced with the Mauser, like you said.
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:
 

candy

G59 Terrorist
Staff member
Donator
Messages
1,299
Points
548
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:
Code:
self.health = 300;
self.maxhealth = self.health;
 
Messages
17
Points
8
It works fine for me, show me how you're doing it.
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.
 

candy

G59 Terrorist
Staff member
Donator
Messages
1,299
Points
548
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.
Yeah don't run it on 'init' because that runs before player connection & spawning. You have to run it on onPlayerSpawned or after.
 
Messages
17
Points
8
Yeah don't run it on 'init' because that runs before player connection & spawning. You have to run it on onPlayerSpawned or after.
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:
 
Messages
17
Points
8
@Victor Koulikov If there related similarly to this thread, BO2 gsc, then post them here instead.
Call of Duty: Black Ops 2 Scripts Questions | CabConModding
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:
 

candy

G59 Terrorist
Staff member
Donator
Messages
1,299
Points
548
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:
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:
Top