Jump to content
Sign in to follow this  
logitrust

marker on map, script respawn. Q!

Recommended Posts

Hi guys! Working on our clan's new public mission/server to ArmA2/A.O. Right now im working on a ''marker script'' so the vehicles/air/m.h.q etc. can be shown/tracked on map. All that works fine on the global side.

createMarker["marker01",[0,0,0]];

"marker01" setMarkerShape "ICON";

"marker01" setMarkerType "AIR";

"marker01" setMarkerText "";

"marker01" setMarkerColor "ColorYellow";

while {alive osprey_alpha} do

{

"marker01" setMarkerPos getpos osprey_alpha;

sleep 2;

};

deletemarker "marker01";

And now my little ''nut'':

The problem is that i dont know how to get the script ''smarter'' so

that the marker will follow the vehicles/air/m.h.q etc. when using Tophe's Simple Vehicle Respawn Script v1.7. (The script works fine). Seen around on BIS, but have not found any similar problem, with solution. When created the createMarker i used the http://community.bistudio.com/wiki/createMarker

In other words, The marker must follow the vehicle back when it has been destroyed or, stranded in time.

Tell me if something is explained to difficult.

Hoping for an answer - maybe its not so difficult as i think hehe.

Thank you in advance for feedback.

---------- Post added at 12:33 PM ---------- Previous post was at 11:47 AM ----------

Tried to take away deletemarker "marker01"; with out succses to see if the marker returns with the vehicles/air/m.h.q to the respawn-basically, but was only left where the device was destroyed.

Edited by Logitrust

Share this post


Link to post
Share on other sites

maybe i need another script to call back the marker to the unit after its respawnd? Can i maybe use _KilledHandler

----

neh, no luck.

Edited by Logitrust

Share this post


Link to post
Share on other sites

Hi Logitrust. I will try to help you if I can.

I have added a few lines to your code. Create a script called "do_marker.sqf" or something similar. Put it in your mission folder.

"do_marker.sqf"

private ["_plane"];

_plane = _this select 0;

createMarker["marker01",getPos _plane];
"marker01" setMarkerShape "ICON";
"marker01" setMarkerType "AIR";
"marker01" setMarkerText "";
"marker01" setMarkerColor "ColorYellow";

while {alive _plane} do {
    "marker01" setMarkerPos getpos _plane;
    sleep 2;
};

deletemarker "marker01";

...and Tophe's script. This is the one I found "SimpleVehicleRespawn_v1.7.7

Just add the lines in red.

"vehicle.sqf"

/*
=========================================================
 Simple Vehicle Respawn Script v1.7
 by Tophe of Östgöta Ops [OOPS]

 Put this in the vehicles init line:
 veh = [this] execVM "vehicle.sqf"


 Options:
 There are some optional settings. The format for these are:
 veh = [this, Delay, Deserted timer, Respawns, Effect, Static] execVM "vehicle.sqf"


 Default respawn delay is 30 seconds, to set a custom
 respawn delay time, put that in the init as well.
 Like this:
 veh = [this, 15] execVM "vehicle.sqf"

 Default respawn time when vehicle is deserted, but not
 destroyed is 120 seconds. To set a custom timer for this
 first put the respawn delay, then the deserted vehicle timer. (0 = disabled)
 Like this:
 veh = [this, 15, 10] execVM "vehicle.sqf"

 By default the number of respawns is infinite. To set a limit
 First set the other values then the number of respawns you want (0 = infinite).
 Like this:
 veh = [this, 15, 10, 5] execVM "vehicle.sqf"


 Set this value to TRUE to add a special explosion effect to the wreck when respawning.
 Default value is FALSE, which will simply have the wreck disappear.
 Like this:
 veh = [this, 15, 10, 5, TRUE] execVM "vehicle.sqf"

 By default the vehicle will respawn to the point where it first
 was when the mission started (static). This can be changed to
 dynamic. Then the vehicle will respawn to the position where it was destroyed.
 First set all the other values then set TRUE for dynamic or FALSE for static.
 Like this:
 veh = [this, 15, 10, 5, TRUE, TRUE] execVM "vehicle.sqf"

 If you you want to set the INIT field of the respawned vehicle, first set all other
 values, then set init commands. Those must be inside quotations.
 Like this:
 veh = [this, 15, 10, 5, TRUE, FALSE, "this setDammage 0.5"] execVM "vehicle.sqf"

 Default values of all settings are:
 veh = [this, 30, 120, 0, FALSE, FALSE] execVM "vehicle.sqf"




Contact & Bugreport: harlechin@hotmail.com

=========================================================
*/

