Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×
Sign in to follow this  
splatsh

setTriggerStatements problem

Recommended Posts

This works

In trigger activation:

nul=[] execVM "test.sqf"

// test.sqf

_this setTriggerStatements ["C1 distance player<= 400;", "[C1,""HMMWV_Armored""] call BIS_fnc_supplyDrop;", ""];

But this wont work. Why?

How can I make this to work right?

nul=[HMMWV_Armored] execVM "test.sqf"

// test.sqf

_type = _this select 0;


_this setTriggerStatements ["C1 distance player<= 400;", "[C1,""_type""] call BIS_fnc_supplyDrop;", ""];

I have try this to

[C1,"_type"]

and

[C1,_type]

But I cant get it to work.

Share this post


Link to post
Share on other sites

You have to pass the classname as a string:

nul=["HMMWV_Armored"] execVM "test.sqf"

---------- Post added at 11:19 AM ---------- Previous post was at 11:18 AM ----------

[C1,""_type""]

Should be:

[C1,_type]

Share this post


Link to post
Share on other sites
You have to pass the classname as a string:

nul=["HMMWV_Armored"] execVM "test.sqf"

---------- Post added at 11:19 AM ---------- Previous post was at 11:18 AM ----------

Should be:

[C1,_type]

Sorry, still not working

_this = createTrigger ["EmptyDetector", [0,0,0]];
_this setTriggerArea [0, 0, 0, true];
_this setTriggerActivation ["NONE", "PRESENT", false];
_this setTriggerStatements ["C1 distance player<= 400;", "[C1,_type] call BIS_fnc_supplyDrop;", ""];
_trigger_0 = _this;

hint format ["%1",triggerStatements _trigger_0];

My hint is saying [C1, _type] when I use that.

when I use

_this setTriggerStatements ["C1 distance player<= 400;", "[C1, ""HMMWV_Armored""] call BIS_fnc_supplyDrop;", ""];

My hint is telling me the right stuff:

[C1, HMMWV_Armored]

So, I still got something wrong.

Share this post


Link to post
Share on other sites

My mistake.

_this setTriggerStatements ["C1 distance player<= 400;", "[C1,_type] call BIS_fnc_supplyDrop;", ""];

This will not work because of variable scope. The variable _type is local only to the script, and thus cannot be used in the trigger statement. You could try this:

this setTriggerStatements ["C1 distance player<= 400;", format ["[C1,%1] call BIS_fnc_supplyDrop;",_type], ""];

Share this post


Link to post
Share on other sites
My mistake.

This will not work because of variable scope. The variable _type is local only to the script, and thus cannot be used in the trigger statement. You could try this:

this setTriggerStatements ["C1 distance player<= 400;", format ["[C1,%1] call BIS_fnc_supplyDrop;",_type], ""];

Thanks, I will try that later.

One more question

This works

_wpt1 setWaypointStatements ["true",  "[medic] join player"];

with this

_unit = _group_2 createUnit [_spawntype, _spawnPoint, [], 3, "FORM"];
_unit setVehicleVarName "medic";
medic = _unit;

Why is this not working and how to get it to work

_wpt1 setWaypointStatements ["true",  "[_unit] join player"];

If I can get this to work, I dont need to name my units that I am spawning, it really should help me out if I could get them to join me without names.

and I cant get deleteVehicle to work

_wpt2 = _group_1 addWaypoint[_spawnPoint,50];
_wpt2 setwaypointtype "MOVE";
_wpt2 setWaypointStatements ["true", "deleteVehicle _vehicle_1"];

My chopper is moving to that _spawnPoint, but they dont delete it.

How can I delete stuff when they have arrived to a move point?

Edited by splatsh

Share this post


Link to post
Share on other sites
Why is this not working and how to get it to work

_wpt1 setWaypointStatements ["true",  "[_unit] join player"];

This does not work for the same reason. You can't use local variables that you define in your script when setting waypoint statements. Basically, whenever you write code that is going to be executed on a different scope, you can't pass it variables local to the current scope.

Since this time it's a unit however and not a string, the solution is somewhat different:

_varName = vehicleVarName _unit;
_wpt1 setWaypointStatements ["true",format ["[%1] join player",_varName]];

It still requires _unit to have a name (vehicleVarName) though (you just don't have to know it).

Share this post


Link to post
Share on other sites
Sign in to follow this  

×