Jump to content
Sign in to follow this  
Holden93

Script with while loop not working

Recommended Posts

Hello there,

this is the script

while {speedTrouble == true} do
{
if(speed hunter > 50)
{
	jackson sideChat "Ray, I'm breaking radio silence, a bomb got triggered, leave the vehicle, now!";   
	sleep 3;
	bomb = "Bo_GBU12_LGB" createVehicle (getPos hunter);
}
}

Basically if the speed of the hunter is more than 50 I want a bomb to be created and the sidechat to show up, too bad nothing happens.

I tried with both speedTrouble = true and ==, still nothing.

Can you tell me what's wrong with it? Thanks.

Share this post


Link to post
Share on other sites

couple of things.

first off, I'm not sure if while {speedtrouble == true} works, but since speedtrouble is a bolean, it's sufficient to just use while {speedtrouble}.

further, you are missing a then or exitwith after your if-condition. Last but not least, there might be a semicolon missing and it's a good idea to add a minimum of sleep to the loop itself. try this:

while {speedTrouble} do {
if(speed hunter > 50) exitwith {
	jackson sideChat "Ray, I'm breaking radio silence, a bomb got triggered, leave the vehicle, now!";   
	sleep 3;
	bomb = "Bo_GBU12_LGB" createVehicle (getPos hunter);
};
sleep 0.5;
}; 

I assume you want to exit that loop after triggering the bomb, if you would want to keep that loop running you would just replace the exitwith with a then

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
Sign in to follow this  

×