Jump to content
Luckyas

How to make script work more times?

Recommended Posts

Hello guys.
I am making a script for my scenario that will have a bomb behind your car. When you press the addaction it will detach the bomb and make a trigger area around it. When someone is driving trough the area it will create a large explosion at the bomb. The script works pretty good but only when you use it once. I think this is because the variables are the same. Now is my question: How can I make this script work multiple times.
 
First script:
mine1 = "SLAMDirectionalMine" createVehicle [0,0,0];
mine1 attachto [car1, [0, -3, -1.3]];
car1 addAction ["Drop dah bomb", "expmine1.sqf"];
 
Second script:
detach Mine1;
trgm1 = createTrigger ["EmptyDetector", getPosASLW Mine1];
sleep 0.2;
car1 removeaction 0;
sleep 1;
trgm1 setTriggerArea [8, 8, 0, false];
trgm1 setTriggerActivation ["CIV", "PRESENT", true];
trgm1 setTriggerStatements ["this", "'M_Mo_82mm_AT_LG' createVehicle (getPosASLW Mine1); deleteVehicle Mine1", "'"];
 
Best regards,
Lucas

Share this post


Link to post
Share on other sites

is the second script "expmine1.sqf" ?

Share this post


Link to post
Share on other sites

try changing your variables to local variables like _mine. or if you are using them in other scripts try 

_mine = "SLAMDirectionalMine" createVehicle [0,0,0]; 
car1 setVariable ["mine",_mine];

Not sure if thats what your looking for but it might help.

Share this post


Link to post
Share on other sites

fnc_addMine = { 
 params ["_car"];
 _mine = "SLAMDirectionalMine" createVehicle [0,0,0];
 _mine attachto [_car, [0, -3, -1.3]];
 _car addAction ["Drop dah bomb", {_this spawn fnc_expMine;}, _mine];
};

fnc_expMine = {
 params ["_car", "_driver", "_actionID", "_mine"];
 detach _mine;
 _trigger = createTrigger ["EmptyDetector", getPosASLW _mine];
 sleep 0.2;
 _car removeaction _actionID;
 sleep 1;
 _trigger setTriggerArea [8, 8, 0, false];
 _trigger setTriggerActivation ["CIV", "PRESENT", true];
 _trigger setTriggerStatements ["this", format["'M_Mo_82mm_AT_LG' createVehicle (getPosASLW %1); deleteVehicle %1", _mine], ""];
};

If you add [this] call fnc_addMine; to the vehicle. It should do the rest automatically, didn't test it but should work.

If you use this in the init (of the vehicle), you need to either create 2 separate scripts files, and than execVM them or even better use a cfgFunction with them. 

 

 

EDIT: if you want to re-add the mine/addAction afterwards use the fnc_addMine in the fnc_expMine (somewhere on the bottom), it should rerun the function and add the mine back on with the action.

Share this post


Link to post
Share on other sites

Hello JasperRab.

Thank you so much for trying to help me. The script looks very professional but when I try it out it gives me 2 wierd errors thats I cannot seem to find out why.

I placed the script you made in my mission's init.sqf. Then I call for the fnc_addMine. It then gives me this error: http://imgur.com/B7WF8f5

And when I drive over the mine and the trigger area it gives me this error: http://imgur.com/pvI0pxQ. 

I think the problem is in this line of the code: _trigger setTriggerStatements ["this", format["'M_Mo_82mm_AT_LG' createVehicle (getPosASLW %1); deleteVehicle %1", _mine], ""];

If you could take a look at that I would apriciate that very much.

 

Best regards,

Lucas

Share this post


Link to post
Share on other sites

And also I think I didn't explain good what my problem was. The problem was that when I use the script to lay a bomb down it works, but when I then want to place another one down it moved the trigger area.

But I think your script will totally work once's this error is fixed.

Share this post


Link to post
Share on other sites

Hello JasperRab.

Thank you so much for trying to help me. The script looks very professional but when I try it out it gives me 2 wierd errors thats I cannot seem to find out why.

I placed the script you made in my mission's init.sqf. Then I call for the fnc_addMine. It then gives me this error: http://imgur.com/B7WF8f5

And when I drive over the mine and the trigger area it gives me this error: http://imgur.com/pvI0pxQ. 

