Answered How do you change starting pistol in zombies?

Victor Koulikov

Veteran
Messages
17
Reaction score
3
Points
558
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;
    }
}
It doesn't work :/ I have tested with and without the other self.health. Without the other self health code, It takes 2 hits to get down on all maps. Is there something I need to put in inti() to make the function active?
 

candy

G59 Terrorist
Staff member
Donator
Messages
1,327
Reaction score
763
Points
973
It doesn't work :/ I have tested with and without the other self.health. Without the other self health code, It takes 2 hits to get down on all maps. Is there something I need to put in inti() to make the function active?
Are you even calling the function?
 

candy

G59 Terrorist
Staff member
Donator
Messages
1,327
Reaction score
763
Points
973
No, I’m not. I don’t know what this is, I apologize, I’m new to scripting. I simply copied the function and put it at the bottom, thinking all I needed was the function.
That's why then.
Call it like this in your ops
620650457527f9d08e8183d4822b3aa9.png
 

Victor Koulikov

Veteran
Messages
17
Reaction score
3
Points
558
That's why then.
Call it like this in your ops
620650457527f9d08e8183d4822b3aa9.png
It works perfect in MotD! But now in every other map I am... invincible. Self health is 300. I stood with a hoard of zombies was swiping at me, and on my screen it seems like I'm taking damage, but that red screen you see when you are one hit away from getting down never appears.

Is there a way to do map specific scripts? I've tried making a folder in "scripts/zm" with what the name of the map should be in code. I tried "tomb", _tomb" and "zm_tomb". Perhaps it's the "maps" folder, I'm going to try testing that now, but I don't know if it will accept scripts like the scripts folder does. I believe I saw somewhere that you can create a "mods" folder, and I can (after some time) figure out how to create a file for the M1911 and it's upgraded version, and add it to the mod and in the script, to be able to use it in Origins.

But I don't know any of this for sure, I wish there was some detailed page on all of the ways you can mod Redacted. I've changed the perk icons to ones that I've spent lots of time tweaking, and I know how to save (most) imagefiles in just the right format and all that, and that you can add scripts through the scripts folder, but I'm not sure if that's it, or if I can do map specific scripts and/or added weapons to a specific map. If you know of a page like that, please link it to me. Or if you know of a simple way to have a different script for each map.
 

candy

G59 Terrorist
Staff member
Donator
Messages
1,327
Reaction score
763
Points
973
It works perfect in MotD! But now in every other map I am... invincible. Self health is 300. I stood with a hoard of zombies was swiping at me, and on my screen it seems like I'm taking damage, but that red screen you see when you are one hit away from getting down never appears.

Is there a way to do map specific scripts? I've tried making a folder in "scripts/zm" with what the name of the map should be in code. I tried "tomb", _tomb" and "zm_tomb". Perhaps it's the "maps" folder, I'm going to try testing that now, but I don't know if it will accept scripts like the scripts folder does. I believe I saw somewhere that you can create a "mods" folder, and I can (after some time) figure out how to create a file for the M1911 and it's upgraded version, and add it to the mod and in the script, to be able to use it in Origins.

But I don't know any of this for sure, I wish there was some detailed page on all of the ways you can mod Redacted. I've changed the perk icons to ones that I've spent lots of time tweaking, and I know how to save (most) imagefiles in just the right format and all that, and that you can add scripts through the scripts folder, but I'm not sure if that's it, or if I can do map specific scripts and/or added weapons to a specific map. If you know of a page like that, please link it to me. Or if you know of a simple way to have a different script for each map.
Yeah I didn't mean rely on the health loop I gave you for all maps, I only did it for MoTD. So yeah afterlife not being defined on any other map is going to have problems.

I also tested myself and seems like transit needs a wait. Setting the health while spawning resets it back to 100 during the spawn in sequence, so I just added a short wait. Here is exactly what I used and it worked fine on Transit and MoTD.
Code:
onPlayerSpawned()
{
    self endon("disconnect");
    level endon("game_ended");
    self waittill("spawned_player");
   
    if( getDvar("mapname") != "zm_prison" )
    {
        wait 2;
        self.health = 300;
        self.maxhealth = self.health;
    }
    else
    {
        self thread healthLoop();
    }
}

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;
    }
}
 

Victor Koulikov

Veteran
Messages
17
Reaction score
3
Points
558
Yeah I didn't mean rely on the health loop I gave you for all maps, I only did it for MoTD. So yeah afterlife not being defined on any other map is going to have problems.

I also tested myself and seems like transit needs a wait. Setting the health while spawning resets it back to 100 during the spawn in sequence, so I just added a short wait. Here is exactly what I used and it worked fine on Transit and MoTD.
Code:
onPlayerSpawned()
{
    self endon("disconnect");
    level endon("game_ended");
    self waittill("spawned_player");
  
    if( getDvar("mapname") != "zm_prison" )
    {
        wait 2;
        self.health = 300;
        self.maxhealth = self.health;
    }
    else
    {
        self thread healthLoop();
    }
}

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;
    }
}
I know I've said this a lot, but truly, thank you. I'm sorry you did so much work because I know next to nothing about scripting, but I'll look into learning it so I can do this kind of stuff myself. But now I have a change I really wanted working on all the maps. I tested TranZit, MotD and Nuketown. First try it took me like 6-7 hits to get down strangely, but this works, thank you so very much! I won't bother you anymore, if I need more scripting help, or I find a way to get the M1911 into Origins, I'll figure out how to code the level.default_laststandpistol line for co op and solo in BO2. Thank you again :smile:
 

candy

G59 Terrorist
Staff member
Donator
Messages
1,327
Reaction score
763
Points
973
I know I've said this a lot, but truly, thank you. I'm sorry you did so much work because I know next to nothing about scripting, but I'll look into learning it so I can do this kind of stuff myself. But now I have a change I really wanted working on all the maps. I tested TranZit, MotD and Nuketown. First try it took me like 6-7 hits to get down strangely, but this works, thank you so very much! I won't bother you anymore, if I need more scripting help, or I find a way to get the M1911 into Origins, I'll figure out how to code the level.default_laststandpistol line for co op and solo in BO2. Thank you again :smile:
Lol no problem. If you need more help just make a new thread. I'll help, I'm not bothered.
 
Top