Jump to content
Sign in to follow this  
McArcher

COIN modification

Recommended Posts

Can I modify or somehow edit Construction Interface, to make it build things not only horizontally , but with angle to ground (sorry for bad english).

What do I mean:

ordinary situation:

  ________
|         |
|  house  |
-------------------
        \       |
         \      |
           \    |
ground        \  |
               \

I want;

     /\
\   /   \
 \/     \
   \     /
    \   /
     \/
      \

---------- Post added at 15:47 ---------- Previous post was at 15:42 ----------

I want to place small objects not horizontally. (of cource in real life buildings are errected only horizontally, but such objects like power generator or sandbags dont have to be horizontal i think)

Edited by McArcher

Share this post


Link to post
Share on other sites

I modified the coin_interface.sqf script a while back to do this (note: you toggle ground-alignment with ALT), as well as allow you to hold SHIFT to place multiple buildings at once without having to purchase it from the menu each and every time first. It also fixes some bugs where models don't show up correctly (i.e. small sandbag barriers) which makes them a pain in the ass to place. Oh, and it disables collision detection so the builder can actually make barriers and put other objects (i.e. MG turrets) within another object (a nest or semi-circle barrier). But of course you may not want this, in which case uncomment lines 482-491 (or search for "_isFlat =").

Here's the script:

scriptName "CoIn\data\scripts\coin_interface.sqf";
/*
File: coin_interface.sqf
Author: Karel Moricky

Description:
	Construction Interface system

Parameter(s):
	_this - OBJECT - CoIn manager

Returned value(s):
	Nothing
*/
_logic = _this select 3;

//if(player distance FLAG_BASE < 1500) exitWith{ "Must be atleast 1500m away from main base to build." call XfGlobalChat; };

uinamespace setvariable ["COIN_displayMain",finddisplay 46];


debuglog format ["Log: [CoIn] %1 executed %2",player,_logic getvariable "BIS_COIN_name"];
debuglog format ["WF_CONS [CoIn] %1",_this];


//--- Terminate of system is already running
if !(isnil {player getvariable "bis_coin_logic"}) exitwith {debuglog "Log: [CoIn] Camera script is already running"};
player setvariable ["bis_coin_logic",_logic];
bis_coin_player = player;

//////////////////////////////////////////////////
startLoadingScreen [localize "str_coin_name","RscDisplayLoadMission"];
//////////////////////////////////////////////////


//--- Execute designer defined code - onStart
_code = _logic getvariable "BIS_COIN_onStart";
[_logic] call _code;

debugLog format ["COIN_ after onStart %1",_logic];

_camera = BIS_CONTROL_CAM;
if (isnil "BIS_CONTROL_CAM") then {
_camera = "camconstruct" camcreate [position player select 0,position player select 1,15];
//_camera = "camconstruct" camcreate [position _logic select 0,position _logic select 1,15];
_camera cameraeffect ["internal","back"];
_camera camPrepareFOV 0.900;
_camera campreparefocus [-1,-1];
_camera camCommitPrepared 0;
cameraEffectEnableHUD true;
_camera setdir direction player;
[_camera,-30,0] call BIS_fnc_setPitchBank;
_camera camConstuctionSetParams ([position _logic] + (_logic getvariable "BIS_COIN_areasize"));
};

BIS_CONTROL_CAM = _camera;
BIS_CONTROL_CAM_LMB = false;
BIS_CONTROL_CAM_RMB = false;
showcinemaborder false;

1122 cutrsc ["constructioninterface","plain"];

//_display = finddisplay 46;
(uinamespace getvariable "COIN_displayMain") displayseteventhandler ["KeyDown",		"if !(isnil 'BIS_CONTROL_CAM_Handler') then {BIS_temp = ['keydown',_this,commandingmenu] spawn BIS_CONTROL_CAM_Handler; BIS_temp = nil;}"];
(uinamespace getvariable "COIN_displayMain") displayseteventhandler ["KeyUp",		"if !(isnil 'BIS_CONTROL_CAM_Handler') then {BIS_temp = ['keyup',_this] spawn BIS_CONTROL_CAM_Handler; BIS_temp = nil;}"];
(uinamespace getvariable "COIN_displayMain") displayseteventhandler ["MouseButtonDown",	"if !(isnil 'BIS_CONTROL_CAM_Handler') then {BIS_temp = ['mousedown',_this,commandingmenu] spawn BIS_CONTROL_CAM_Handler; BIS_temp = nil; BIS_CONTROL_CAM_onMouseButtonDown = _this; if (_this select 1 == 1) then {BIS_CONTROL_CAM_RMB = true}; if (_this select 1 == 0) then {BIS_CONTROL_CAM_LMB = true};}"];
(uinamespace getvariable "COIN_displayMain") displayseteventhandler ["MouseButtonUp",	"if !(isnil 'BIS_CONTROL_CAM_Handler') then {BIS_CONTROL_CAM_RMB = false; BIS_CONTROL_CAM_LMB = false;}"];
//(uinamespace getvariable "COIN_displayMain") displayseteventhandler ["MouseMoving",		"if !(isnil 'BIS_CONTROL_CAM_Handler') then {BIS_temp = ['mousemoving',_this] spawn BIS_CONTROL_CAM_Handler; BIS_temp = nil;}"];
//(uinamespace getvariable "COIN_displayMain") displayseteventhandler ["MouseHolding",	"if !(isnil 'BIS_CONTROL_CAM_Handler') then {BIS_temp = ['mouseholding',_this] spawn BIS_CONTROL_CAM_Handler; BIS_temp = nil;}"];

BIS_CONTROL_CAM_keys = [];

if (isnil "BIS_CONTROL_CAM_ASL") then {
createcenter sidelogic;
_logicGrp = creategroup sidelogic;
_logicASL = _logicGrp createunit ["Logic",position player,[],0,"none"];
BIS_CONTROL_CAM_ASL = _logicASL;
};

_logic setvariable ["BIS_COIN_selected",objnull];
_logic setvariable ["BIS_COIN_params",[]];
_logic setvariable ["BIS_COIN_tooltip",""];
_logic setvariable ["BIS_COIN_menu","#USER:BIS_Coin_categories_0"];
_logic setvariable ["BIS_COIN_restart",false];
_nvgstate = if (daytime > 18.5 || daytime < 5.5) then {true} else {false};
camusenvg _nvgstate;
_logic setvariable ["BIS_COIN_nvg",_nvgstate];


debugLog format ["COIN_ open menu %1",_logic];

//--- Open menu
_logic spawn {
_logic = _this;
waituntil {!isnil {_this getvariable "BIS_COIN_fundsOld"}};
while {!isnil "BIS_CONTROL_CAM"} do {
	waituntil {
		_params = _logic getvariable "BIS_COIN_params";
		if (isnil "_params") then {_params = []};
		(commandingmenu == "" && count _params == 0 && !BIS_CONTROL_CAM_RMB) || isnil "BIS_CONTROL_CAM"
	};
	if (isnil "BIS_CONTROL_CAM") exitwith {};
	showcommandingmenu "#USER:BIS_Coin_categories_0";
	//showcommandingmenu (_logic getvariable "BIS_COIN_menu");
	sleep 0.01;
};
};

debugLog format ["COIN_ border %1",_logic];

