Answered Please Help With Script?

JayCoder

Veteran
Staff member
Messages
375
Reaction score
148
Points
903
Not Understanding what i'm doing here that is wrong, i have had people help, but problem is still her, trying to set a maxlimit of how much health is allowed to be purchased in zombieland.. here the script
Code:
AddHealth(amount, status)
{
        if (self.health <= 250 || self.health <= 100)
        {
            if (self.money >= level.itemPrice[status]["General"]["Health"])
            {
                self.addingHealth = true;
                wait 0.01;
                self.health += amount;
                self.maxhealth = self.health;
                self.addingHealth = false;
                if (!self.healthMonitor)
                { self thread MonitorHealth(); }
                self.money -= level.itemPrice[status]["General"]["Health"];
                self iPrintln("^1+50 Health ^7Purchased Successfully");
            }
            else
                self SendError("MoreMoney");
        }
        else
            self SendError("MaxHealth");   
}

MonitorHealth()
{
    self endon("disconnect");
    self endon("infected");
    self endon("normalHealth");
    level endon("game_ended");
    
    self.healthMonitor = true;
    for (;;)
    {
        if (!self.addingHealth)
        {
            if (self.health > 100)
                self.maxhealth = self.health;
        }
        if (self.health < 100)
        {
            self.maxhealth = 100;
            self.healthMonitor = false;
            self notify("normalHealth");
        }
        wait 0.01;
    }
}
 

candy

G59 Terrorist
Staff member
Donator
Messages
1,322
Reaction score
752
Points
973
Not Understanding what i'm doing here that is wrong, i have had people help, but problem is still her, trying to set a maxlimit of how much health is allowed to be purchased in zombieland.. here the script
Code:
AddHealth(amount, status)
{
        if (self.health <= 250 || self.health <= 100)
        {
            if (self.money >= level.itemPrice[status]["General"]["Health"])
            {
                self.addingHealth = true;
                wait 0.01;
                self.health += amount;
                self.maxhealth = self.health;
                self.addingHealth = false;
                if (!self.healthMonitor)
                { self thread MonitorHealth(); }
                self.money -= level.itemPrice[status]["General"]["Health"];
                self iPrintln("^1+50 Health ^7Purchased Successfully");
            }
            else
                self SendError("MoreMoney");
        }
        else
            self SendError("MaxHealth");  
}

MonitorHealth()
{
    self endon("disconnect");
    self endon("infected");
    self endon("normalHealth");
    level endon("game_ended");
   
    self.healthMonitor = true;
    for (;;)
    {
        if (!self.addingHealth)
        {
            if (self.health > 100)
                self.maxhealth = self.health;
        }
        if (self.health < 100)
        {
            self.maxhealth = 100;
            self.healthMonitor = false;
            self notify("normalHealth");
        }
        wait 0.01;
    }
}
Why don't you just do
Code:
if (self.health < 250)
Instead of what you were doing before
 

JayCoder

Veteran
Staff member
Messages
375
Reaction score
148
Points
903
Why don't you just do
Code:
if (self.health < 250)
Instead of what you were doing before
iv tried many ways, i could try that but i have it work, but its not working right it sets it to a limit but makes everything else free after u click item
 

JayCoder

Veteran
Staff member
Messages
375
Reaction score
148
Points
903
Well that might have to do with a code somewhere else. Idk, im only 14. So i don't know too much
But if i take the max out of the health its fine.... Just trying to see y it won't work properly
 
Last edited:

JayCoder

Veteran
Staff member
Messages
375
Reaction score
148
Points
903
I only changed that one line in the code, it works fine for me. So its not this code like I said, its something else you've got.
Its really not, when i take it out it works amazingly well for me.
 

candy

G59 Terrorist
Staff member
Donator
Messages
1,322
Reaction score
752
Points
973
Its really not, when i take it out it works amazingly well for me.
Wouldn't make sense for it to work perfect for me then. So I suppose you can figure it out yourself then.
 
Top