Home   Help Search Login Register  

Author Topic: Scripting a radar w/ Altitude  (Read 1891 times)

0 Members and 1 Guest are viewing this topic.

Offline ryguy

  • Members
  • *
Scripting a radar w/ Altitude
« on: 06 Jul 2010, 21:05:42 »
Hi all,
I'm trying to make a mission where a marker follows a player around like a radar, with the marker text displaying it's altitude in ASL (AGL is ok if it's not possible). The radar would only work within a certain range, as in real life.
Someone gave me advice to use this, but I didn't understand where to put it (In an sqm in the mission file, or in the trigger's init?):
Code: [Select]
"nameofmarker" setMarkerText format ["%1", GetPosASL this select 2] Any help? Thanks!

Offline F2kSel

  • Members
  • *
Re: Scripting a radar w/ Altitude
« Reply #1 on: 06 Jul 2010, 21:45:25 »
You can do either but I'll show you the trigger method.

Place you chopper and name    heli
in the init put    mark=true;


place a marker and name  helimark and select the type of marker


place a trigger / repeating
axis 450,450 would be the size of the radar

anyone present

condition
mark and heli in thislist

on act
"helimark" setMarkerText format ["%1", GetPosASL heli select 2] ;"helimark" setMarkerPos getpos heli; mark=false

on deac
 mark=true;


Using script would be better and you can create the marker within the script.





« Last Edit: 06 Jul 2010, 22:02:46 by F2kSel »

Offline ryguy

  • Members
  • *
Re: Scripting a radar w/ Altitude
« Reply #2 on: 07 Jul 2010, 00:49:28 »
Cool, so how would I do this for multiple aircraft? And would this stay with the aircraft whether or not it was empty?

Offline F2kSel

  • Members
  • *
Re: Scripting a radar w/ Altitude
« Reply #3 on: 07 Jul 2010, 03:03:09 »
Well for multiple aircraft it would be far too complex to do with triggers.

In script it wouldn't be hard but it's a bit beyond my ability.

As for checking if a plane is empty I'm not sure what you mean, you could choose to display aircraft above a certain height and use different colour markers for each side.


Offline ryguy

  • Members
  • *
Re: Scripting a radar w/ Altitude
« Reply #4 on: 07 Jul 2010, 04:13:40 »
OK, how would I do this put in a scripting file?
BTW, what a meant when I said will it work if the planes are empty is, will the marker be on a person, or will it be for the planes.
Thanks a ton for your help... It needs to be created for multiple planes so if anyone else has some input please tell :)

Offline F2kSel

  • Members
  • *
Re: Scripting a radar w/ Altitude
« Reply #5 on: 07 Jul 2010, 23:17:29 »
I decided to push on a little further and did get something working.

If you want to try it go to the editor and place a player on an empty map.
Place the radar tower and name it radar and put this in the init
Code: [Select]
nul = [] execvm "Radar.sqf"Then save the file.


Now just copy and past the code ARMEDIT or notepad and save as an Radar.SQF into the file you just save.

Place some aircaraft and see if it works.




Code: [Select]
// nul = [] execvm "Radar.sqf"

while {alive Tower} do
{
_myarray = nearestObjects [(getpos Tower), ["air"], 1000];
{
_marker  =  createMarker [str _x, GetPosASL _x];
_marker setMarkerType "Dot";

switch (side _x) do
{
case WEST:
{
_marker setMarkerColor "ColorBlue";
};

case EAST:

      _marker setMarkerColor "ColorRed";
};

case CIVILIAN:
{
_marker setMarkerColor "ColorYellow";
if (!alive _x) then {
_marker setMarkerColor "ColorOrange";
};
};
};
_marker setMarkerText format ["%1", floor (GetPosATL _x select 2)] ;
_marker setMarkerPos getpos _x;
} foreach _myarray;
sleep 0.3;
{
deletemarker (str _x);
} foreach _myarray;
 };


You don't have to use the radar tower a game logic would do.

OPFOR   are RED
BLUFOR  are BLUE
CIV's      are Yellow
Crashed aircraft are Orange.

I've kept it quite simple, I'm sure it's been done many times before and to a much higher standard but for me it's just an exercise in coding.

Offline ryguy

  • Members
  • *
Re: Scripting a radar w/ Altitude
« Reply #6 on: 08 Jul 2010, 05:36:08 »
Genius! Thank you dude!   :clap:  :good:
I can send you the mission file when I'm done with it... It should be quite interesting (I'm a total noob to scripting...)

Offline F2kSel

  • Members
  • *
Re: Scripting a radar w/ Altitude
« Reply #7 on: 08 Jul 2010, 11:10:29 »
Sure I'll take a look, I don't bother with missions much myself as I  prefer playing about in the editor trying to solve problems.

if you change the nearestobjects line it can track all objects land,sea and air


Code: [Select]
_myarray = nearestObjects [(getpos Tower), ["man","air","land","boat"], 1000];

Useful for when things don't turn up.

 
« Last Edit: 08 Jul 2010, 11:23:13 by F2kSel »