//--- Border - temporary solution //TODO: move border if position of logic changes (eg. by placing hq)
_createBorder = {
_logic = _this;
_oldBorder = missionnamespace getvariable "BIS_COIN_border";
if (!isnil "_oldBorder") then {
	{deletevehicle _x} foreach _oldBorder;
};
missionnamespace setvariable ["BIS_COIN_border",nil];

_border = [];
_center = position _logic;
_size = (_logic getvariable "BIS_COIN_areasize") select 0;
_width = 9.998; //200/126
_width = 9.996; //150/96
_width = 9.992; //100/64
_width = 9.967; //50/32
_width = 9.917; //30/20
_width = 9.83; //20/14
_width = 9.48; //10/8
_width = 10 - (0.1/(_size * 0.2));
_width = 10;

_pi = 3.14159265358979323846;
_perimeter = (_size * _pi);
_perimeter = _perimeter + _width - (_perimeter % _width);
_size = (_perimeter / _pi);
_wallcount = _perimeter / _width * 2;
_total = _wallcount;
//_size = sqrt (((_size *4)^2)/(_width^2));

/*
_pi = 3.14159265358979323846;
_perimeterOrig = (_size * 2 * _pi);
_perimeterOrig = _perimeterOrig + _width - (_perimeterOrig % _width);

_total = _perimeterOrig / _width;
_perimeter = _perimeterOrig / _width;
_minD = 2 * sqrt ((_size/2)^2 - _total);
_size = _minD;
*/

//hintc str [_total,_size];
for "_i" from 1 to _total do {
	_dir = (360 / _total) * _i;
	_xpos = (_center select 0) + (sin _dir * _size);
	_ypos = (_center select 1) + (cos _dir * _size);
	_zpos = (_center select 2);

	_a = "transparentwall" createvehiclelocal [_xpos,_ypos,_zpos];
	_a setposasl [_xpos,_ypos,0];
	_a setdir (_dir + 90);
	_border = _border + [_a];
	//[_a,0,0] call BIS_fnc_setPitchBank;
	//sleep 0.01;
};
missionnamespace setvariable ["BIS_COIN_border",_border];
};
_createBorderScope = _logic spawn _createBorder;

//"chromAberration" ppEffectEnable true;
//"chromAberration" ppEffectAdjust [0.015*0.666, 0.0175*0.666, false];
//"chromAberration" ppEffectCommit 0;

debugLog format ["COIN_ cam handler %1",_logic];


//--- This block is pretty important
if !(isnil "BIS_CONTROL_CAM_Handler") exitwith {endLoadingScreen};

BIS_CONTROL_CAM_Handler = {
_mode = _this select 0;
_input = _this select 1;
_camera = BIS_CONTROL_CAM;
_logic = bis_coin_player getvariable "bis_coin_logic";
_terminate = false;

 	if (isnil "_logic") exitwith {};

//--- Closing CoIn if player not in rules
//	_rules = _logic getvariable "BIS_COIN_rules";	
//	_code = if (typename _rules == "ARRAY") then {{(player in _rules) || ((side player) in _rules)}} else {{(side player) == _rules}}; //! same condition code as in coin //.fsm
//	if !(call _code) then {BIS_COIN_QUIT = true;}; //player not in rules -> close

_areasize = _logic getvariable "BIS_COIN_areasize";
_limitH = _areasize select 0;
_limitV = _areasize select 1;

_keysCancel		= actionKeys "MenuBack";
_keysRepair		= actionKeys "User13";
_keysSell		= actionKeys "User14";
_keysUp		= actionKeys "nextAction";
_keysDown		= actionKeys "prevAction";
_keysShift		= actionKeys "User11";

_keysBanned		= [1];
//_keysSelectAll		= actionKeys "SelectAll";
_keyNightVision		= actionKeys "NightVision";


//--- Mouse Moving/Holding
if (_mode in ["mousemoving","mouseholding"]) then {
	///_logic = bis_coin_player getvariable "bis_coin_logic";
	//_logic setvariable ["BIS_COIN_mousepos",_input];
};

//--- Mouse DOWN
if (_mode == "mousedown") then {
	_key = _input select 1;
	if (_key == 1 && 65665 in (actionkeys "MenuBack")) then {_terminate = true};
};


//--- Key DOWN
if (_mode == "keydown") then {

	_key = _input select 1;
	if !(_key in (BIS_CONTROL_CAM_keys + _keysBanned)) then {BIS_CONTROL_CAM_keys = BIS_CONTROL_CAM_keys + [_key]};

	//--- Terminate CoIn
	if (_key in _keysCancel && isnil "BIS_Coin_noExit") then {_terminate = true};

	//--- Start NVG
	if (_key in _keyNightVision) then {
		_NVGstate = !(_logic getvariable "BIS_COIN_nvg");
		_logic setvariable ["BIS_COIN_nvg",_NVGstate];
		camusenvg _NVGstate;
	};
};
//--- Key UP
if (_mode == "keyup") then {
	_key = _input select 1;
	if (_key in BIS_CONTROL_CAM_keys) then {BIS_CONTROL_CAM_keys = BIS_CONTROL_CAM_keys - [_key]};
};

//--- Deselect or Close
if (_terminate) then {
	_menu = _this select 2;

	//--- Close
	if (isnil "BIS_Coin_noExit") then {
		if (_menu == "#USER:BIS_Coin_categories_0") then {
			BIS_CONTROL_CAM cameraeffect ["terminate","back"];
			camdestroy BIS_CONTROL_CAM;
			BIS_CONTROL_CAM = nil;
		} else {
			_preview = _logic getvariable "BIS_COIN_preview";
			if !(isnil "_preview") then {deletevehicle _preview};
			_logic setvariable ["BIS_COIN_preview",nil];
			_logic setvariable ["BIS_COIN_params",[]];
		};
	};
};

//--- Camera no longer exists - terminate and start cleanup	
if (isnil "BIS_CONTROL_CAM" || player != bis_coin_player || !isnil "BIS_COIN_QUIT") exitwith {
	//////////////////////////////////////////////////
	startLoadingScreen [localize "str_coin_exit" + " " + localize "str_coin_name","RscDisplayLoadMission"];
	//////////////////////////////////////////////////

	if !(isnil "BIS_CONTROL_CAM") then {BIS_CONTROL_CAM cameraeffect ["terminate","back"];camdestroy BIS_CONTROL_CAM;};
	BIS_CONTROL_CAM = nil;
	BIS_CONTROL_CAM_Handler = nil;
	1122 cuttext ["","plain"];
	_player = bis_coin_player;
	_player setvariable ["bis_coin_logic",nil];
	bis_coin_player = objnull;
	_preview = _logic getvariable "BIS_COIN_preview";
	if !(isnil "_preview") then {deletevehicle _preview};
	//_logic setvariable ["BIS_COIN_mousepos",nil];
	_logic setvariable ["BIS_COIN_preview",nil];
	_logic setvariable ["BIS_COIN_selected",nil];
	_logic setvariable ["BIS_COIN_params",nil];
	_logic setvariable ["BIS_COIN_lastdir",nil];
	_logic setvariable ["BIS_COIN_tooltip",nil];
	_logic setvariable ["BIS_COIN_fundsOld",nil];
	_logic setvariable ["BIS_COIN_restart",nil];
	_logic setvariable ["BIS_COIN_nvg",nil];
	showcommandingmenu "";

	//_display = finddisplay 46;
	(uinamespace getvariable "COIN_displayMain") displayseteventhandler ["KeyDown",		""];
	(uinamespace getvariable "COIN_displayMain") displayseteventhandler ["KeyUp",		""];
	(uinamespace getvariable "COIN_displayMain") displayseteventhandler ["MouseButtonDown",	""];
	(uinamespace getvariable "COIN_displayMain") displayseteventhandler ["MouseButtonUp",	""];
	(uinamespace getvariable "COIN_displayMain") displayseteventhandler ["MouseMoving",		""];
	(uinamespace getvariable "COIN_displayMain") displayseteventhandler ["MouseHolding",	""];
	(uinamespace getvariable "COIN_displayMain") displayseteventhandler ["MouseZChanged",	""];

	//--- Behold the placeholders
	BIS_COIN_QUIT = nil;
	_border = missionnamespace getvariable "BIS_COIN_border";
	{deletevehicle _x} foreach _border;
	missionnamespace setvariable ["BIS_COIN_border",nil];
	//"chromAberration" ppEffectEnable false;
	//if !(isnil "BIS_WF_CoreCommonInitialized") then {(uinamespace getvariable "COIN_displayMain") displaySetEventHandler ["keydown","if ((_this select 1) In actionKeys ""TeamSwitch"") then {[] Exec (corePath + ""Client\Action\Action_OpenOptionsMenu.sqs"")};"];};

	debuglog format ["Log: [CoIn] %1 terminated %2",player,_logic getvariable "BIS_COIN_name"];

	//////////////////////////////////////////////////
	endLoadingScreen;
	//////////////////////////////////////////////////
};

//coinn = coinn + 1;
};

