Jump to content
Snipes Murphy

[Tutorial] Placeable Objects as Police

Recommended Posts

Translated By: Snipes Murphy

Difficulty: Medium 

Credit To: Altis Dev

I'll take that person Maximum who make its code to 3.1.4.8. Functional for 4.x.

First, let's go Mpmissions \ Altis_life.Altis \ Function.h

Below

class Dialog_Controls  
	{  
		file = "dialog\function";  
		class setMapPosition {};  
		class displayHandler {};  
		class spawnConfirm {};  
		class spawnMenu {};  
		class spawnPointCfg {};  
		class spawnPointSelected {};  
		class progressBar {};  
		class impoundMenu {};  
		class unimpound {};  
		class sellGarage {};  
		class bankDeposit {};  
		class bankWithdraw {};  
		class bankTransfer {};  
		class garageLBChange {};  
		class safeInventory {};  
		class safeOpen {};  
		class safeTake {};  
		class safeFix {};  
		class vehicleGarage {};  
		class gangDeposit {};  
		class wireTransfer {};  
		class insureCar{};  
	};

Add this:

class CopPlaceables	{  
	file = "core\cop\placeables";  
	class placeablesInit {};  
	class placeablesMenu {};  
	class placeablesRemoveAll {};  
	class placeablePlace {};  
	class placeableCancel {};  
	class placeablesPlaceComplete {};  
};

Then go to core \ cop and create a new folder will be called "placeables"
And in this case we will add 6 sqf files.
Let's start with the "fn_placeablesInit.sqf" file, add this one are: (Here you can change the object name in quotes and the object itself)

/*   
	Author: Maximum  
	Description: Placeables for the cop\medic sides.  
	Disclaimer: Don't be a asshole and pass this off as your own or become a KAI and sell it for profit, Im releasing this for FREE… Credits: Killerty69 for a second pare of eyes when mine got to sleepy  
	P.S. - Don't be a faggot like i know some of you all will be.  
*/  
life_barrier_active = false;  
life_barrier_activeObj = ObjNull;  
life_placeables = [  
	[ "Cone", "RoadCone_F"],  
	[ "Cone White Light", "RoadCone_L_F"],  
	[ "Road Sign", "SignAd_Sponsor_F"],  
	[ "Fence", "Land_BarGate_F"],  
	[ "Fence truck", "Land_Crash_barrier_F"],  
	[ "Fence Orange plastic", "PlasticBarrier_03_orange_F"],  
	[ "Fence yellow plastic", "PlasticBarrier_02_yellow_F"],  
	[ "Single Lamp", "Land_PortableLight_single_F"],  
	[ "Dual Lamp", "Land_PortableLight_double_F"],  
	[ "From the UN flag", "Flag_UNO_F"]  
];  
life_bar_limit = 2500;  
life_bar_placey = [];

Then continue to create our files, with this one "fn placeable Menu.sqf", adding that it will:

/*   
	Author: Maximum  
	Description: Placeables for the cop\medic sides.  
	Disclaimer: Don't be a asshole and pass this off as your own or become a KAI and sell it for profit, Im releasing this for FREE... Credits: Killerty69 for a second pare of eyes when mine got to sleepy  
	P.S. - Don't be a faggot like i know some of you all will be.  
*/  
disableSerialization;  

createDialog "life_cop_placeables";  
waitUntil { !isNull(findDisplay 20000) };  
_display = findDisplay 20000;  
_placeables = _display displayCtrl 20001;  
lbClear _placeables;  

{      
	_name = _x select 0;  
    _className = _x select 1;  
    _placeables lbAdd _name;  
    _placeables lbSetData [(lbSize _placeables) - 1, _className];  
} foreach (life_placeables);

Create "fn placeable RemoveAll.sqf", add this:

/*   
	Author: Maximum  
	Description: Placeables for the cop\medic sides.  
	Disclaimer: Don't be a asshole and pass this off as your own or become a KAI and sell it for profit, Im releasing this for FREE... Credits: Killerty69 for a second pare of eyes when mine got to sleepy  
	P.S. - Don't be a faggot like i know some of you all will be.  
*/  
{  
	deleteVehicle _x;  
} forEach (life_bar_placey);  

