Jump to content
WaIdoZ

Trigger work with Marker

Recommended Posts

I am trying to make a trigger work on a marker but the marker is on a different execVM sqf file, but i am not sure how i can call the sqf that the marker on with a trigger when the player walks in. I know you can do it in editor but i want to learn it in script. the only things i came up with is this.

 

init.sqf file

 

_trg = createTrigger ["EmptyDetector", [5782.864,10333.795]];

_trg setTriggerArea [5, 5, 0, false];

_trg setTriggerActivation ["ANYPLAYER", "PRESENT", true];

_trg setTriggerStatements ["this", execVM "Marker1.sqf'", "'"];

=================

Marker1.sqf file

 

bob = createMarker ["marker1", [5782.864,10333.795]]; bob setMarkerShape "ELLIPSE"; "marker1" setMarkerColor "Colorblack"; "marker1" setMarkerSize [500, 500]; "marker1" setMarkerBrush "SOLID";

Share this post


Link to post
Share on other sites

Check your syntax, you have some weird things going on:

_trg setTriggerStatements ["this", execVM "Marker1.sqf'", "'"];

Elements in an array are separated by commas. I find that arrays are easier to see when they are expanded vertically:

_trg setTriggerStatements 
[
  "this",				// correct
  execVM "Marker1.sqf'",		// nope!
  "'"					// nope!
];

The parameters of setTriggerStatements (exclusive of the leading handle) are an array of strings. So, in this case, each element should be a complete string. And since the .sqf name in an execVM is also a string, it will be a string within a string, for which we use single quotes:

_trg setTriggerStatements 
[
  "this",				// correct
  "execVM 'Marker1.sqf'",		// correct
  ""					// correct
];

 

ALSO

 

While it's not incorrect, you are mixing use of the createMarker handle with the marker name in your "Marker1.sqf." The handle returns the marker name, so it works normally, but it's inconsistent and maybe "non-aesthetic." 

bob = createMarker ["marker1", [5782.864,10333.795]];
"marker1" setMarkerShape "ELLIPSE";
"marker1" setMarkerColor "Colorblack";
"marker1" setMarkerSize [500, 500];
"marker1" setMarkerBrush "SOLID";

// same as

bob = createMarker ["marker1", [5782.864,10333.795]];
bob setMarkerShape "ELLIPSE";
bob setMarkerColor "Colorblack";
bob setMarkerSize [500, 500];
bob setMarkerBrush "SOLID";

Though there is no real reason to use a global, since the marker name itself is global:

private _bob = createMarker ["marker1", [5782.864,10333.795]];
"marker1" setMarkerShape "ELLIPSE";
"marker1" setMarkerColor "Colorblack";
"marker1" setMarkerSize [500, 500];
"marker1" setMarkerBrush "SOLID";

// same as

_bob = createMarker ["marker1", [5782.864,10333.795]];
_bob setMarkerShape "ELLIPSE";
_bob setMarkerColor "Colorblack";
_bob setMarkerSize [500, 500];
_bob setMarkerBrush "SOLID";

As you get deeper into scripting, you might want to decide on consistent styles. It makes things easier to read, and so easier to troubleshoot.

  • Thanks 1

Share this post


Link to post
Share on other sites
16 minutes ago, Harzach said:

Check your syntax, you have some weird things going on:


_trg setTriggerStatements ["this", execVM "Marker1.sqf'", "'"];

Elements in an array are separated by commas. I find that arrays are easier to see when they are expanded vertically:


_trg setTriggerStatements 
[
  "this",				// correct
  execVM "Marker1.sqf'",		// nope!
  "'"					// nope!
];

The parameters of setTriggerStatements (exclusive of the leading handle) are an array of strings. So, in this case, each element should be a complete string. And since the .sqf name in an execVM is also a string, it will be a string within a string, for which we use single quotes:


_trg setTriggerStatements 
[
  "this",				// correct
  "execVM 'Marker1.sqf'",		// correct
  ""					// correct
];

 

Ohhh i didnt know about the ' ' symbols. I am new to the sqf programming. i came from the C# from unity. thank you

Share this post


Link to post
Share on other sites
18 minutes ago, WaIdoZ said:

i came from the C# from unity.

 

Ah, cool. Check the links in my sig - you'll get an overview of the differences, as well as basic-to-comprehensive descriptions/examples of every command/function/etc. Have fun!

  • Thanks 1

Share this post


Link to post
Share on other sites
3 minutes ago, Harzach said:

 

Ah, cool. Check the links in my sig - you'll get a overview of the differences, as well as basic-to-comprehensive descriptions/examples of every command/function/etc. Have fun!

thank you ill take a look right now.

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

×