I think the problem is in this line of the code: _trigger setTriggerStatements ["this", format["'M_Mo_82mm_AT_LG' createVehicle (getPosASLW %1); deleteVehicle %1", _mine], ""];

If you could take a look at that I would apriciate that very much.

 

Best regards,

Lucas

 

Yes you are right, a better way of doing it then having this line,

_trigger setTriggerStatements ["this", format["'M_Mo_82mm_AT_LG' createVehicle %1; deleteVehicle %2", (getPosASLW _mine), _mine], ""];

For your 2nd error, I cant see the picture, if you could re-upload it.

Share this post


Link to post
Share on other sites

Yes you are right, a better way of doing it then having this line,

_trigger setTriggerStatements ["this", format["'M_Mo_82mm_AT_LG' createVehicle %1; deleteVehicle %2", (getPosASLW _mine), _mine], ""];

For your 2nd error, I cant see the picture, if you could re-upload it.

Hello JasperRab.

I tested your script but it still gives me an error. The first error is 1 sec after I placed the bomb. It sais: http://imgur.com/aTY4zy8. It did create the trigger with all the specifications I think because when I walk into it it creates the bomb. But it then gives me this error  http://imgur.com/7qwQFub. Its not deleting the " _mine" because of the error.

 

Thank you very much for looking into this.

Lucas 

Share this post


Link to post
Share on other sites

First of all,

why create a trigger for that and spawn an explosive on top of that?

Mines will trigger for civilians just fine, no need for that.

You could simply exchange the M6 mine with "APERSBoundingMine_Range_Ammo", then you won't need to trigger the mine manually.

 

Cheers

Share this post


Link to post
Share on other sites

Yea, no real way of doing it that way then, it converts the object to a string, which it cant use afterwards, had an issue like this in the past as well with IEDs, forgot about it.

 

another way of doing it, have a waitUntil under creation of the trigger and waitUntil the trigger is active with triggerActivated.

_trigger setTriggerActivation ["CIV", "PRESENT", true];
_trigger setTriggerStatements ["this", "", ""]; // not needed anymore

waitUntil {triggerActivated _trigger};

"M_Mo_82mm_AT_LG" createVehicle (getPosASLW _mine);
deleteVehicle _mine;

this should surely do it ;)

Share this post


Link to post
Share on other sites

Yea, no real way of doing it that way then, it converts the object to a string, which it cant use afterwards, had an issue like this in the past as well with IEDs, forgot about it.

 

another way of doing it, have a waitUntil under creation of the trigger and waitUntil the trigger is active with triggerActivated.

_trigger setTriggerActivation ["CIV", "PRESENT", true];
_trigger setTriggerStatements ["this", "", ""]; // not needed anymore

waitUntil {triggerActivated _trigger};

"M_Mo_82mm_AT_LG" createVehicle (getPosASLW _mine);
deleteVehicle _mine;

this should surely do it ;)

Thank you very much. Unfortunatly I have to go now but il test it tommorow. 

 

Greetings,

Lucas

Share this post


Link to post
Share on other sites

First of all,

why create a trigger for that and spawn an explosive on top of that?

Mines will trigger for civilians just fine, no need for that.

You could simply exchange the M6 mine with "APERSBoundingMine_Range_Ammo", then you won't need to trigger the mine manually.

 

Cheers

It is actualy for a race im making. And my race track is up the the air and its pretty buggy when it comes to mine detecting. Thats why im doing it like this

. The mine that is attached to the car and is getting dropped is just for the looks.

Share this post


Link to post
Share on other sites

Yea, no real way of doing it that way then, it converts the object to a string, which it cant use afterwards, had an issue like this in the past as well with IEDs, forgot about it.

 

another way of doing it, have a waitUntil under creation of the trigger and waitUntil the trigger is active with triggerActivated.

_trigger setTriggerActivation ["CIV", "PRESENT", true];
_trigger setTriggerStatements ["this", "", ""]; // not needed anymore

waitUntil {triggerActivated _trigger};

"M_Mo_82mm_AT_LG" createVehicle (getPosASLW _mine);
deleteVehicle _mine;

this should surely do it ;)

Tested it out and it works great! Its exactly what I needed. 

Thank you so much.

 

Lucas

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

×