Create "fn_placeablePlace.sqf", add this:

/*   
	Author: Maximum  
	Description: Placeables for the cop\medic sides.  
	Disclaimer: Don't be a asshole and pass this off as your own or become a KAI and sell it for profit, Im releasing this for FREE... Credits: Killerty69 for a second pare of eyes when mine got to sleepy  
	P.S. - Don't be a faggot like i know some of you all will be.  
*/  
disableSerialization;  
if (count life_bar_placey >= life_bar_limit) exitWith { hint "You've reached the limit of objects you can place."; };  
_display = findDisplay 20000;  
_placeables = _display displayCtrl 20001;  
_className = lbData[20001, lbCurSel (20001)];  
closeDialog 0;  
life_barrier_active = true;  
_allowMoveDistance = 50;  
_object = _className createVehicle (position player);  
life_barrier_activeObj = _object;  
_attachPos = [0, 3, 0.5];  
_object attachTo[player, _attachPos];  
_object enableSimulationGlobal false;  
_originalPos = position _object;  
_playerOriginalPos = position player;  

waitUntil{  
	if (life_barrier_activeObj distance _originalPos > _allowMoveDistance || player distance _playerOriginalPos > _allowMoveDistance) then {  
		[true] call life_fnc_placeableCancel;  
    };  
    sleep 1;  
    !life_barrier_active;  
};  

Create "fn_placeableCancel.sqf", add this:

/*   
	Author: Maximum  
	Description: Placeables for the cop\medic sides.  
	Disclaimer: Don't be a asshole and pass this off as your own or become a KAI and sell it for profit, Im releasing this for FREE... Credits: Killerty69 for a second pare of eyes when mine got to sleepy  
	P.S. - Don't be a faggot like i know some of you all will be.  
*/  
if (!life_barrier_active) exitWith {}; //bad check?  
deleteVehicle life_barrier_activeObj;  
life_barrier_active = false;  
life_barrier_activeObj = ObjNull; 

To finish create "fn placeable Complete.sqf Place", add this:

/*   
	Author: Maximum  
	Description: Placeables for the cop\medic sides.  
	Disclaimer: Don't be a asshole and pass this off as your own or become a KAI and sell it for profit, Im releasing this for FREE... Credits: Killerty69 for a second pare of eyes when mine got to sleepy  
	P.S. - Don't be a faggot like i know some of you all will be.  
*/  
disableSerialization;  
if (!life_barrier_active) exitWith {};  
if (life_barrier_activeObj == ObjNull) exitWith {};  

_currentPos = getPosATL life_barrier_activeObj;  
detach life_barrier_activeObj;  
life_barrier_activeObj setPos[(getPos life_barrier_activeObj select 0), (getPos life_barrier_activeObj select 1), 0];  
life_barrier_activeObj enableSimulationGlobal true;  
life_bar_placey pushBack life_barrier_activeObj;  
life_barrier_active = false;  
life_barrier_activeObj = ObjNull;  

Then go to dialog \ Master Handler.h, e Added: (after another)

#include "placeables.hpp"  

Also in the file dialog, create the "placeables.hpp" File, Add it:

class Life_Cop_Placeables {  
	idd = 20000;  
    name= "life_cop_placeables";  
    movingEnable = false;  
    enableSimulation = true;  
    onLoad = "";  

	class controlsBackground {  
		class Life_RscTitleBackground: Life_RscText {  
			colorBackground[] = {"(profilenamespace getvariable ['GUI_BCG_RGB_R',0.3843])", "(profilenamespace getvariable ['GUI_BCG_RGB_G',0.7019])", "(profilenamespace getvariable ['GUI_BCG_RGB_B',0.8862])", "(profilenamespace getvariable ['GUI_BCG_RGB_A',0.7])"};  
			idc = -1;  
			x = 0.1;  
			y = 0.2;  
			w = 0.6;  
			h = (1 / 25);  
		};  