if (!isServer) exitWith {};

// Define variables
_unit = _this select 0;
_delay = if (count _this > 1) then {_this select 1} else {30};
_deserted = if (count _this > 2) then {_this select 2} else {120};
_respawns = if (count _this > 3) then {_this select 3} else {0};
_explode = if (count _this > 4) then {_this select 4} else {false};
_dynamic = if (count _this > 5) then {_this select 5} else {false};
_unitinit = if (count _this > 6) then {_this select 6} else {};
_haveinit = if (count _this > 6) then {true} else {false};

_hasname = false;
_unitname = vehicleVarName _unit;
if (isNil _unitname) then {_hasname = false;} else {_hasname = true;};
_noend = true;
_run = true;
_rounds = 0;

if (_delay < 0) then {_delay = 0};
if (_deserted < 0) then {_deserted = 0};
if (_respawns <= 0) then {_respawns= 0; _noend = true;};
if (_respawns > 0) then {_noend = false};

_dir = getDir _unit;
_position = getPosASL _unit;
_type = typeOf _unit;
_dead = false;
_nodelay = false;

[color="Red"]nul = [_unit] execVM "do_marker.sqf";[/color]

// Start monitoring the vehicle
while {_run} do
{
sleep (2 + random 10);
     if ((getDammage _unit > 0.8) and ({alive _x} count crew _unit == 0)) then {_dead = true};

// Check if the vehicle is deserted.
if (_deserted > 0) then
{
	if ((getPosASL _unit distance _position > 10) and ({alive _x} count crew _unit == 0) and (getDammage _unit < 0.8)) then
	{
		_timeout = time + _deserted;
		sleep 0.1;
	 	waitUntil {_timeout < time or !alive _unit or {alive _x} count crew _unit > 0};
		if ({alive _x} count crew _unit > 0) then {_dead = false};
		if ({alive _x} count crew _unit == 0) then {_dead = true; _nodelay =true};
		if !(alive _unit) then {_dead = true; _nodelay = false};
	};
};

// Respawn vehicle
     if (_dead) then
{
	if (_nodelay) then {sleep 0.1; _nodelay = false;} else {sleep _delay;};
	if (_dynamic) then {_position = getPosASL _unit; _dir = getDir _unit;};
	if (_explode) then {_effect = "M_TOW_AT" createVehicle getPosASL _unit; _effect setPosASL getPosASL _unit;};
	sleep 0.1;

	deleteVehicle _unit;
	sleep 2;
	_unit = _type createVehicle _position;
	_unit setPosASL _position;
	_unit setDir _dir;

	if (_haveinit) then
				{_unit setVehicleInit format ["%1;", _unitinit];
				processInitCommands;};
	if (_hasname) then
				{_unit setVehicleInit format ["%1 = this; this setVehicleVarName ""%1""",_unitname];
				processInitCommands;};
	_dead = false;

	// Check respawn amount
	if !(_noend) then {_rounds = _rounds + 1};
	if ((_rounds == _respawns) and !(_noend)) then {_run = false;};
};
[color="Red"]nul = [_unit] execVM "do_marker.sqf";[/color]
};

This will always create an "AIR" marker....but this can be used on any vehicle.....so there's more that can be done to display the correct marker. Fiddle with it and see what you can do. This is the way to learn. If you get into trouble...just post again. Glad to help.

There are other ways to do this....but this is the path I wandered down today! :)

Kudos to Tophe. Great respawn script!

Edited by twirly

Share this post


Link to post
Share on other sites

tnx twirly :) Im now using 20 markers, and it works very well with your solution!

Share this post


Link to post
Share on other sites

have encountered a problem here. I run the DAC mod in my mission, and a few other script mods like acre, etc. These will not start when I run all my markers. With other words, the mission seams laggy.

Copy of my init.sqf there you can see all my markers.:

execVM "briefing.sqf";

execVM "markerpos\markers01.sqf";

execVM "markerpos\markers02.sqf";

execVM "markerpos\markers03.sqf";

execVM "markerpos\markers04.sqf";

execVM "markerpos\markers05.sqf";

execVM "markerpos\markers06.sqf";

execVM "markerpos\markers07.sqf";

execVM "markerpos\markers08.sqf";

execVM "markerpos\markers09.sqf";

execVM "markerpos\markers10.sqf";

execVM "markerpos\markers11.sqf";

