Jump to content

Neviothr

Making the player not take damage while in a vehicle?

Recommended Posts

I'm trying to make so the player doesn't take damage while in vehicles, for some reason it doesn't work.

This is how my script looks:

while {true} do {	if ((vehicle player == MGG) or (vehicle player == HAT1) or (vehicle player == HAT2) or (vehicle player == HAT3) or (vehicle player == M1131) or (vehicle player == M1132)) then {		player allowDamage false;		hint "You no longer take damage";	};	else {		player allowDamage true;		hint "You now take damage";	};	sleep 10;};

What am I doing wrong?

Share this post


Link to post
Share on other sites


while {true} do {

waitUntil {((vehicle player == MGG) || (vehicle player == HAT1) || (vehicle player == HAT2) || (vehicle player == HAT3) || (vehicle player == M1131) || (vehicle player == M1132)};

player allowDamage false;

hint "You can not take damage";

waitUntil {((vehicle player != MGG) || (vehicle player != HAT1) || (vehicle player != HAT2) || (vehicle player != HAT3) || (vehicle player != M1131) || (vehicle player != M1132)};

player allowDamage true;

hint "You can now take damage";

};

  • Like 1

Share this post


Link to post
Share on other sites

The above is missing a ) at the end of the waituntil condition check

!= M1132)};

 

should be != M1132))};

 

another way to do it

while {true} do {
    waitUntil {vehicle player in [MGG,HAT1,HAT2,HAT3,M1131]};
    player allowDamage false;
    hint "You can not take damage";
    
    waitUntil {vehicle player == player};
    player allowDamage true;
    hint "You can now take damage";
    };
  • Like 2

Share this post


Link to post
Share on other sites

Remember that simply not allowing damage to the player doesn't mean the player wont die if the vehicle is disabled. If you wanted to make the player stay alive when the vehicle explodes, simply make an eventhandler for the vehicle that dumps players out of the vehicle over a certain amount of damage (_damage >= 0.91)

  • Like 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×