waituntil {scriptdone _createBorderScope};
//////////////////////////////////////////////////
endLoadingScreen;
//////////////////////////////////////////////////








/*******************************************************************************************************************************************************
/*** LOOOP *********************************************************************************************************************************************
/******************************************************************************************************************************************************/
_canAffordCount = 0;
_canAffordCountOld = 0;
_oldMenu = commandingmenu;
_limitHOld = -1;
_limitVOld = -1;
_loaded = false;
_localtime = time;
_heightAdj = 0;
while {!isnil "BIS_CONTROL_CAM"} do {
if (isnull (uinamespace getvariable 'BIS_CONTROL_CAM_DISPLAY') && !_loaded) then {
	cameraEffectEnableHUD true;
	1122 cutrsc ["constructioninterface","plain"];
	_loaded = true;
	_logic setvariable ["BIS_COIN_restart",true];
	_localtime = time;
};
if ((time - _localtime) >= 1 && _loaded) then {_loaded = false};
_logic = bis_coin_player getvariable "bis_coin_logic";

_mode = "mousemoving";
//_input = _logic getvariable "BIS_COIN_mousepos";
_camera = BIS_CONTROL_CAM;

 	if (isnil "_logic") exitwith {};

//--- Closing CoIn if player not in rules
//_rules = _logic getvariable "BIS_COIN_rules";	
//_code = if (typename _rules == "ARRAY") then {{(player in _rules) || ((side player) in _rules)}} else {{(side player) == _rules}}; //! same condition code as in coin //.fsm
//if !(call _code) then {BIS_COIN_QUIT = true}; //player not in rules -> close

_areasize = _logic getvariable "BIS_COIN_areasize";
_limitH = _areasize select 0;
_limitV = _areasize select 1;

if (_limitH != _limitHOld || _limitV != _limitVOld) then {
	_logic spawn _createBorder;
	BIS_CONTROL_CAM camConstuctionSetParams ([position _logic] + (_logic getvariable "BIS_COIN_areasize"));
};
_limitHOld = _limitH;
_limitVOld = _limitV;


_keysCancel		= actionKeys "MenuBack";
_keysRepair		= actionKeys "User13";
_keysSell		= actionKeys "User14";
_keysShift		= actionKeys "User11";
_keysAlt		= actionkeys "User12";

_keysBanned		= [1];
_keysSelectAll		= actionKeys "SelectAll";

/*
//--- Close
if (BIS_CONTROL_CAM_RMB && 65665 in (actionkeys "MenuBack") && isnil "BIS_Coin_noExit") then {
	if (commandingmenu == "#USER:BIS_Coin_categories_0") then {
		BIS_CONTROL_CAM cameraeffect ["terminate","back"];
		camdestroy BIS_CONTROL_CAM;
		BIS_CONTROL_CAM = nil;
	};
};
*/

//--- Mouse moving or holding
if (_mode in ["mousemoving","mouseholding"]) then {

	_x = _input select 1;
	_y = _input select 2;

	//--- Check pressed keys
	_keys = BIS_CONTROL_CAM_keys;
	//debuglog ("Log: " + str _keys);
	_ctrl = (29 in _keys) || (157 in _keys);
	_shift = (42 in _keys) || (54 in _keys);
	_alt = (56 in _keys);


	//--- Construction or Selection
	_params = _logic getvariable "BIS_COIN_params";
	_tooltip = "empty";
	_tooltipType = "empty";
	_selected = objnull;
	if (count _params > 0) then {

		//--- Construction

		//--- Basic colors
		_colorGreen = "#(argb,8,8,3)color(0,1,0,0.3,ca)";
		_colorRed = "#(argb,8,8,3)color(1,0,0,0.3,ca)";
		_colorGray = "#(argb,8,8,3)color(1,1,1,0.1,ca)";
		_colorGray = "#(argb,8,8,3)color(0,0,0,0.25,ca)";
		_color = _colorGreen;

		//--- Class, Category, Cost, (preview class), (display name)
		_itemclass = _params select 0;
		_itemcategory = _params select 1;
		//if (typename _itemcategory == typename 0) then {_itemCategory = select _itemcategory};
		_itemcost = _params select 2;
		_itemcash = 0;
		if (typename _itemcost == "ARRAY") then {_itemcash = _itemcost select 0; _itemcost = _itemcost select 1};
		_itemFunds = (_logic getvariable "BIS_COIN_funds") select _itemcash;
		_itemname = if (count _params > 3) then {_params select 3} else {gettext (configfile >> "CfgVehicles" >> _itemclass >> "displayName")};
		//_itemclass_preview = _itemclass + "preview";
		_itemclass_preview = gettext (configfile >> "CfgVehicles" >> _itemclass);
		if (_itemclass_preview == "") then {_itemclass_preview = _itemclass};
		//if (str (configfile >> "CfgVehicles" >> _itemclass_preview) == "") then {_itemclass_preview = _itemclass};


		//--- Preview building
		_preview = camtarget BIS_CONTROL_CAM;
		if (typeof _preview != _itemclass_preview) then {
//debuglog str ["Log:::::::::",time,_itemclass,_itemclass_preview,(configfile >> "CfgVehicles" >> _itemclass >> "ghostpreview")];
			//--- No preview
			deletevehicle _preview;
			if !(isnil {_logic getvariable "BIS_COIN_preview"}) then {deletevehicle (_logic getvariable "BIS_COIN_preview")}; //--- Serialization hack
			_preview = _itemclass_preview createvehicle (screentoworld [0.5,0.5]);
			BIS_CONTROL_CAM camsettarget _preview;
			BIS_CONTROL_CAM camcommit 0;
			_logic setvariable ["BIS_COIN_preview",_preview];

			_preview setObjectTexture [0,_colorGray];
			_preview setvariable ["BIS_COIN_color",_colorGray];

			//--- Execute designer defined code
			_code = _logic getvariable "BIS_COIN_onSelect";
			//[_itemclass,_preview] call _code;
			[_logic, _preview,_itemclass] spawn _code;

			//--- Exception - preview not created
			if (isnull _preview) then {
				deletevehicle _preview;
				_logic setvariable ["BIS_COIN_preview",nil];
				_logic setvariable ["BIS_COIN_params",[]];
				debuglog format ["Log: [COIN] ERROR: Failed to create '%1' (preview of '%2')",_itemclass_preview,_itemclass];
			};

		} else {
			//--- Check zone
			if (
				([position _preview,_logic] call BIS_fnc_distance2D) > _limitH
			) then {
				_color = _colorGray
			} else {

				//--- No money
				_funds = 0;
				call compile format ["_funds = %1",_itemFunds];
				_fundsRemaining = _funds - _itemcost;
				if (_fundsRemaining < 0) then {_color = _colorRed};

				//--- No Place To Build
				/*_isFlat = (position _preview) isflatempty [
					(sizeof typeof _preview) / 2,	//--- Minimal distance from another object
					0,				//--- If 0, just check position. If >0, select new one
					0.7,				//--- Max gradient
					(sizeof typeof _preview),	//--- Gradient area
					0,				//--- 0 for restricted water, 2 for required water,
					false,				//--- True if some water can be in 25m radius
					_preview			//--- Ignored object
				];
				if (count _isFlat == 0) then {_color = _colorRed};*/
			};
			_preview setObjectTexture [0,_color];
			_preview setvariable ["BIS_COIN_color",_color];

			_tooltip = _itemclass;
			_tooltipType = "preview";

			//--- Temporary solution
			_colorGUI = [1,1,1,0.1];
			if (_color == _colorGreen) then {_colorGUI = [0.3,1,0.3,0.3]};
			if (_color == _colorRed) then {_colorGUI = [1,0.2,0.2,0.4]};

			//_display = uiNamespace getvariable "BIS_CONTROL_CAM_DISPLAY";
			//_center = (uiNamespace getvariable "BIS_CONTROL_CAM_DISPLAY") displayctrl 112201;
			((uiNamespace getvariable "BIS_CONTROL_CAM_DISPLAY") displayctrl 112201) ctrlsettextcolor _colorGUI;
			((uiNamespace getvariable "BIS_CONTROL_CAM_DISPLAY") displayctrl 112201) ctrlcommit 0;
		};

		//--- Place
		if (!isnull _preview && ((BIS_CONTROL_CAM_LMB && 65536 in (actionKeys "DefaultAction")) || {_x in (actionKeys "DefaultAction")} count BIS_CONTROL_CAM_keys > 0) && _color == _colorGreen) then {


			_pos = position _preview;
			_dir = direction _preview;
			_done = true;
			_align = false;
			if (count _keys > 0) then {
				if ({_x in _keysShift} count _keys > 0) then {
						_done = false;
				};
				if ({_x in _keysAlt} count _keys > 0) then {
						_align = true;
				};
			};
			if(_done) then {
			deletevehicle _preview;
			_logic setvariable ["BIS_COIN_preview",nil];
			_logic setvariable ["BIS_COIN_params",[]]; };

			//--- Remove funds
			call compile format ["%1 = %1 - _itemcost",_itemFunds];

			//--- Execute designer defined code
			[_logic,_itemclass,_pos,_dir,_done,_align] spawn {
				_logic = _this select 0;
				_itemclass = _this select 1;
				_pos = _this select 2;
				_dir = _this select 3;
				_done = _this select 4;
				_align = _this select 5;

				//format["%1",_pos] call XfGlobalChat;


				_code = _logic getvariable "BIS_COIN_onPurchase";
				[_logic,objNull,_itemclass,_pos,_dir] call _code;

				//--- Build				
				_building = _itemclass createvehicle _pos;//[10,10,10000];
				_building setpos _pos;
				_building setdir _dir;
				sleep 0.1;
				if(!_align) then {_building setpos _pos;};
				//if (gettext (configfile >> "cfgvehicles" >> _itemclass >> "placement") == "vertical") then {_building setpos _pos}; //--- Vertical

				_building setvariable ["BIS_COIN_cost",_itemcost,true];

				//--- Register building
				[_logic,"BIS_COIN_buildings",[_building],true] call bis_fnc_variablespaceadd;
				if(!_align) then {
				waituntil {!isnull _building};
				_building setdir _dir;
				_building setpos _pos; 
				};
				//--- Execute designer defined code On Construct
				_code = _logic getvariable "BIS_COIN_onConstruct";
				[_logic, _building,_itemclass,_pos,_dir] spawn _code;
			};
			//--- Temporary solution
			_colorGUI = [1,1,1,0.1];
			//_display = uiNamespace getvariable "BIS_CONTROL_CAM_DISPLAY";
			//_center = (uiNamespace getvariable "BIS_CONTROL_CAM_DISPLAY") displayctrl 112201;
			((uiNamespace getvariable "BIS_CONTROL_CAM_DISPLAY") displayctrl 112201) ctrlsettextcolor _colorGUI;
			((uiNamespace getvariable "BIS_CONTROL_CAM_DISPLAY") displayctrl 112201) ctrlcommit 0;
		};

		//--- Deselect
/*
		if (BIS_CONTROL_CAM_RMB) then {
			deletevehicle _preview;
			_logic setvariable ["BIS_COIN_preview",nil];
			_logic setvariable ["BIS_COIN_params",[]];
		};
*/
	} else {
		_colorGUI = [1,1,1,0.1];

		_buildings = _logic getvariable "BIS_COIN_buildings";
		if (count _buildings > 0) then {

			//--- Selection
			_worldpos = screentoworld [0.5,0.5];
			_selected = objnull;

			{
				_size = (sizeof typeof _x) / 3;
				if (_size < 2) then {_size = 2};
				if (_x distance _worldpos < _size) exitwith {_selected = _x;_logic setvariable ["BIS_COIN_selected",_selected]};
				_logic setvariable ["BIS_COIN_selected",objnull];
			} foreach _buildings;

			//--- Selected building
			if !(isnull _selected) then {
				_colorGUI = [1,1,1,0.3];

				_tooltip = typeof _selected;
				_tooltipType = "selected";

				//--- Custom actions
				if (count _keys > 0 && !_ctrl) then {

					//--- Repair
					if ({_x in _keysRepair} count _keys > 0) then {
						[_logic,_selected] spawn {
							_code = (_this select 0) getvariable "BIS_COIN_onRepair";
							_this call _code;
							(_this select 1) setdamage 0;
						};
					};

					//--- Sell
					if ({_x in _keysSell} count _keys > 0) then {
						[_logic,_selected] spawn {
							_code = (_this select 0) getvariable "BIS_COIN_onSell";
							_this call _code;
							deletevehicle (_this select 1);
						};
					};

				};
			};
		};

		//_display = uiNamespace getvariable "BIS_CONTROL_CAM_DISPLAY";
		//_center = (uiNamespace getvariable "BIS_CONTROL_CAM_DISPLAY") displayctrl 112201;
		((uiNamespace getvariable "BIS_CONTROL_CAM_DISPLAY") displayctrl 112201) ctrlsettextcolor _colorGUI;
		((uiNamespace getvariable "BIS_CONTROL_CAM_DISPLAY") displayctrl 112201) ctrlcommit 0;
	};

	_oldTooltip = _logic getvariable "BIS_COIN_tooltip";
	//_display = uiNamespace getvariable "BIS_CONTROL_CAM_DISPLAY";
	if ((_tooltipType + _tooltip) != _oldTooltip || commandingmenu != _oldMenu) then {

		//--- Description
		_type = _tooltip;

		//--- Header & preview picture

		_textHeader = "<t size='1.2'><br /></t>";
		_textPicture = "<t size='2.8'><br /></t><br /><br />";
		_fileIcon = gettext (configfile >> "cfgvehicles" >> _type >> "icon");
		if (str(configfile >> "CfgVehicleIcons" >> _fileIcon) != "") then {_fileIcon = gettext (configfile >> "CfgVehicleIcons" >> _fileIcon)};
		_filePicture = gettext (configfile >> "cfgvehicles" >> _type >> "picture");
		if (str(configfile >> "CfgVehicleIcons" >> _filePicture) != "") then {_filePicture = gettext (configfile >> "CfgVehicleIcons" >> _filePicture)};

		if (_tooltipType != "empty") then {
			_textHeader = format ["<t align='center'><t size='1.4'>%1</t><br /><t size='1'></t></t>",
				gettext (configfile >> "cfgvehicles" >> _type >> "displayname"),
				if (isnull _selected) then {""} else {str round ((1 - damage _selected) * 100) + "%"}
			];
			_textPicture = format ["<t align='left' size='2.8' shadow='0'><img image='%1'/></t> ",_filePicture];
		};

		/*
		_textHeader = "X";
		_textPicture = "";		
		*/

		_text1 = if (_tooltipType == "selected" && (str (_logic getvariable "BIS_COIN_onRepair") != str {})) then {

			//--- Repair hint
			localize "str_coin_repair" + "<t align='right'>" + call compile (actionKeysNames ["User13",1]) + "</t><br />";
		} else {
			//--- Rotate
			if (count _params > 0) then {
				localize "str_coin_rotate" + "<t align='right'>" + call compile (keyname 29) + "</t><br />";
			} else {"<br />"};
		};

		_text2 = if (_tooltipType == "selected" && (str (_logic getvariable "BIS_COIN_onSell") != str {})) then {

			//--- Sell hint
			localize "str_coin_sell" + "<t align='right'>" + call compile (actionKeysNames ["User14",1]) + "</t><br />";
		} else {

			//--- Build hint
			if (count _params > 0) then {
				localize "str_coin_build" + "<t align='right'>" + call compile (actionKeysNames ["DefaultAction",1]) + "</t><br />";
			} else {"<br />"};

		};

		_text3 = if (commandingmenu != "#USER:BIS_Coin_categories_0") then {

			//--- Back hint
			if (isnil "BIS_Coin_noExit") then {
				localize "str_coin_back" + "<t align='right'>" + call compile (actionKeysNames ["MenuBack",1]) + "</t>";
			} else {""};
		} else {

			//--- Exit hint
			if (isnil "BIS_Coin_noExit") then {
				"<t color='#ff5544'>" + localize "str_coin_exit" + "<t align='right'>" + call compile (actionKeysNames ["MenuBack",1]) + "</t></t>";
			} else {""};
		};

		//--- Compose text
		_textHint = (
		 	_textPicture + 
			_textHeader + 
			""
		);

		_textControls = (
			_text1 + 
			_text2 + 
			_text3 + 
			""
		);

		//--- Set box
		//_bcg = (uiNamespace getvariable "BIS_CONTROL_CAM_DISPLAY") displayctrl 112211;
		((uiNamespace getvariable "BIS_CONTROL_CAM_DISPLAY") displayctrl 112211) ctrlshow true;
		((uiNamespace getvariable "BIS_CONTROL_CAM_DISPLAY") displayctrl 112211) ctrlcommit 0;
		//_desc = _display displayctrl 112214;
		((uiNamespace getvariable "BIS_CONTROL_CAM_DISPLAY") displayctrl 112214) ctrlsetstructuredtext (parsetext _textHint);
		((uiNamespace getvariable "BIS_CONTROL_CAM_DISPLAY") displayctrl 112214) ctrlshow true;
		((uiNamespace getvariable "BIS_CONTROL_CAM_DISPLAY") displayctrl 112214) ctrlcommit 0;
		//_controls = _display displayctrl 112215;
		((uiNamespace getvariable "BIS_CONTROL_CAM_DISPLAY") displayctrl 112215) ctrlsetstructuredtext (parsetext _textControls);
		((uiNamespace getvariable "BIS_CONTROL_CAM_DISPLAY") displayctrl 112215) ctrlshow true;
		((uiNamespace getvariable "BIS_CONTROL_CAM_DISPLAY") displayctrl 112215) ctrlcommit 0;
	};

	//--- Amount of funds changed
	_funds = _logic getvariable "BIS_COIN_funds";
	_fundsDescription = _logic getvariable "BIS_COIN_fundsDescription";
	_cashValues = [];
	{
		_cashValues = _cashValues + [call compile _x];
	} foreach _funds;
	_cashValuesOld = _logic getvariable "BIS_COIN_fundsOld";
	if (isnil "_cashValuesOld") then {_cashValuesOld = []; _cashValuesOld set [count _cashValues - 1,-1]};
	_restart = _logic getvariable "BIS_COIN_restart";
	if (!([_cashValues,_cashValuesOld] call bis_fnc_arraycompare) || _restart) then {
		_cashValuesCount = count _cashValues;
		_cashSize = if (_cashValuesCount <= 1) then {2} else {2.8 / _cashValuesCount};
		_cashText = format ["<t size='%1' align='left' valign='middle'>",_cashSize];
		_cashLines = 0;
		for "_i" from 0 to (count _funds - 1) do {
			_cashValue = _cashValues select _i;
			_cashDescription = if (count _fundsDescription > _i) then {_fundsDescription select _i} else {"?"};
			_cashText = _cashText + format ["%1 %2<br />",_cashDescription,round _cashValue];
			_cashLines = _cashLines + 0.05;
		};
		_cashText = _cashText + "</t>";
		//_cash = _display displayctrl 112224;
		_cashPos = ctrlposition ((uiNamespace getvariable "BIS_CONTROL_CAM_DISPLAY") displayctrl 112224);
		((uiNamespace getvariable "BIS_CONTROL_CAM_DISPLAY") displayctrl 112224) ctrlsetstructuredtext (parsetext _cashText);
		((uiNamespace getvariable "BIS_CONTROL_CAM_DISPLAY") displayctrl 112224) ctrlsetposition [_cashPos select 0,_cashPos select 1,_cashPos select 2,(_cashPos select 3)/*0.1*/ + _cashLines];
		((uiNamespace getvariable "BIS_CONTROL_CAM_DISPLAY") displayctrl 112224) ctrlshow true;
		((uiNamespace getvariable "BIS_CONTROL_CAM_DISPLAY") displayctrl 112224) ctrlcommit 0;

		//--- Categories menu
		_categories = +(_logic getvariable "BIS_COIN_categories");
		//_categoriesLong = [];
		//{_categoriesLong = _categoriesLong + [_x + ""]} foreach _categories; //--- Adding empty spaces will widen the box to max value
		_categoriesMenu = [];
		for "_i" from 0 to (count _categories - 1) do {
			_categoriesMenu = _categoriesMenu + [_i];
		};

		[["Categories",true],"BIS_Coin_categories",[_categoriesMenu,_categories],"#USER:BIS_Coin_%1_items_0","",""] call BIS_fnc_createmenu;

		//--- Items menu
		_items = _logic getvariable "BIS_COIN_items";
		_canAffordCountOld = _canAffordCount;
		_canAffordCount = 0;
		debugLog format ["COIN_ %1",_items];
		for "_i" from 0 to (count _categories - 1) do {
			_category = _categories select _i;
			_arrayNames = [];
			_arrayNamesLong = [];
			_arrayEnable = [];
			_arrayParams = [];
			{
				_itemclass = _x select 0;
				_itemcategory = _x select 1;
				if (typename _itemcategory == typename "") then {//--- Backward compatibility
					_itemcategory = _categories find _itemcategory;
					debuglog format ["Log: [COIN] ERROR: Old category used: '%1' (in '%2')",_itemcategory,_itemclass];
				} else {100};

				if (_itemcategory < count _categories) then {
					_itemcost = _x select 2;
					_itemcash = 0;
					if (typename _itemcost == "ARRAY") then {_itemcash = _itemcost select 0; _itemcost = _itemcost select 1};
					_cashValue = _cashValues select _itemcash;
					_cashDescription = if (count _fundsDescription > _itemcash) then {_fundsDescription select _itemcash} else {"?"};
					_itemname = if (count _x > 3) then {_x select 3} else {gettext (configfile >> "CfgVehicles" >> _itemclass >> "displayName")};
					if (_itemcategory == _i/*_category*/) then {
						_canAfford = if (_cashValue - _itemcost >= 0) then {1} else {0};
						_canAffordCount = _canAffordCount + _canAfford;
						_text = _itemname + " - " + _cashDescription + str _itemcost;
						_arrayNames = _arrayNames + [_text];
						_arrayNamesLong = _arrayNamesLong + [_text + "                   "];
						_arrayEnable = _arrayEnable + [_canAfford];
						_arrayParams = _arrayParams + [[_logic getvariable "BIS_COIN_ID"] + [_x,_i]];
					};  
				} else {debuglog format ["Log: [CoIn] ERROR: Invalid category '%1' used in '%2'",_itemcategory,_itemclass]};
			} foreach _items;


			[[_category,true],format ["BIS_Coin_%1_items",_i],[_arrayNames,_arrayNamesLong,_arrayEnable],"","
				BIS_CONTROL_CAM_LMB = false;
				scopename 'main';
				_item = '%1';
				_id = %2;
				_array = (call compile '%3') select _id;
				_logic = call compile ('BIS_COIN_'+ str (_array select 0));

				_params = _array select 1;
				_logic setvariable ['BIS_COIN_params',_params];
				_logic setvariable ['BIS_COIN_menu',commandingmenu];
				showcommandingmenu '';

			",_arrayParams] call BIS_fnc_createmenu;	
			/*

			[_category,format ["BIS_Coin_%1_items",_category],[_arrayNames,_arrayNamesLong,_arrayEnable],"","
				debugLog ('item: %1 id %2 array %3');

			",_arrayParams] call BIS_fnc_createmenu;	
			*/
		};

		if (_canAffordCount != _canAffordCountOld) then {showcommandingmenu (commandingmenu)}; //<-- Open menu again to show disabled items
	};
	_logic setvariable ["BIS_COIN_fundsOld",_cashValues];
	_logic setvariable ["BIS_COIN_tooltip",_tooltipType + _tooltip];

	if (_restart) then {
		_logic setvariable ["BIS_COIN_restart",false];
		//showcommandingmenu "";
	};
};
_oldMenu = commandingmenu;

sleep 0.01;
};

Edit: Oh, and you may need to bind Shift and Alt to the "User11" and "User12" actions respectively. They're under custom actions in the key config menu. I forget if they were default or not.

Edited by MH6

Share this post


Link to post
Share on other sites

MH6, How can I use it in my mission instead of original COIN ?

---------- Post added at 21:54 ---------- Previous post was at 21:42 ----------

no horisontal alignment and no collision detection are great things, I have been looking for, but didn't know how to rip this CoIn out of game's code :D because original COIN doesn't allow to build Masking Nets over objects and doesn't allow building in the forest after cleaning up ground from trees. If I make it working in my mission I will be the happiest man on Earth, maybe :)

