Jump to content
Sign in to follow this  
1para{god-father}

Help on Script to delete Marker

Recommended Posts

Having an little issue deleting a marker, I get the hint fine but the marker remains, can i not use _markerpad in a trigger ?

_vehicleambush=_this select 1;
_base = _this select 0;	
_pads = [hpad1,hpad2,hpad3,hpad4,hpad5,hpad6,hpad7,hpad8,hpad9,hpad10];
_dest = _pads select (floor (random count _pads));
[_base,_dest,55] execvm "shk_moveobjects.sqf";

///////////////////make marker///////////////////////
_markerpad = FORMAT ["marker_%1",(_dest)];
_mrkscud1 = createmarker [_markerpad,getpos _vehicleambush];
_mrkscud1 setmarkershape "ELLIPSE";
_mrkscud1 setmarkersize [200,200];
_mrkscud1 setMarkerColor "ColorRed";

_triggeram1 = createTrigger["EmptyDetector",[getPos _vehicleambush select 0,getPos _vehicleambush select 1,0]];
_triggeram1 setTriggerArea [230,230,27,false];
_triggeram1 setTriggerActivation ["WEST","NOT PRESENT",true];
_triggeram1 setTriggerTimeout [30,30,30,true];
_triggeram1 setTriggerStatements ["this", "Hint 'Finished'; deleteMarker _markerpad;",""];

Share this post


Link to post
Share on other sites

My guess is you're trying to use _markerpad outside its scope. Underscore makes vars local to their scope. Remove the underscore if you want multiple triggers/scripts to access them.

Share this post


Link to post
Share on other sites

Got it wrong lol

Edited by PELHAM

Share this post


Link to post
Share on other sites

_markerpad is a local variable, not the actual name of the marker, so you wouldn't want quotes, single or double, around it as it's not a string.

I suspect the _markerpad = FORMAT ["marker_%1",(_dest)]; line might be the culprit, might need to specify it as a string, but i'm too hungry to think now. :)

Share this post


Link to post
Share on other sites

Kylania is right:

I'm not sure you are feeding in the %1 part correctly, do you need brackets?

This is how they do it in Insurgency:

_mkr = createMarker[format["%1intel%2", _cache, _i], _pos];

Then you can also use:

getMarkerPos format["%1intel%2", _cache, _i] select 0, etc

To delete it is tricky - you have to define the name

_mkr = format["%1intel%2", _cache, _i];

delete _mkr;

(The above may not be 100% accurate - had to do it from memory as I could not find all of it but hope you are now on the right track.)

If you have created multiple markers you have to call the delete part multiple times. I have a friend who has been very frustrated with all this for a week. Still don't understand it fully myself.

Edited by PELHAM

Share this post


Link to post
Share on other sites

_vehicleambush=_this select 1;
_base = _this select 0;	
_pads = [hpad1,hpad2,hpad3,hpad4,hpad5,hpad6,hpad7,hpad8,hpad9,hpad10];
_dest = _pads select (floor (random count _pads));
[_base,_dest,55] execvm "shk_moveobjects.sqf";

///////////////////make marker///////////////////////
_markerpad = FORMAT ["marker_%1",(_dest)];

_mrkscud1 = createmarker [_markerpad,getpos _vehicleambush];
_mrkscud1 setmarkershape "ELLIPSE";
_mrkscud1 setmarkersize [200,200];
_mrkscud1 setMarkerColor "ColorRed";

Well confused now !

I need to format _markerpad to get the marker name to work and if i put a hint in i get "marker_hpad3" which is what i expected. take the format out then the marker does not work.

So I thought I could use that to delete as well ? It is all in 1 script so it should never be out of scope.

@PELHAM

Thanks Ill have a bash at that then and will see :)

Share this post


Link to post
Share on other sites

_markerpad will return null inside this code:

_triggeram1 setTriggerStatements ["this", "Hint 'Finished'; deleteMarker _markerpad;",""];

ergo, out of scope.

Share this post


Link to post
Share on other sites

markers the bane of my life!!!! lol. Im still trying to rip apart insurgency markers - this is what ive worked out so far without complicating it.

not sure if this is of any use or what you are exactly trying to achieve but...

anyprobs creating the marker -

Possibly change this to

markerpad = FORMAT ["marker%1", _dest];

or markerpad = FORMAT ["%1marker",_dest];

or mrkscud1 = createMarker [format ["%1marker", _dest], getpos _vehicleambush];

As for deleting it -

_markerpad is local to that script - change to markerpad (global)- this will delete the last markerpad marker u make, if its running from another script.

same if you choose the third option, remove the _ from mrkscud1.

Note -

For those making several markers if the script is running over and over again

if you add markerpaddy = markerpad;

when deleting markerpaddy - this will delete the first marker placed. Still trying to figure out the insurgency delete marker issue as mentioned by Pelham.

hope this is of some use.

Edited by Mikie boy
update

Share this post


Link to post
Share on other sites

A scope isn't a script. The main scope is everything within the script outside of any { }'s. When you start adding { }'s you have created a new scope. Example below:

// Script.sqf

Main Scope

{
Scope 1
};

{
Scope 2
_var = 10;
};

{
Scope 3
if ((_var == 10)) then {Scope 4};
};

_var is defined in scope 2. So the if then in scope 3 won't work, unless you define your LOCAL variables private. I ALWAYS do this in the main scope, unless I only want it accessible in a specifc scope of course. At the top of your script add this:

private ["_var1"];

You have now set your local variables private in the main scope and can access that local variable with that value in an scope below it.

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  

×