execVM "markerpos\markers12.sqf";

execVM "markerpos\markers13.sqf";

execVM "markerpos\markers14.sqf";

execVM "markerpos\markers15.sqf";

execVM "markerpos\markers16.sqf";

execVM "markerpos\markers17.sqf";

execVM "markerpos\markers18.sqf";

execVM "markerpos\markers19.sqf";

execVM "markerpos\markers20.sqf";

execVM "markerpos\markers21.sqf";

execVM "markerpos\markers22.sqf";

execVM "markerpos\markers23.sqf";

execVM "markerpos\markers24.sqf";

execVM "markerpos\markers25.sqf";

execVM "markerpos\markers26.sqf";

execVM "markerpos\markers27.sqf";

execVM "markerpos\markers28.sqf";

execVM "markerpos\markers29.sqf";

execVM "markerpos\markers30.sqf";

execVM "markerpos\markers31.sqf";

execVM "markerpos\markers32.sqf";

execVM "markerpos\markers33.sqf";

execVM "markerpos\markers34.sqf";

execVM "markerpos\markers35.sqf";

execVM "markerpos\markers36.sqf";

execVM "markerpos\markers37.sqf";

execVM "markerpos\markers38.sqf";

execVM "markerpos\markers39.sqf";

execVM "markerpos\markers40.sqf";

execVM "markerpos\markers41.sqf";

execVM "markerpos\markers42.sqf";

execVM "markerpos\markers43.sqf";

execVM "markerpos\markers44.sqf";

execVM "markerpos\markers45.sqf";

execVM "markerpos\markers46.sqf";

execVM "markerpos\markers47.sqf";

execVM "markerpos\markers48.sqf";

execVM "markerpos\markers49.sqf";

execVM "markerpos\markers50.sqf";

execVM "markerpos\markers51.sqf";

execVM "markerpos\markers52.sqf";

execVM "markerpos\markers53.sqf";

execVM "markerpos\markers54.sqf";

execVM "markerpos\markers55.sqf";

execVM "markerpos\markers56.sqf";

execVM "markerpos\markers57.sqf";

execVM "markerpos\markers58.sqf";

execVM "markerpos\markers59.sqf";

execVM "markerpos\markers60.sqf";

execVM "markerpos\markers61.sqf";

execVM "markerpos\markers62.sqf";

execVM "markerpos\markers63.sqf";

execVM "markerpos\markers64.sqf";

execVM "markerpos\markers65.sqf";

execVM "markerpos\markers66.sqf";

execVM "markerpos\markers67.sqf";

execVM "markerpos\markers68.sqf";

execVM "markerpos\markers69.sqf";

execVM "markerpos\markers70.sqf";

execVM "markerpos\markers71.sqf";

execVM "markerpos\markers72.sqf";

execVM "markerpos\markers73.sqf";

execVM "markerpos\markers74.sqf";

_KilledHandler = player addEventHandler ["killed", {_this execVM "playerkilled.sqf"}];

skiptime (((paramsarray select 0) - daytime + 24) % 24);

switch (paramsarray select 1) do {

case 1: { 0 setOvercast 0; 0 setRain 0; 0 setFog 0 };

case 2: { 0 setOvercast 1; 0 setRain 1; 0 setFog 0.2 };

case 3: { 0 setOvercast 0.7; 0 setRain 0; 0 setFog 0 };

case 4: { 0 setOvercast 0.7; 0 setRain 1; 0 setFog 0.7 };

};

if (isServer) then {

ace_sys_tracking_markers_enabled = false;

publicVariable "ace_sys_tracking_markers_enabled"

};

Found the root of the problem, and it is all the execVM "markerpos\markersXX.sqf"; in the init file who fuck things up. When I delete some , to lets say i got 10 markers left, DAC and acre start to work when i start running the mission. I wonder if its another way to do this. realy need to have veeled,wings,mhq01,mhq02 and other things marked on the mission map to get this finish'd.

Thanks in advance for feedback.

---------- Post added at 02:39 PM ---------- Previous post was at 02:35 PM ----------

each markersXX looks like this:

createMarker["markerXX",[0,0,0]];

"marker01" setMarkerShape "";

"marker01" setMarkerType "";

"marker01" setMarkerText "";

"marker01" setMarkerColor "";

while {alive XXX} do

{

"marker01" setMarkerPos getpos XXX;

sleep 2;

};

deletemarker "markerXX";