Share this post


Link to post
Share on other sites
MH6, How can I use it in my mission instead of original COIN ?

---------- Post added at 21:54 ---------- Previous post was at 21:42 ----------

no horisontal alignment and no collision detection are great things, I have been looking for, but didn't know how to rip this CoIn out of game's code :D because original COIN doesn't allow to build Masking Nets over objects and doesn't allow building in the forest after cleaning up ground from trees. If I make it working in my mission I will be the happiest man on Earth, maybe :)

You need to do something similar to the following whenever the player you want to give the ability to build to spawns.

When they spawn (which you can determine with the use of an event handler if you haven't set something up already), you have to add a custom Build action to their action menu, like so:

_action = player addAction ["Build","scripts\coin\coin_interface.sqf",x_consmod,1,false];
player setvariable [_BIS_COIN_idAction,_action];

Where x_consmod is the name of the Construction Module you placed in the map (if it doesn't have a name, give it one). The module may also need to be synced with the player in the map editor.

Also, if you want the player to be able to build anywhere, instead of only where you place the Construction Module, add this below where you add the action:

[x_consmod,player] execVM "scripts\coin\updateConstructionModule.sqf";

and stick this into "scripts\coin\updateConstructionModule.sqf", which you'll need to create.

_module = _this select 0;
_cmdr = _this select 1;
_module setvariable ["CMDR",_cmdr,true];
while {true} do {
if(!alive _cmdr) exitWith{};
_pos = getPos _module;
_module setPos getPos _cmdr;
sleep 5;
};

All this does is reset the position of the module to the player's position, so he'll always be able to build where he is at. It keeps the radius restriction though, so he can't build something a mile away from his location.

Now just stick coin_interface.sqf from my above post into scripts/coin/ and you should be set.

That should be all you need for it to work. If it doesn't, let me know; I may be forgetting something (haven't used these scripts in a while).

Edited by MH6

Share this post


Link to post
Share on other sites

Thank you.

I want to create COIN dynamically by script.

I already have one working (original COIN) and want to modify it with your COIN.

If I use the same instruction

"ConstructionManager" createUnit [ getPos RU_MHQ, group_RU_MHQ, "COIN_RU_MHQ = this;"];
will it work with your COIN too?

---------- Post added at 20:36 ---------- Previous post was at 20:34 ----------

is x_consmod a string? "COIN_RU_MHQ" in my case?

Share this post


Link to post
Share on other sites

x_consmod and COIN_RU_MHQ are variables, but yes, you can replace x_consmod with COIN_RU_MHQ, and your code will work.

Share this post


Link to post
Share on other sites

One small question.

I want to make Repair Trucks able to build (I will add action not to player, but to the trucks). So, if I must do

player setvariable [_BIS_COIN_idAction,_action];

to the user of a truck then should I modify truck's action that way: add a script into truck's action which will:

1. assign this _BIS_COIN_idAction to the user of a truck

2. and then call the "scripts\coin\coin_interface.sqf" with my COIN variable as a parameter?

What should I put into _BIS_COIN_idAction ?

Share this post


Link to post
Share on other sites

Not sure about that bud. Maybe try just giving the truck the Build action and ignore _BIS_COIN_idAction completely, and see if that works. If it does, great. If it doesn't, then you need some way to get the player who is using the truck. I assume you want them to be able to build while outside the truck too, yes?

Share this post


Link to post
Share on other sites

yes. only when they are outside the truck, better to say.

Share this post


Link to post
Share on other sites

RU_MHQ addEventHandler ["GetOut", 
{
private ["_action", "_unit"];
_unit = _this select 2;
if (_unit == RU_player_1) then
{
	"ConstructionManager" createUnit [ getPos RU_MHQ, group_RU_MHQ, "COIN_RU_MHQ = this;"];
	COIN_RU_MHQ synchronizeObjectsAdd [RU_player_1];

	COIN_RU_MHQ setvariable ["BIS_COIN_name", "RU MHQ"];
	COIN_RU_MHQ setvariable ["BIS_COIN_rules", [RU_player_1]];
	COIN_RU_MHQ setvariable ["BIS_COIN_categories", ["Base", "Active Defence", "Passive Defence", "Storage", "Barriers", "Respawn Points"]];
	// ...
	COIN_RU_MHQ setvariable ["BIS_COIN_funds", "mcti_money_east"];
	COIN_RU_MHQ setvariable ["BIS_COIN_fundsDescription", ["R"]];
	COIN_RU_MHQ setvariable ["BIS_COIN_areasize", [150, 15]];
	COIN_RU_MHQ setvariable ["BIS_COIN_actionCondition", "TRUE"];

	_action = RU_MHQ addAction ["Build", "scripts\coin\coin_interface.sqf", COIN_RU_MHQ, 1, false];
	RU_MHQ setvariable [_BIS_COIN_idAction, _action];
};
}];

I placed coin_interface.sqf into folder scripts\coin\ in my mission folder, and when I use the menu "Build", I see a loading screen (with green NV picture of a man :) ), the title of loading screen is "Contruction Interface". and nothing more.... ESC button doesn't help.... What is that? What did I do wrong?

