Jump to content
Knifedge

No errors but no result either

Recommended Posts

HI,

 

I have created the below piece of code which to me looks like it should.

I get no errors when running the mission, there is nothing in the RPT log on server or client.

 

Can someone please help me identify where I have gone wrong?

The below script gets called in client init, I have other scripts adding in actions at this point and they are working OK.

private ["_casAmmoCost", "_casFuelCost", "_availableCASCallers"];
_casAmmoCost = 85;
_casFuelCost = 20;
_availableCASCallers = ["Radioman", "Squad Leader", "Team Leader", "Commander"];

_c = "<t color='#f20000'>";
_callCASAction = [_c + "Call CAS Strike</t>",
	{ 
		_attachedTo = (_this select 0);
		_actionCaller = (_this select 1);
		
		titleText ["Click to mark CAS Target location.", "PLAIN"];
		openMap [true, false];
		
		["call_cas_" + name player, "onMapSingleClick", {
			titleText ["", "PLAIN"];
			_markerName = "CASSTRIKEMARKER_" + (str _pos);
			_marker = createMarker [_markerName, _pos];
			_marker setMarkerType "hd_objective";
			_marker setMarkerColor "ColorRed";
			_marker setMarkerText format["CAS Strike (Marked by %1)", name player];
			
			fnc_RemoveResources = {
				private ["_casAmmoCost", "_casFuelCost"];
				_casAmmoCost = _this select 0;
				_casFuelCost = _this select 1;
				resources_ammo = resources_ammo - _casAmmoCost;
				resources_fuel = resources_fuel - _casFuelCost;
			};
			[_casAmmoCost, _casFuelCost] remoteExec ["fnc_RemoveResources", 2];
			
			_center = createCenter sideLogic;    
			_group = createGroup _center;         
			_cas = _group createUnit ["ModuleCAS_F",_pos , [], 0, ""];   
			_cas setVariable ["vehicle","B_Plane_CAS_01_F",true]; 
			_cas setVariable ["type", 2,true];
			
			["call_cas_" + name player, "onMapSingleClick"] call BIS_fnc_removeStackedEventHandler;
			true;
			
			fnc_RadioMessage = {
				private ["_side", "_alias", "_message"];
				_side = _this select 0;
				_alias = _this select 1;
				_message = _this select 2;
				
				[_side, _alias] sideRadio _message;
			};
			
			[west, "AirBase", format["Roger that %1, CAS Strike Inbound at grid %2, clear the target area immediately.", name player, (mapGridPosition _pos)]] remoteExec ["fnc_RadioMessage, -2];
			hint format ["CAS Strike Inbound %1", (mapGridPosition _pos)];
			openMap [false, false];
			
			fnc_CleanUpMarker = {
				private "_marker";
				_marker = _this;
				deletion = _marker spawn {
					private ["_pmarker", "_markerTimer"];
					_pmarker = _this;
					_markerTimer = 1;

					while { _markerTimer < 30 } 
					do { 
						uiSleep 30;
						_markerTimer = _markerTimer + 30;
					};

					deleteMarker _pmarker;
				};
			};
			
			_marker remoteExec ["fnc_CleanUpMarker", 2];
		}, []] call BIS_fnc_addStackedEventHandler
	},
[],
0,
false,
true,
"",
"true",
-1,
false,
"",
""];

_this addAction _callCASAction;
if (roleDescription _this in _availableCASCallers) then {
	_this addAction _callCASAction;
};

_this addEventHandler ["Respawn",{
	if (roleDescription (_this select 0) in _availableCASCallers) then {
	(_this select 0) addAction _callCASAction;
};
}];

Any help appreciated, thanks.

Share this post


Link to post
Share on other sites

It seems to me, you try to create a module but this one is not initialized (neither activated, nor linked). Adding a module with addAction is not a good idea. (Possible but difficult)

Just place a virtual (or not) CAS module and do what you want in the vehicle init. I guess your role description are already done in editor, so, there is no problem to link the module with such roles.

On the other hand, you can't let unlinked the virtual module and script these links with scripts (see bis_fnc_addSupportLink)

 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×