(03-24-2013, 03:30 PM)Erik The Born Wrote: I mean this script only allows you to hit the door once. If i try to hit the door more nothing will happen. Get it?
It'd be great if you guys could delete part or all of the text you are quoting. Otherwise you just get huuuge posts for 1 sentence.
This change should enable you to hit it 3 times before breaking it. However I warn you it is entirely untested.
void OnStart()
{
AddEntityCollideCallback("Sledge", "AreaThatIsInTheDoor", "Break_dammit", false, 1);
SetLocalVarInt("TimesDoorHit", 0); // represents the number of times the door has been hit
}
void Break_dammit (string &in asParent, string &in asChild, int alState)
{
int inHit = GetLocalVarInt("TimesDoorHit"); // make the name shorter, easier to use in the if's
// if's to check the number of times you've hit the door, first is 0
if (inHit==0) {
SetPropHealth("DoorToBreak", 40); ///This will crack it
}
else if (inHit==1) {
SetPropHealth("DoorToBreak", 10); ///This will make it very destroyed but still in it's place
}
else if (inHit==2) {
SetPropHealth("DoorToBreak", 0); ///This will destroy it
RemoveEntityCollideCallback("Sledge", "AreaThatIsInTheDoor"); // remove the collide callback area
}
AddLocalVarInt("TimesDoorHit", 1); // each time the door is hit, 1 is added to hit value
CreateParticleSystemAtEntity("", "ps_hit_wood", "AreaThatIsInTheDoor", false); // create particle on each hit
}
Remember that SetPropHealth is not adding damage, it is literally setting the HP of the door to the number specified, so it will never be destroyed unless you set it to 0 at some point.