---------- Post added at 04:17 ---------- Previous post was at 03:59 ----------

.rpt has

Error in expression <ce.sqf", COIN_RU_MHQ, 1, false];

RU_MHQ setvariable [_BIS_COIN_idAction, _action>

Error position: <setvariable [_BIS_COIN_idAction, _action>

Error Тип Любой, ожидаетÑÑ ÐŸÐ¾ÑледовательноÑÑ‚ÑŒ

error type any, expected ... string? i forgot ""s ?

---------- Post added at 04:19 ---------- Previous post was at 04:17 ----------

maybe instead of

RU_MHQ setvariable [_BIS_COIN_idAction, _action];

I need
COIN_RU_MHQ setvariable ["BIS_COIN_idAction", _action];

?

---------- Post added at 04:46 ---------- Previous post was at 04:19 ----------

I thought that _BIS_COIN_idAction was a constant by BIS, created empty mission with CoIn module, tried to output _BIS_COIN_idAction, it said ANY, so it is not a constant. Mistyped?

COIN_RU_MHQ setvariable ["BIS_COIN_idAction", _action]; hasn't helped...

Edited by McArcher

Share this post


Link to post
Share on other sites
waituntil {!isnil "bis_fnc_init"};

//[] call BIS_fnc_help;

///////////////////////////////////////////////////////////////

enableSaving [false, false];

waitUntil {time>0.1};

private ["_action", "_group"];

mcti_money_east = 99000;

_group = createGroup east;

COIN_RU_MHQ = "ConstructionManager" createUnit [ position player, _group, ""];

//COIN_RU_MHQ synchronizeObjectsAdd [RU_player_1];

COIN_RU_MHQ setvariable ["BIS_COIN_name", "RU MHQ"];

COIN_RU_MHQ setvariable ["BIS_COIN_rules", [RU_player_1]];

COIN_RU_MHQ setvariable ["BIS_COIN_categories", ["Base", "Active Defence", "Passive Defence", "Storage", "Barriers", "Respawn Points"]];

COIN_RU_MHQ setvariable ["BIS_COIN_funds", "mcti_money_east"];

COIN_RU_MHQ setvariable ["BIS_COIN_fundsDescription", ["R"]];

COIN_RU_MHQ setvariable ["BIS_COIN_areasize", [150, 15]];

COIN_RU_MHQ setvariable ["BIS_COIN_actionCondition", "TRUE"];

COIN_RU_MHQ setvariable ["BIS_COIN_items",

[

//--- Class, Category, Cost or [fundsID,Cost], (display name)

// Buildings for Base construction

["RU_WarfareBBarracks", "Base", 3000, "Barracks (Field Variant)"],

["Land_Mil_Barracks_i", "Base", 3500, "Barracks (City Variant)"],

["RU_WarfareBLightFactory", "Base", 9000, "Light Factory"],

["RU_WarfareBHeavyFactory", "Base", 25000, "Heavy Factory"],

["RU_WarfareBAircraftFactory", "Base", 31000, "Aircraft Factory"],

["RU_WarfareBVehicleServicePoint", "Base", 4000, "Vehicle Service Point"],

["RU_WarfareBUAVterminal", "Base", 4000, "Radio Terminal"],

["PowGen_Big", "Base", 1000, "Diesel Power Generator"],

["RU_WarfareBFieldhHospital", "Respawn Points", 1000, "Field Hospital"],

["Land_tent_east", "Storage", 100, "Small Tent"],

["Land_Ind_Garage01", "Storage", 500, "Small Garage"],

["Land_Ind_Workshop01_02", "Storage", 600, "Small Workshop"],

["Land_Barn_W_02", "Storage", 600, "Short Barn"],

["Land_Ind_Workshop01_04", "Storage", 700, "Old Workshop"],

["Land_Barn_W_01", "Storage", 800, "Long Barn"],

["Land_Hangar_2", "Storage", 1000, "Large Hangar w/ Doors"],

["WarfareBAirport", "Storage", 2500, "Large Hangar"],

["KORD", "Active Defence", 250, "KORD Minitripod"],

["KORD_high", "Active Defence", 275, "KORD"],

["RU_WarfareBMGNest_PK", "Active Defence", 300, "MG Nest (PK)"],

["AGS_RU", "Active Defence", 700, "AGS-30"],

["Igla_AA_pod_East", "Active Defence", 800, "AA IGLA Pod"],

["Metis", "Active Defence", 800, "Metis AT-13"],

["ZU23_Ins", "Active Defence", 900, "ZU-23"],

["2b14_82mm", "Active Defence", 1000, "Podnos 2B14"],

["D30_RU", "Active Defence", 1900, "D-30"],

["SearchLight_RUS", "Active Defence", 100, "Searchlight"],

["Land_CamoNet_EAST", "Passive Defence", 50, "Camo Net 1"],

["Land_CamoNetB_EAST", "Passive Defence", 75, "Camo Net Big"],

["Land_CamoNetVar_EAST", "Passive Defence", 50, "Camo Net 2"],

["Land_fort_rampart", "Passive Defence", 50, "Rampart Element"],

["Land_Hlidac_budka", "Passive Defence", 50, "Sentry Box"],

["Land_fort_artillery_nest", "Passive Defence", 100, "Rampart (Nest)"],

["Land_fortified_nest_small", "Passive Defence", 200, "Nest (Small)"],

["Land_fortified_nest_big", "Passive Defence", 500, "Nest (Big)"],

["Land_Fort_Watchtower", "Passive Defence", 525, "Fort"],

["Land_Vysilac_FM", "Passive Defence", 600, "Tower"],

["Land_Mil_Guardhouse", "Passive Defence", 1000, "Checkpoint"],

["Land_Mil_ControlTower", "Passive Defence", 2000, "Control Tower"],

["Fence_corrugated_plate", "Barriers", 20, "Fence 1"],

["Fence_Ind_long", "Barriers", 20, "Fence 2"],

["Fort_RazorWire", "Barriers", 25, "Razor Wire"],

["Hedgehog", "Barriers", 50, "Hedgehog"],

["Hhedgehog_concrete", "Barriers", 75, "Small Concrete Hedgehog"],

["Hhedgehog_concreteBig", "Barriers", 100, "Big Concrete Hedgehog"],

["Fort_Barricade", "Barriers", 100, "Barricade from Garbage"],

["Land_fort_bagfence_long", "Barriers", 25, "Sandbag - Long"],

["Land_fort_bagfence_corner", "Barriers", 50, "Sandbag - Corner"],

["Land_fort_bagfence_round", "Barriers", 50, "Sandbag - Round"],

["Land_HBarrier1", "Barriers", 20, "Hesco x1"],

["Land_HBarrier3", "Barriers", 60, "Hesco x3"],

["Land_HBarrier5", "Barriers", 100, "Hesco x5"],

["Land_HBarrier_large", "Barriers", 150, "Big Hesco x4"]

]

];

_action = UAZ_1 addAction ["Build", "scripts\coin\coin_interface.sqf", COIN_RU_MHQ, 1, false];

player setvariable [_BIS_COIN_idAction, _action];

hangs on loading screen :(

---------- Post added at 19:23 ---------- Previous post was at 19:06 ----------

undefined _BIS_COIN_idAction.

---------- Post added at 19:40 ---------- Previous post was at 19:23 ----------

_action = player addAction ["Build", "scripts\coin\coin_interface.sqf", COIN_RU_MHQ, 1, false];

player setvariable [_BIS_COIN_idAction, _action];

gives the same error. is _BIS_COIN_idAction right word? Edited by McArcher

Share this post


Link to post
Share on other sites

omg, I've found _BIS_COIN_idAction in the coin.sqf, ripped from Modules.pbo....... if I could understand it quickly....... :D

_id = _logic getvariable "BIS_COIN_id";

_BIS_COIN_idAction = format ["BIS_COIN_action_%1",_id];

---------- Post added at 00:57 ---------- Previous post was at 00:17 ----------

I have acheived some progress... This code deletes original action. However, I must wait about 5-6 sec after my new action appears! Otherwise, coin will show empty interface and hang...

waituntil {!isnil "bis_fnc_init"};
//[] call BIS_fnc_help;
///////////////////////////////////////////////////////////////
enableSaving [false, false];
waitUntil {time>0.1};

private ["_action", "_group", "_id", "_BIS_COIN_idAction"];
mcti_money_east = 99000;
_group = createGroup east;

"ConstructionManager" createUnit [ getPos player, _group, "COIN_RU_MHQ = this;"];
COIN_RU_MHQ synchronizeObjectsAdd [RU_player_1];
COIN_RU_MHQ setvariable ["BIS_COIN_name", "RU MHQ"];
COIN_RU_MHQ setvariable ["BIS_COIN_rules", [east]];
COIN_RU_MHQ setvariable ["BIS_COIN_categories", ["Base", "Active Defence", "Passive Defence", "Storage", "Barriers", "Respawn Points"]];
COIN_RU_MHQ setvariable ["BIS_COIN_funds", "mcti_money_east"];
COIN_RU_MHQ setvariable ["BIS_COIN_fundsDescription", ["R"]];
COIN_RU_MHQ setvariable ["BIS_COIN_areasize", [150, 15]];
COIN_RU_MHQ setvariable ["BIS_COIN_actionCondition", "TRUE"];

COIN_RU_MHQ setvariable ["BIS_COIN_items",
			[
				//--- Class, Category, Cost or [fundsID,Cost], (display name)
				// Buildings for Base construction
				["RU_WarfareBBarracks", "Base", 3000, "Barracks (Field Variant)"],
				["Land_Mil_Barracks_i", "Base", 3500, "Barracks (City Variant)"],
				["RU_WarfareBLightFactory", "Base", 9000, "Light Factory"],
				["RU_WarfareBHeavyFactory", "Base", 25000, "Heavy Factory"],
				["RU_WarfareBAircraftFactory", "Base", 31000, "Aircraft Factory"],
				["RU_WarfareBVehicleServicePoint", "Base", 4000, "Vehicle Service Point"],
				["RU_WarfareBUAVterminal", "Base", 4000, "Radio Terminal"],
				["PowGen_Big", "Base", 1000, "Diesel Power Generator"],

				["RU_WarfareBFieldhHospital", "Respawn Points", 1000, "Field Hospital"],

				["Land_tent_east", "Storage", 100, "Small Tent"],
				["Land_Ind_Garage01", "Storage", 500, "Small Garage"],
				["Land_Ind_Workshop01_02", "Storage", 600, "Small Workshop"],
				["Land_Barn_W_02", "Storage", 600, "Short Barn"],
				["Land_Ind_Workshop01_04", "Storage", 700, "Old Workshop"],
				["Land_Barn_W_01", "Storage", 800, "Long Barn"],
				["Land_Hangar_2", "Storage", 1000, "Large Hangar w/ Doors"],
				["WarfareBAirport", "Storage", 2500, "Large Hangar"],

				["KORD", "Active Defence", 250, "KORD Minitripod"],
				["KORD_high", "Active Defence", 275, "KORD"],
				["RU_WarfareBMGNest_PK", "Active Defence", 300, "MG Nest (PK)"],	
				["AGS_RU", "Active Defence", 700, "AGS-30"],
				["Igla_AA_pod_East", "Active Defence", 800, "AA IGLA Pod"],
				["Metis", "Active Defence", 800, "Metis AT-13"],
				["ZU23_Ins", "Active Defence", 900, "ZU-23"],
				["2b14_82mm", "Active Defence", 1000, "Podnos 2B14"],
				["D30_RU", "Active Defence", 1900, "D-30"],		
				["SearchLight_RUS", "Active Defence", 100, "Searchlight"],	

				["Land_CamoNet_EAST", "Passive Defence", 50, "Camo Net 1"],
				["Land_CamoNetB_EAST", "Passive Defence", 75, "Camo Net Big"],
				["Land_CamoNetVar_EAST", "Passive Defence", 50, "Camo Net 2"],
				["Land_fort_rampart", "Passive Defence", 50, "Rampart Element"],
				["Land_Hlidac_budka", "Passive Defence", 50, "Sentry Box"],
				["Land_fort_artillery_nest", "Passive Defence", 100, "Rampart (Nest)"],
				["Land_fortified_nest_small", "Passive Defence", 200, "Nest (Small)"],
				["Land_fortified_nest_big", "Passive Defence", 500, "Nest (Big)"],
				["Land_Fort_Watchtower", "Passive Defence", 525, "Fort"],
				["Land_Vysilac_FM", "Passive Defence", 600, "Tower"],
				["Land_Mil_Guardhouse", "Passive Defence", 1000, "Checkpoint"],
				["Land_Mil_ControlTower", "Passive Defence", 2000, "Control Tower"],

				["Fence_corrugated_plate", "Barriers", 20, "Fence 1"],
				["Fence_Ind_long", "Barriers", 20, "Fence 2"],		
				["Fort_RazorWire", "Barriers", 25, "Razor Wire"],
				["Hedgehog", "Barriers", 50, "Hedgehog"],
				["Hhedgehog_concrete", "Barriers", 75, "Small Concrete Hedgehog"],
				["Hhedgehog_concreteBig", "Barriers", 100, "Big Concrete Hedgehog"],
				["Fort_Barricade", "Barriers", 100, "Barricade from Garbage"],
				["Land_fort_bagfence_long", "Barriers", 25, "Sandbag - Long"],
				["Land_fort_bagfence_corner", "Barriers", 50, "Sandbag - Corner"],
				["Land_fort_bagfence_round", "Barriers", 50, "Sandbag - Round"],
				["Land_HBarrier1", "Barriers", 20, "Hesco x1"],
				["Land_HBarrier3", "Barriers", 60, "Hesco x3"],
				["Land_HBarrier5", "Barriers", 100, "Hesco x5"],
				["Land_HBarrier_large", "Barriers", 150, "Big Hesco x4"]

			]
		];

sleep 5.5;
_id = COIN_RU_MHQ getVariable "BIS_COIN_id";
_BIS_COIN_idAction = format ["BIS_COIN_action_%1",_id];
_action = player addAction ["Build", "data\scripts\coin_interface.sqf", COIN_RU_MHQ, 1, false];
player setVariable [_BIS_COIN_idAction, _action];
player removeAction 0; // number depends on current actions alreay added

---------- Post added at 01:43 ---------- Previous post was at 01:05 ----------

if i put sleep's into script, it doesnt init new CoIn while script is paused, so I must wait again 6-10 sec after script has ended... will be thinking how to override this...

Edited by McArcher

Share this post


Link to post
Share on other sites

I have found a better way to do it, but it needs double time (it reruns coin.sqf with coin module as a parameter and delets existing action from list; coin.sqf is is modified - has new coin_interface.sqf path). if anyone needs this, I can post it here.

Share this post


Link to post
Share on other sites

now I have a new problem. after I delete action of original initialization I initialize coin 2nd time to set new script path. All is ok, but one thing.... I don't understand is it your coin_interface.sqf causing it, or my reinitialization, but after i purchase a building, money is showing as they should, decreased. but in some seconds (10-20) they are at old value, as if didn't buy anything! very strange...

---------- Post added at 04:56 ---------- Previous post was at 04:44 ----------

ahaha, i have found an error in your script, MH6 :D

you forgot (or did it on purpose?) to

publicvariable _itemFunds;
as it is done in original script....

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
Sign in to follow this  

×