Home   Help Search Login Register  

Author Topic: onSingleMapClick  (Read 2271 times)

0 Members and 1 Guest are viewing this topic.

Offline Knight Trane

  • Members
  • *
onSingleMapClick
« on: 14 Feb 2011, 04:49:34 »
I got a simple script "setFOB.sqf," that is supposed to move a marker using onSingleMapClick.
I set up an addaction in the int. field of a playable unit to start the script:

Code: [Select]
_fun1 = s1 addaction ["Set FOB Location", "setFOB.sqf"];

setFOB.sqf
Code: [Select]
titleText["Commander, select position for your troops to construct F.O.B.", "PLAIN"];
onMapSingleClick "'_fob' setMarkerPos _pos; onMapSingleClick '';true;";

I've looked at alot of posts and still can't get this to work.  I need it to work on dedicated sever, but can't even get it to work on host.

Any help appreciated.



Offline i0n0s

  • Moderator
  • *****
Re: onSingleMapClick
« Reply #1 on: 14 Feb 2011, 09:05:14 »
Do you have a marker named _fob?

Offline Knight Trane

  • Members
  • *
Re: onSingleMapClick
« Reply #2 on: 14 Feb 2011, 19:41:40 »
Quote
Do you have a marker named _fob?

Yes.  I have sensed changed it to "fob".  No underscore "_".

Also I forgot to put my marker name in single quotes,' '.

I put this together form BI forums with help from Peppy:

Code: [Select]
GetClick = true;
onMapSingleClick
{
'fob' setMarkerPos _pos;
"ACE_BCS_HMMV" createVehicle _pos;
GetClick = false;
};

waitUntil{!GetClick};
onMapSingleClick "";

Exit;

So I got that part to work.  Will players be able to teleport to fob, if they are jip?  I intend to use objects and addactions to teleport out to fob.
« Last Edit: 14 Feb 2011, 19:57:18 by Knight Trane »

Offline i0n0s

  • Moderator
  • *****
Re: onSingleMapClick
« Reply #3 on: 14 Feb 2011, 22:00:06 »
If you add the addAction right, then it shouldn't be a problem.

Offline Knight Trane

  • Members
  • *
Re: onSingleMapClick
« Reply #4 on: 20 Feb 2011, 18:47:04 »
For "onMapSingleClick" is it possible to use the createUnit array and createVehicle array?  I seem to having trouble with the _pos variable, and probably quotes.

Offline i0n0s

  • Moderator
  • *****
Re: onSingleMapClick
« Reply #5 on: 20 Feb 2011, 20:48:17 »
It is possible.
Can you show some code?

Offline Knight Trane

  • Members
  • *
Re: onSingleMapClick
« Reply #6 on: 24 Feb 2011, 19:40:35 »
So I got the "addAction.sqf" to work.  It calls a function that is supposed to create a marker, "fob", and allow for a "onSingleMapClick" that will setPos the marker and create a vehicle.  The marker gets created, but the reposition and vehicle creation don't happen. 


init.sqf(test for setFOB.sqf):
Code: [Select]
#include "functions\setFOB.sqf"

addAction.sqf
Code: [Select]
if (!isServer) exitWith {};  
waituntil {!isnil "bis_fnc_init"};
if (!isnil "s1") then {
  if (player == s1) then {
//if ("fnc_CWO_setFOB")
    //player is s1, do whatever
//mf = player addaction ["Set FOB Location","action.sqf",{call fnc_CWO_FOB}];
mf = player addaction [("<t color=""#ffffff"">" + ("Set FOB Location") + "</t>"),"action.sqf",{call fnc_CWO_FOB}];
hint "go";
};
};


setFOB.sqf:
Code: [Select]
/*****************************************************************
This Script facilitates the setting and removal of the Company Forward Operating Base (FOB).
The Company Commander will have the ability to set the location of the Company FOB from any location on the map.  Once placed the addAction will be removed until he tours the battle field (enters a trigger that that makes a publicvarable true enabling a trigger, at Base, to add the action to back to the Commander).
*/

publicVariable "fnc_CWO_FOB";

fnc_CWO_FOB = {

private ["FOB"];
if (!isServer) exitWith {};  
waituntil {!isnil "bis_fnc_init"};

hint "Commander you may select the position to construct a Forward Operating Base";
    
FOB = createMarker['fob',[10,10,10]];
FOB setMarkerShape "ICON";
"fob" setMarkerType "FOB";
"fob" setMarkerColor "ColorBlue";
"fob" setMarkerText "F.O.B.";


GetClick = true;
onMapSingleClick
{
'fob' setMarkerPos _pos;
"ACE_BCS_HMMV" createVehicle _pos;
GetClick = false;
};
waitUntil{!GetClick};
onMapSingleClick "";


};

« Last Edit: 26 Feb 2011, 18:53:32 by Knight Trane »

Re: onSingleMapClick
« Reply #7 on: 24 May 2011, 20:16:55 »
this is how I use the onMapSingleClick to create a unit at a given place on the map
Code: [Select]
onlyonce=true


titletext ["Click any where on the map to place a Unit on this Pos.","plain down"]

onMapSingleClick "'ACE_USMCHM3' createUnit [_pos, group player];onlyonce=false";

@!onlyonce
onMapSingleClick ""
and it adds the unit to my squad. Not sure if this is what you are looking for.
« Last Edit: 24 May 2011, 20:18:47 by SpectrumWarrior »