ItsMods

Full Version: Problem changeing maxhealth
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm trying to change players hp induvidually depending on what team they are on using this code.

PHP Code:
sethp(hp)                                                          
{                                                                  
  
self.maxhealth hp;                                             
  
self.health self.maxhealth;                                    
  
self iPrintLn(self.name+" maxhealth: "+self.maxhealth"hp:"+hp);


It prints the name correctly by different clients so I know it gets run as player but it refuses to change the maxhp. Is there something else that needs to be changed to get it to work?
Huh? this should work fine ... try this.. maybe it doesn't register fast enough

Code:
sethp(hp)                                                          
{                                                                  
    self.maxhealth = hp;                                            
    self.health = self.maxhealth;      
    wait .05;
    self iPrintLn(self.name+" maxhealth: "+self.maxhealth+ "hp:"+hp);
}
Im printing out the maxhp somewhere else all the time and tested it by just shooting people/bots, the maxhealth just wont change.

-----EDIT----

Tried calling the function in onPlayerSpawned()... worked fine.
But calling the function in a for level.players loop doesnt.
Strange thing is the function recognizes the player it is called on since it outputs the player.name correctly.
(07-02-2011, 17:07)iAegle Wrote: [ -> ]Huh? this should work fine ... try this.. maybe it doesn't register fast enough

Code:
sethp(hp)                                                          
{                                                                  
    self.maxhealth = hp;                                            
    self.health = self.maxhealth;      
    wait .05;
    self iPrintLn(self.name+" maxhealth: "+self.maxhealth+ "hp:"+hp);
}

That's not going to matter at all. Maybe you should attempt to loop the iprintln to see if the game sets it back to another value at all.