//<--Locator DataBlocks-->\\
datablock MissionMarkerData(PlayerMarker)
{
   catagory = "Misc";
   shapeFile = "octahedron.dts";
};

//<--Locator Scripts-->\\
function LocateLoop()
{

if (CommandTargetSet.getobject(5) == -1)
return;
if (!$LC)
return;

for (%i=0;%i<CommandTargetSet.getcount();%i++)
{
%obj = CommandTargetSet.getobject(%i);
if (%obj.getclassname() $="Player")
{
Tag(%obj);
}
}
schedule(10,0,"LocateLoop");
}

function Tag(%obj)
{
if (CommandTargetSet.getobject(5) == -1)
return;
if (%obj.getstate() $="Dead")
return;
if (CheckGuid(%obj))
return;
%wp = new waypoint()
{
position = vectoradd(%obj.getposition(),"0 0 1.5");
team = 0;
name = "";
Datablock = PlayerMarker;
};
if ($Mode == 0)
{
for (%i=0;%i<PlayerListGroup.getcount();%i++)
{
%cl = PlayerListGroup.getobject(%i);
if (%cl.targetid == %obj.gettarget())
{
%wp.name = %cl.name;
if (%cl.name $="\x10\c6\x11")
%wp.name = "No Name";
%wp.team = %cl.teamid;
WaypointSet.add(%wp);
schedule(10,0,"Delete",%wp);
return;
}
}
}
else
{
for (%i=0;%i<PlayerListGroup.getcount();%i++)
{
%cl = PlayerListGroup.getobject(%i);
if (%cl.targetid == %obj.gettarget())
{
%wp.name = %cl.guid;
if (%cl.guid $="")
%wp.name = %cl.name SPC "(B)";
%wp.team = %cl.teamid;
WaypointSet.add(%wp);
schedule(10,0,"Delete",%wp);
return;
}
}
}
}

function CheckGUID(%obj)
{
for (%i=0;%i<PlayerListGroup.getcount();%i++)
{
%cl = PlayerListGroup.getobject(%i);
if (%cl.targetid == %obj.gettarget())
{
if (%cl.guid == $GUID)
return true;
}
}
return false;
}

function Delete(%obj)
{
%obj.delete();
}

function ToggleLocator(%val)
{
if (CommandTargetSet.getobject(5) == -1){
addmessagehudline("Error: Tribes 2 was enable to start the locator. You need a hacked exe.");
return;
}
if (%val)
if ($LC)
{
$LC = false;
addmessagehudline("Locator disabled.");
return;
}
else
{
$LC = true;
addmessagehudline("Locator enabled.");
LocateLoop();
}
}

function ToggleLocatorMode(%val)
{
if (CommandTargetSet.getobject(5) == -1){
addmessagehudline("Error: Tribes 2 was enable to start the locator. You need a hacked exe.");
return;
}
if (%val)
if ($Mode)
{
$Mode = 0;
addmessagehudline("Locator Mode Set To: Client Names");
return;
}
else
{
$Mode = 1;
addmessagehudline("Locator Mode Set To: Client GUID's");
}
}

package LC{
function OptionsDlg::onWake(%this)
{
if (!$LCB)
{
//Phantom
$RemapName[$RemapCount] = "Toggle Locator";
$RemapCmd[$RemapCount] = "ToggleLocator";
$RemapCount++;

$RemapName[$RemapCount] = "Cycle Modes";
$RemapCmd[$RemapCount] = "ToggleLocatorMode";
$RemapCount++;

$LCB = true;
}
parent::onwake(%this);
}
};
activatepackage(LC);

//<--Locator Variables-->\\
$GUID = 1084380;
$Mode = 0;
$LC = false;