Will it work better if i make one execVM "markerpos\markers.sqf"; to the init.sqf and throw all the markers in one markers.sqf file maybe? have tryd out some things there, but cant get it to work. Any idea folks? :-)

Alex

Edited by Logitrust

Share this post


Link to post
Share on other sites
Anything you repeat 74 times should be turned into a function. :)

il google that, any idea how to start doing that? sry, im neewbe on scripting in arma.

Share this post


Link to post
Share on other sites

Post what execVM "markerpos\markers74.sqf"; contains and we'll see how we can turn it into a function, so you have one function you call 74 times instead of calling 74 different scripts.

Share this post


Link to post
Share on other sites

okei! :) but remember that the reason I have 74 different markers is

Because I have 74 different things. that is, different nato-symbols with different colors, etc. planes, tanks, cars, goals, etc.

this is my markers74.sqf

createMarker["marker74",[0,0,0]];

"marker74" setMarkerShape "ICON";

"marker74" setMarkerType "Man";

"marker74" setMarkerText "Papa-01";

"marker74" setMarkerColor "Colororange";

while {alive papa_01} do

{

"marker74" setMarkerPos getpos papa_01;

sleep 2;

};

deletemarker "marker74";

---------- Post added at 03:14 PM ---------- Previous post was at 03:13 PM ----------

so an overview for eatch marker look like this.

//Markerscript - By Logitrust for Scandinavian Task Force

//S.T.F.(Scantask.net)

//markers01.sqf

:MV-22 Osprey_alpha

//markers02.sqf

:MV-22 Osprey_bravo

//markers03.sqf

:ah6_alpha

//markers04.sqf

:ah6_bravo

//markers05.sqf

:ah64d_alpha

//markers06.sqf

:ah64d_bravo

//markers07.sqf

:ah1z_alpha

//markers08.sqf

:ah1z_bravo

//markers09.sqf

:uh1y_alpha

//markers10.sqf

:uh1y_bravo

//markers11.sqf

:mh6_alpha

etc.etc

and thats just the choppers.

---------- Post added at 04:40 PM ---------- Previous post was at 03:14 PM ----------

but no bad idea to gather them. Since all this choppers i posted over, is all the same. And cars/ will be same, just slice them up. Somone who know how to turn them into functions?

createMarker["marker09",[0,0,0]];
"marker09" setMarkerShape "ICON";
"marker09" setMarkerType "AIR";
"marker09" setMarkerText "";
"marker09" setMarkerColor "ColorYellow";

while {alive uh1y_alpha} do

{

"marker09" setMarkerPos getpos uh1y_alpha;

sleep 2;

};

deletemarker "marker09";

Edited by Logitrust

Share this post


Link to post
Share on other sites

I've adapted twirly's script so it'll work with the respawn script. You'll want to change the colors maybe, not sure what all those markers had in them. :)

do_marker.sqf:

//////////////////////////////////////////////////////////////////
// Function file for Armed Assault
// Created by: Logitrust/twirly - Enchanced by kylania
//////////////////////////////////////////////////////////////////

// Call by:
// _nil = [object] execVM "do_marker.sqf";

private ["_markerType","_unit","_markerName","_markerText","_markerColor"];

// Grab unit object
_unit = _this select 0; // papa_01

// Create marker values
_markerName = "marker" + str(_unit); // "markerpapa_01"
_markerText = toUpper vehicleVarName _unit; // "PAPA_O1"
_markerType = ""; // "Man"
_markerColor = ""; // "ColorOrange"

// Assign marker type and color
if (_unit isKindOf "Man") then {_markerType = "Man"; _markerColor = "ColorOrange"};
if (_unit isKindOf "Tank") then {_markerType = "Tank"; _markerColor = "ColorRed"};
if (_unit isKindOf "Air") then {_markerType = "Air"; _markerColor = "ColorYellow"};
if (_unit isKindOf "Car") then {_markerType = "Car"; _markerColor = "ColorBlue"};

// If non matching item, give defaults
if (_markerType == "") then {_markerType = "Dot"};
if (_markerColor == "") then {_markerColor = "ColorBlack"};

// Create the marker
createMarker[_markerName,[1,1,1]];
_markerName setMarkerShape "ICON";
_markerName setMarkerType _markerType;
_markerName setMarkerText _markerText;
_markerName setMarkerColor _markerColor;

// Maintain marker.
while {alive _unit} do
{
_markerName setMarkerPos getPos _unit;
sleep 2;
};

// Clean up.
deleteMarker _markerName; 

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  

×