		class MainBackground: Life_RscText {  
			colorBackground[] = {0, 0, 0, 0.7};  
			idc = -1;  
			x = 0.1;  
			y = 0.2 + (11 / 250);  
			w = 0.6;  
			h = 0.6 - (22 / 250);  
		};  
    };  

	class controls {  
		class Title : Life_RscTitle {  
			colorBackground[] = {0, 0, 0, 0};  
			idc = -1;  
			text = "Available placeables";  
			x = 0.1;  
			y = 0.2;  
			w = 0.6;  
			h = (1 / 25);  
		};  

		class PlaceablesList : Life_RscListBox {  
			idc = 20001;  
			text = "";  
			sizeEx = 0.035;  
			x = 0.12;  
			y = 0.26;  
			w = 0.56;  
			h = 0.370;  
		};  

		class CloseButtonKey : Life_RscButtonMenu {  
			idc = -1;  
			text = "$STR_Global_Close";  
			onButtonClick = "closeDialog 0;";  
			x = -0.06 + (6.25 / 40) + (1 / 250 / (safezoneW / safezoneH));  
			y = 0.8 - (1 / 25);  
			w = (6.25 / 40);  
			h = (1 / 25);  
		};  

		class RemoveAll : life_RscButtonMenu {  
			idc = -1;  
			text = "Remove all";  
			onButtonClick = "[] call life_fnc_placeablesRemoveAll";  
			x = 0.1 + (6.25 / 40) + (1 / 250 / (safezoneW / safezoneH));  
			y = 0.8 - (1 / 25);  
			w = (6.25 / 40);  
			h = (1 / 25);  
		};  

		class Place : Life_RscButtonMenu {  
			idc = -1;  
			text = "Place";  
			colorBackground[] = {"(profilenamespace getvariable ['GUI_BCG_RGB_R',0.3843])", "(profilenamespace getvariable ['GUI_BCG_RGB_G',0.7019])", "(profilenamespace getvariable ['GUI_BCG_RGB_B',0.8862])", 0.5};  
			onButtonClick = "[] spawn life_fnc_placeablePlace;";  
			x = 0.32;  
			y = 0.69;  
			w = (6.25 / 40);  
			h = (1 / 25);  
		};  
    };  
};

Then still in the same folder, enter the file and add player_inv.hpp after that:

class ButtonSyncData : life_RscButtonMenu {  
			idc = -1;  
			//shortcuts[] = {0x00050000 + 2};  
			text = "$STR_PM_SyncData";  
			onButtonClick = "[] call SOCK_fnc_syncData;";  
			x = 0.1;  
			y = 0.805;  
			w = (6.25 / 40);  
			h = (1 / 25);  
		}; 

Add this:

class ButtonPlaceables: Life_RscButtonMenu {  
	idc = 20003;  
	text = "Placeables";  
	onButtonClick = "[] spawn life_fnc_placeablesMenu; closeDialog 0;";  
	//x = 0.26 + (6.25 / 19.8) + (1 / 250 / (safezoneW / safezoneH));  
	x = 0.42 + (6.25 / 19.8) + (1 / 250 / (safezoneW / safezoneH));  
	y = 0.801;  
	w = (6.25 / 40);  
	h = (1 / 25);  
};  

Then go to Core \ pmenu \ fn_p_openMenu.sqf and add

ctrlShow[20003,false];  

For Civ and Independent box (for those that can)
Like this :

switch(playerSide) do {  
	case west: {  
		ctrlShow[2011,false];	  
	};  

	case civilian: {  
		ctrlShow[2012,false];  
		ctrlShow[20003,false]; //<--- ajouter ici  
	};  
};  

It's nearly finished
Go to your fn_initCop.sqf in Core
And add (at the end)

[] spawn life_fnc_placeablesInit;  

And finally go to Core \ Function \ KeyHandler.sqf
Go right at the end and add:

