Home   Help Search Login Register  

Author Topic: Multiple onMapSingleClicks  (Read 1113 times)

0 Members and 1 Guest are viewing this topic.

Offline Meatball0311

  • Members
  • *
Multiple onMapSingleClicks
« on: 30 Nov 2007, 06:13:11 »
I am wanting to make an airstrike script.  What I would like to happen is give the plane three commands via onMapSingleClicks.

1st one the target (clicking once on the map)
2nd the inbound waypoint (by using shift, and click)
3rd the outbound waypoint (by using shift, alt, click)

What commands do I use?

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: Multiple onMapSingleClicks
« Reply #1 on: 30 Nov 2007, 11:25:32 »
The script detects Alt and Shift-clicks by the way of two localized variables, _shift and _alt, that are passed to the script. Does it matter to you if the commands are given in order (i.e., it has to go from position-inbound-outbound) or can you decide which you want to set yourself? In either case, let's say you have a single script for all your actions. It might look something like this. First you tell onMapSingleClick to execute the script:

onMapSingleClick "nil=[_pos, _shift, _alt] execVM ""YourScript.sqf""";

(note the double parenthesises around the script-string)

And then the script itself could look like this:

Code: [Select]
_pos = _this select 0;
_shift= _this select 1;
_alt = _this select 2;

if (!_alt && !_shift) exitWith
{
hint "This is where you'd put in the code for designating target.";
}:

if (_shift) exitWith
{
hint "Code for inbound";
};

if (_alt) exitWith
{
hint "Code for outbound";
};

Spooner tells me the if-then's are faster than switch...do, so I believe him  :D Otherwise that might have been a possible contender as well.

I'm not sure if you can combine shift and alt (i.e., if (_alt && _shift)), but I suppose you can try? Otherwise the above should be enough, methinks.  :)

Good luck!

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

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re: Multiple onMapSingleClicks
« Reply #2 on: 30 Nov 2007, 12:17:13 »
u can detect shift + alt clicks :D

and even if  if then are faster than switch... i dont see this script as a script dat needs somin fast or somin... and it does do 3 difrent checks...

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Offline Meatball0311

  • Members
  • *
Re: Multiple onMapSingleClicks
« Reply #3 on: 01 Dec 2007, 02:17:19 »
Please excuse me, but I am a nOOb when it comes to scripting.  I still cannot create an onMapSingleClick that you have to press shift + click to place marker.  This is what I got so far.

I have a radio Alpha trigger set up to call on my "call4cas.sqs"

I have onMapSingleClick "[_pos] exec "airstrike.sqs"

airstrike.sqs

Quote
_pos = _this select 0
_shift = _this select 1
_alt = _this select 2

#target
hint "Check"
_target = createMarker ["target", _pos]
_target setMarkerShape "ICON"
"target" setMarkerType "DESTROY"
~1
hint "SELECT INBOUND WAYPOINT"
onMapSingleClick "(_pos && _shift);true;"

#inbound
_pos2 = _this select 0
_inbound = createMarker ["inbound", _pos2]
_inbound setMarkerShape "ICON"
"inbound" setMarkerType "MOVE"

I am getting error
onMapSingleClick "(_pos && _shift);true;"
type array, expect boolen

I dont know if I am heading in the right direction or have everything screwed up.  Please help, oh great script writing wizards :D

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re: Multiple onMapSingleClicks
« Reply #4 on: 01 Dec 2007, 07:12:17 »
its da onmapsingleclcik line... u got it wrong :P

u have

Quote
"[_pos] exec "airstrike.sqs"

and u need

Code: [Select]
onMapSingleClick "nil=[_pos, _shift, _alt] exec ""YourScript.sqs""";
also its preferable u start scripting in .sqf scripts :D they look beter ;) :D but dats ur choise :D

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta