Jump to content
pliskin124

Detecting when engine is on to run a script.

Recommended Posts

So far, at the end of my script I have
 

	if (is Engineon Truck1) then {	
	null = execVM "Detonation5.sqf";
		};

but it doesn't execute set off the explosive.

 

What I want to do is as soon as the unit turns on the car, the vehicle explodes. Any help would be most appreciated.

Share this post


Link to post
Share on other sites
Truck1 addEventHandler
[
	"Engine",
	{
		if (_this select 1) then
		{
			null = [(_this select 0)] execVM "Detonation5.sqf";
		};
	}
];

Tried the script, as well as two modifications and it still did not work.

 

Modification 1

	removeAllActions FuelT;
		[] Spawn {

		titleText ["You wire the explosive into the vehicle ignition.","PLAIN"];

	titleFadeOut 2;

	sleep 2;
	
	titleText ["What could possibly go wrong?","PLAIN"];

	titleFadeOut 12;

	sleep 2;

	deletevehicle this;

Truck addEventHandler
[
	"Engine",
	{
		if (FuelT select 1) then
		{
			null = [(FuelT select 0)] execVM "Detonation5.sqf";
		};
	}
];

Modification 2:

FuelT addEventHandler
[
	"Engine",
	{
		if (_this select 1) then
		{
			null = [(_this select 0)] execVM "Detonation5.sqf";
		};
	}
];

Share this post


Link to post
Share on other sites

So far, at the end of my script I have

 

	if (is Engineon Truck1) then {	
	null = execVM "Detonation5.sqf";
		};

but it doesn't execute set off the explosive.

 

What I want to do is as soon as the unit turns on the car, the vehicle explodes. Any help would be most appreciated.

if (isEngineOn Truck1) then {null = execVM "detonation5.sqf";};

You didn't have is connected with EngineOn, just to let you know. ;)

Share this post


Link to post
Share on other sites
if (isEngineOn Truck1) then {null = execVM "detonation5.sqf";};

You didn't have is connected with EngineOn, just to let you know. ;)

 

Still doesn't work. ;)

Share this post


Link to post
Share on other sites

I suggest you build in levels of debug so you can see if your state is met e.g with

 

hint "Boom"; 

Share this post


Link to post
Share on other sites

so i'm assuming you have a waitUntil before all of that (i would recommend it as it wouldn't activate as when it would go through it would pass it)
and then yea just use isEngineOn to return.

 waitUntil {isEngineOn Truck1};
null = [truck1] execVM "Detonation5.sqf"; 
hint "boom";

Share this post


Link to post
Share on other sites

 If using waitUntil, you should put a sleep in it.

waitUntil {sleep 0.1; isEngineOn Truck1};

null = [truck1] execVM "Detonation5.sqf"; 

hint "boom";

Share this post


Link to post
Share on other sites

If I'm not mistaken, isEngineOn and engineOn works only with local objects.

Share this post


Link to post
Share on other sites

 

while{alive Truck1} do
{
    if (isEngineOn Truck1) then
    {    
        Truck1 setDamage 1;
    };
    sleep 1;
};

 

What about something like this? No need to overengineer things.

Share this post


Link to post
Share on other sites

 

while{alive Truck1} do
{
    if (isEngineOn Truck1) then
    {    
        Truck1 setDamage 1;
    };
    sleep 1;
};

 

What about something like this? No need to overengineer things.

Because the player has set an explosive on the truck and it needs to kill multiple units in a wide area.

Share this post


Link to post
Share on other sites

You didn't say that in your first post, did you?

 

You can still replace

 

Truck1 setDamage 1;

 

with the execution of your script.

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

×