case 46	: {  
            _currentPos = getPosATL life_barrier_activeObj;  
            detach life_barrier_activeObj;  
            life_barrier_activeObj setPos[(getPos life_barrier_activeObj select 0), (getPos life_barrier_activeObj select 1), 0];  
            life_barrier_activeObj enableSimulationGlobal true;  
            life_bar_placey pushBack life_barrier_activeObj;  
            life_barrier_active = false;  
            life_barrier_activeObj = ObjNull;  
            hint "Vous avez placé l'objet !";  
   	}; 

** For box 46 (the C key) If you want to change the letter, go here ** https: //community.bistudio.com/wiki/DIK_KeyCodes
And choose a letter not yet defined by basic BOHEMIA, for example (the R key is to recharge = impossible to define it as one)
Well, that's it for me!
** I hope it was understandable to you! Thanking you! **

 

lE0xi5n.jpg

Edited by Snipes Murphy
  • Like 1

Share this post


Link to post
Share on other sites
On 2016-09-27 at 4:56 AM, Snipes Murphy said:

Then still in the same folder, enter the file and add player_inv.hpp after that:

class ButtonSyncData : life_RscButtonMenu {  
			idc = -1;  
			//shortcuts[] = {0x00050000 + 2};  
			text = "$STR_PM_SyncData";  
			onButtonClick = "[] call SOCK_fnc_syncData;";  
			x = 0.1;  
			y = 0.805;  
			w = (6.25 / 40);  
			h = (1 / 25);  
		}; 

Add this:

class ButtonPlaceables: Life_RscButtonMenu {  
	idc = 20003;  
	text = "Placeables";  
	onButtonClick = "[] spawn life_fnc_placeablesMenu; closeDialog 0;";  
	//x = 0.26 + (6.25 / 19.8) + (1 / 250 / (safezoneW / safezoneH));  
	x = 0.42 + (6.25 / 19.8) + (1 / 250 / (safezoneW / safezoneH));  
	y = 0.801;  
	w = (6.25 / 40);  
	h = (1 / 25);  
};  

What folder/file is that going in? Should I create player_inv.hpp?

Share this post


Link to post
Share on other sites
On 11/30/2016 at 5:14 AM, Hugo. K said:

What folder/file is that going in? Should I create player_inv.hpp?

you do not need to create it, it already is there in "Altis_Life.Altis\dialog". The file is player_inv.hpp and he is telling you to add:

 

class ButtonPlaceables: Life_RscButtonMenu {  
	idc = 20003;  
	text = "Placeables";  
	onButtonClick = "[] spawn life_fnc_placeablesMenu; closeDialog 0;";  
	//x = 0.26 + (6.25 / 19.8) + (1 / 250 / (safezoneW / safezoneH));  
	x = 0.42 + (6.25 / 19.8) + (1 / 250 / (safezoneW / safezoneH));  
	y = 0.801;  
	w = (6.25 / 40);  
	h = (1 / 25);  
};  

After:

class ButtonSyncData : life_RscButtonMenu {  
			idc = -1;  
			//shortcuts[] = {0x00050000 + 2};  
			text = "$STR_PM_SyncData";  
			onButtonClick = "[] call SOCK_fnc_syncData;";  
			x = 0.1;  
			y = 0.805;  
			w = (6.25 / 40);  
			h = (1 / 25);  
		}; 

 

Share this post


Link to post
Share on other sites

can someone add a button so you can remove the one item your looking at instead of removing all? 

Also, how do you cancel placing one.

Edited by ToxicRageTv

Share this post


Link to post
Share on other sites
On 2017-5-7 at 11:50 AM, zMatthew said:

When I click on object I have error:

Look at this

 

It's your battleye filters, check server\Arma3Config\battleye\CreateVehicle.log and add it into the battleye filters .txt

  • Like 1

Share this post


Link to post
Share on other sites

Hey my friend
    When I add the code to the player_inv.hpp file, it comes out in civilians and cops.

Do not show the Placeable menu on the Citizen.
How do I change the code?

Share this post


Link to post
Share on other sites
_copPLC = "deleteVehicle cursorTarget;"; 
[] spawn compile _copPLC; 
cutText ["Placeable Target Removed!", "PLAIN"];

For deleting a target, create a new function

Edited by Nipvu
added button, enhanced deleting

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×