OFPEC Forum
Editors Depot - Mission Editing and Scripting => Arma2 - Editing/Scripting Multiplayer => Topic started by: Knight Trane 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:
_fun1 = s1 addaction ["Set FOB Location", "setFOB.sqf"];
setFOB.sqf
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.
-
Do you have a marker named _fob?
-
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:
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.
-
If you add the addAction right, then it shouldn't be a problem.
-
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.
-
It is possible.
Can you show some code?
-
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):
#include "functions\setFOB.sqf"
addAction.sqf
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:
/*****************************************************************
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 "";
};
-
this is how I use the onMapSingleClick to create a unit at a given place on the map
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.