Home   Help Search Login Register  

Author Topic: GPS tracker using markers for west  (Read 1248 times)

0 Members and 1 Guest are viewing this topic.

Offline egwal

  • Members
  • *
GPS tracker using markers for west
« on: 22 Aug 2008, 16:52:19 »
Soooooou... Im making a mission...

Ive managed to make an already placed marker to follow a unit with the following script:

Quote
; [solttu,"solttumarker"] exec "unittracker.sqs"

_unit1 = _this select 0
_MarkUnit1 = _this select 1
_updatetime = 1.0
_name1 = name _unit1

#Alive
? ((not alive _unit1) or (isnull _unit1) or ((getdammage _unit1) == 1)) : goto "Killed"
_vehiclepos = getPos _unit1
_vehiclex = _vehiclepos select 0
_vehicley = _vehiclepos select 1
_vehiclez = _vehiclepos select 2

_MarkUnit1 setmarkertype "Dot"
_MarkUnit1 setmarkercolor "ColorGreen"
_MarkUnit1 setmarkertext _name1
_markUnit1 setMarkerSize [0.5, 0.5]
_MarkUnit1 setmarkerpos [_vehiclex, _vehicley, _vehiclez]
~_updatetime

goto "Alive"

#Killed
_vehiclepos = getPos _unit1
_vehiclex = _vehiclepos select 0
_vehicley = _vehiclepos select 1
_vehiclez = _vehiclepos select 2
_MarkUnit1 setmarkertype "Marker"
_MarkUnit1 setmarkertext _name1
_MarkUnit1 setmarkercolor "ColorBlack"
_markUnit1 setMarkerSize [0.5, 0.5]
_MarkUnit1 setmarkerpos [_vehiclex, _vehicley, _vehiclez]

exit

The problem is that I have 14 units in total that all need the same "Dot" following them =) And I dont want to do the same for each one of them. The units are in 3 different squads.
AAAND, this is gonna be an A/D map so will I just be able to set the markers visibility in the init.sqs using side == west, then etc?

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: GPS tracker using markers for west
« Reply #1 on: 22 Aug 2008, 17:15:00 »
You may set them to empty type in your init.sqf

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: GPS tracker using markers for west
« Reply #2 on: 22 Aug 2008, 18:42:22 »
Well, I've got a script here that creates markers and updates them on a -group- of your choosing, if that works? It's very simple since it's just something I made for a specific mission, but it should work. Not sure how it'll work in MP - the markers will all be local, I wager.

Code: [Select]
//trackunits.sqf.
// Simple script that tracks all units of a group on the map, showing their locations with a little marker. Also allows for several different modes: i.e., green for healthy, yellow for wounded, red for heavily wounded/can't walk, black for dead. By Wolfrug @ OFPEC for HWM mission pack. Called: groupName execvm "trackUnits.sqs"

_grp = _this;

//How often does the script update?
_waitTime = 0.5;

//What markers are used for the soldiers?
_sMarkerType = "Select";

//What size are the markers?
_sMarkerSize = [0.4, 0.4];

//Marker color array - 0 = healthy, 1 = wounded, 2 = incapacitated, 3 = dead
_sMarkerColors = ["ColorGreen", "ColorYellow", "ColorRed", "ColorBlack"];

//Show unit numbers next to their markers?
_sShowNumbers = false;

//Create markers for each group member and put them into an array
_AllMarkersAndUnits = [];
{
_mrk = createMarkerLocal [(str(units _grp find _x) + "RUG_TrackUnits"), getpos _x];
_mrk setMarkerTypeLocal _sMarkerType;
_mrk setMarkerSizeLocal _sMarkerSize;
_mrk setMarkerColorLocal (_sMarkerColors select 0);
if (_sShowNumbers) then {_mrk setMarkerTextLocal (str(units _grp find _x))};
_AllMarkersAndUnits = _AllMarkersAndUnits + [_mrk, _x];
} forEach units _grp;

//hint format ["%1", _AllMarkersAndUnits];
// Start looping script
while {{alive _x} count units _grp > 0} do
{
_i = 0;
// Actual updating of markers
while {count _AllMarkersAndUnits > _i} do
{
_curMrk = _AllMarkersAndUnits select _i;
_curUnit = _AllMarkersAndUnits select (_i + 1);
_curMrk setMarkerPosLocal [getpos _curUnit select 0, getpos _curunit select 1];
if (damage _curUnit == 0) then {_curMrk setMarkerColorLocal (_sMarkerColors select 0)};
if (damage _curUnit > 0.3) then {_curMrk setMarkerColorLocal (_sMarkerColors select 1)};
if (damage _curUnit > 0.8 OR !canStand _curUNit) then {_curMrk setMarkerColorLocal (_sMarkerColors select 2)};
if (!alive _curUnit) then {_curMrk setMarkerColorLocal (_sMarkerColors select 3)};
//hint format ["%1, %2, %3", _curMrk, _curUnit, getMarkerColor _curMrk];
_i = _i + 2;
};
sleep _waitTime;
};

Save as trackUnits.sqf and call it whenever you want it. :)

Wolfrug out.
"When 900 years YOU reach, look as good you will not!"

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: GPS tracker using markers for west
« Reply #3 on: 22 Aug 2008, 20:38:33 »
Should work fine in MP up to a point, but it won't pick up respawned or JIP players (JIP players will see everyone, but no-one will see those that join after them). You will also see everyone Also, the number shown, if _sShowNumbers is true, won't necessarily be the person's group ID number, as assigned by ArmA in the command menu, if you have AIDisabled in the mission and not all slots are taken.

Don't take that as a criticism, though, since it was not designed for MP. If the MP is one-life COOP with no JIP, then it will be fine. Might even be "good enough", otherwise.
« Last Edit: 22 Aug 2008, 20:47:58 by Spooner »
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline egwal

  • Members
  • *
Re: GPS tracker using markers for west
« Reply #4 on: 22 Aug 2008, 20:54:29 »
Theres something wrong with the "sleep _waittime;" as arma says theres a "Generic error in expression". I copied it straight from here to notepad so there shouldnt be a problem.

Also arma wont me even insert grp1 execvm "trackUnits.sqf" but grp1 exec "trackunits.sqf" goes through, only with the before mentioned error.

however this seems to be exactly the kind of script I was looking for. Now I just gotta make it work =)

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: GPS tracker using markers for west
« Reply #5 on: 22 Aug 2008, 21:06:12 »
exec runs SQS scripts only. Sleep is an SQF command, so that won't work.

When running with execVM inside the editor, such as inside an object's init line, you need to do this:
Code: [Select]
nil = grp1 execvm "trackUnits.sqf";

Inside a script (SQS or SQF),
Code: [Select]
grp1 execvm "trackUnits.sqf";
is fine.
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)