Jump to content
Killerknight

[Tutorial] New trunk

Recommended Posts

Edit by Deadlesszombie:

Author: Basti | John Collins for Eisenschmiede-Gaming

 

*********************************************************************************************

Hey Guys, today i want to share my trunk with all of u and how to install it

*********************************************************************************************

to start things of here are some information about it:

The trunk has 2 new buttons one to take all (as much as possible) one to store all ( as much as possible)

it has ha new layout, and yea, it is not the best but yea go with it, design is not my strongest 

It will look like this:

20170322230724_1.thumb.jpg.b80fc142e2c543dc6b1dd2fa2a548cd1.jpg

*********************************************************************************************

Tested in versions:

5.0.0

4.4.1

*********************************************************************************************

first we need to Edit the menu so go to dialog/trunk.hpp and replace everythin with my code

Spoiler

 

class TrunkMenu
{
	idd = 3500;
	name = "TrunkMenu";
	movingEnable = 0;
	enableSimulation = 1;
	
	class controlsBackground
	{

		
		class MainBackground: Life_RscText
		{
			idc = -1;
			x = 0.237031 * safezoneW + safezoneX;
			y = 0.230556 * safezoneH + safezoneY;
			w = 0.520781 * safezoneW;
			h = 0.594 * safezoneH;
			colorBackground[] = {-1,-1,-1,0.6};
		};

		class BG: Life_RscText
		{
			idc = -1;
			x = 0.23651 * safezoneW + safezoneX;
			y = 0.22963 * safezoneH + safezoneY;
			w = 0.520781 * safezoneW;
			h = 0.055 * safezoneH;
			colorBackground[] = {-1,-1,-1,0.7};
		};

		class RscTitleText: Life_RscTitle
		{
			idc = 3501;
			text = "";
			x = 0.236979 * safezoneW + safezoneX;
			y = 0.233334 * safezoneH + safezoneY;
			w = 0.520781 * safezoneW;
			h = 0.055 * safezoneH;
		};

		class VehicleWeight: RscTitleText
		{
			idc = 3504;
			style = 1;
			text = "";
		};

		class RscTrunkText: Life_RscText
		{
			idc = -1;
			text = "$STR_Trunk_TInventory";
			sizeEx = 0.04;

			x = 0.242187 * safezoneW + safezoneX;
			y = 0.302 * safezoneH + safezoneY;
			w = 0.232031 * safezoneW;
			h = 0.033 * safezoneH;
			colorBackground[] = {-1,-1,-1,0.7};
		};

		class RscPlayerText: Life_RscText
		{
			idc = -1;
			text = "$STR_Trunk_PInventory";
			sizeEx = 0.04;
			x = 0.515469 * safezoneW + safezoneX;
			y = 0.302 * safezoneH + safezoneY;
			w = 0.232031 * safezoneW;
			h = 0.033 * safezoneH;
			colorBackground[] = {-1,-1,-1,0.7};
		};
	};
	class Controls
	{
		class TrunkGear: Life_RscListbox
		{
			idc = 3502;
			text = "";
			sizeEx = 0.030;

			x = 0.242187 * safezoneW + safezoneX;
			y = 0.346 * safezoneH + safezoneY;
			w = 0.232031 * safezoneW;
			h = 0.363 * safezoneH;
		};

		class PlayerGear: Life_RscListbox
		{
			idc = 3503;
			text = "";
			sizeEx = 0.030;

			x = 0.515469 * safezoneW + safezoneX;
			y = 0.346 * safezoneH + safezoneY;
			w = 0.232031 * safezoneW;
			h = 0.363 * safezoneH;
		};

		class TrunkEdit: Life_RscEdit
		{
			idc = 3505;
			text = "1";
			sizeEx = 0.030;

			x = 0.242187 * safezoneW + safezoneX;
			y = 0.72 * safezoneH + safezoneY;
			w = 0.0979687 * safezoneW;
			h = 0.022 * safezoneH;
		};

		class PlayerEdit: Life_RscEdit
		{
			idc = 3506;
			text = "1";
			sizeEx = 0.030;
			x = 0.649531 * safezoneW + safezoneX;
			y = 0.72 * safezoneH + safezoneY;
			w = 0.0979687 * safezoneW;
			h = 0.022 * safezoneH;
		};

		class TakeItem: Life_RscButtonMenu
		{
			idc = -1;
			text = "Take";
			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 = "[] call Life_fnc_vehTakeItem;";

			x = 0.345312 * safezoneW + safezoneX;
			y = 0.72 * safezoneH + safezoneY;
			w = 0.128906 * safezoneW;
			h = 0.033 * safezoneH;
		};

		class StoreItem: Life_RscButtonMenu
		{
			idc = -1;
			text = "Store";
			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 = "[] call Life_fnc_vehStoreItem;";

			x = 0.515469 * safezoneW + safezoneX;
			y = 0.72 * safezoneH + safezoneY;
			w = 0.128906 * safezoneW;
			h = 0.033 * safezoneH;
		};
		
		class TakeAllItem: Life_RscButtonMenu
		{
			idc = -1;
			text = "Take all";
			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 = "[] call Life_fnc_vehTakeAllItem;";

			x = 0.345312 * safezoneW + safezoneX;
			y = 0.76 * safezoneH + safezoneY;
			w = 0.128906 * safezoneW;
			h = 0.033 * safezoneH;
		};
		
		class StoreAllItem: Life_RscButtonMenu
		{
			idc = -1;
			text = "Store all";
			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 = "[] call Life_fnc_vehStoreAllItem;";

			x = 0.515469 * safezoneW + safezoneX;
			y = 0.76 * safezoneH + safezoneY;
			w = 0.128906 * safezoneW;
			h = 0.033 * safezoneH;
		};

		class ButtonClose: Life_RscButtonMenu
		{
			idc = -1;
			//shortcuts[] = {0x00050000 + 2};
			text = "$STR_Global_Close";
			onButtonClick = "closeDialog 0;";
			
			x = 0.237031 * safezoneW + safezoneX;
			y = 0.83 * safezoneH + safezoneY;
			w = 0.108281 * safezoneW;
			h = 0.033 * safezoneH;
			tooltip = "Close"; //--- ToDo: Localize;
		};
	};
};

 

that done we go to our functions.hpp / functions.h in the root directory nad add unter class vehicle the following:

class vehTakeAllItem {};
class vehStoreAllItem {};

so it should look like this

Spoiler
class Vehicle {
        file = "core\vehicle";
        class vehTakeAllItem {};
        class vehStoreAllItem {};
        class addVehicle2Chain {};
        class colorVehicle {};
        class deviceMine {};
        class FuelRefuelcar {};
        class fuelStore {};
        class fuelSupply {};
        class lockVehicle {};
        class openInventory {};
        class vehiclecolor3DRefresh {};
        class vehicleOwners {};
        class vehicleWeight {};
        class vehInventory {};
        class vehStoreItem {};
        class vehTakeItem {};
        class vInteractionMenu {};
    };

 

 

next of we go in the directory core/vehicle and create 2 new sqf files the first one:

fn_vehStoreAllItem.sqf:

Spoiler
#include "..\..\script_macros.hpp"
#define ctrlSelData(ctrl) (lbData[##ctrl,(lbCurSel ##ctrl)])
/*
	File: fn_vehStoreAllItem.sqf
	Author: Killerknight
	
	Description:
	stores all (max items) from selected and add it to the Vehicles inventory
*/
private["_ctrl","_num","_totalWeight","_itemWeight","_veh_data","_inv","_index","_val"];

if(!DarfEinzahlen) exitWith {[localize "STR_NOTF_Trunk_Store_Stop",true,"fast","orange","Error"]spawn Life_fnc_msg;};
if(DarfEinzahlen) then {
	DarfEinzahlen = false;
	[] spawn {
		sleep 1;
		DarfEinzahlen = true;
	};
};

disableSerialization;

_ctrl = ctrlSelData(3503);
if ((lbCurSel ((findDisplay 3500) displayCtrl 3503)) isEqualTo -1)exitWith {["Du musst zuerst etwas auswählen.",true,"fast","orange","Error"]spawn Life_fnc_msg;};
if(Life_trunk_vehicle isKindOf "House_F") then {
	_mWeight = 0;
	{_mWeight = _mWeight + ([(typeOf _x)] call Life_fnc_vehicleWeightCfg);} foreach (Life_trunk_vehicle getVariable["containers",[]]);
	_totalWeight = [_mWeight,(Life_trunk_vehicle getVariable["Trunk",[[],0]]) select 1];
} else {
	_totalWeight = [Life_trunk_vehicle] call Life_fnc_vehicleWeight;
};
_num2 = getNumber(missionConfigFile >> "VirtualItems" >> _ctrl >> "weight");
_num1 = (floor (((_totalWeight select 0) - (_totalWeight select 1)) / _num2));
_num = if (_num1 <= (ITEM_VALUE(_ctrl))) then {_num1}else{(ITEM_VALUE(_ctrl))};
if(_num < 1) exitWith {["Du hast kein Platz dafür.",true,"fast","orange","Error"]spawn Life_fnc_msg;};
_itemWeight = ([_ctrl] call Life_fnc_itemWeight) * _num;
_veh_data = Life_trunk_vehicle getVariable ["Trunk",[[],0]];
_inv = _veh_data select 0;

if(_ctrl == "goldbar" && {!(Life_trunk_vehicle isKindOf "LandVehicle" OR Life_trunk_vehicle isKindOf "House_F")}) exitWith {["Du kannst dieses Item nur in Landfahrzeuge einlagern.",true,"fast","orange","Error"]spawn Life_fnc_msg;};

if(_ctrl == "money") then
{
	_index = [_ctrl,_inv] call TON_fnc_index;
	if(Life_cash < _num) exitWith {["Du hast nicht so viel Geld zum einlagern.",true,"fast","orange","Error"]spawn Life_fnc_msg;};
	if(_index == -1) then
	{
		_inv pushBack [_ctrl,_num];
	}
		else
	{
		_val = _inv select _index select 1;
		_inv set[_index,[_ctrl,_val + _num]];
	};
	
	Life_cash = Life_cash - _num;
	Life_trunk_vehicle setVariable["Trunk",[_inv,(_veh_data select 1) + _itemWeight],true];
	[Life_trunk_vehicle] call Life_fnc_vehInventory;
}
	else
{
	if(((_totalWeight select 1) + _itemWeight) > (_totalWeight select 0)) exitWith {["Das Fahrzeug ist voll.",true,"fast","orange","Error"]spawn Life_fnc_msg;};

	if(!([false,_ctrl,_num] call Life_fnc_handleInv)) exitWith {["Konnte das Item nicht umlagern.",true,"fast","orange","Error"]spawn Life_fnc_msg;};
	_index = [_ctrl,_inv] call TON_fnc_index;
	if(_index isEqualTo -1) then
	{
		_inv pushBack [_ctrl,_num];
	}
		else
	{
		_val = _inv select _index select 1;
		_inv set[_index,[_ctrl,_val + _num]];
	};
	
	Life_trunk_vehicle setVariable["Trunk",[_inv,(_veh_data select 1) + _itemWeight],true];
	[Life_trunk_vehicle] call Life_fnc_vehInventory;
};

 

and  fn_vehTakeAllItem.sqf:

Spoiler
#include "..\..\script_macros.hpp"
#define ctrlSelData(ctrl) (lbData[##ctrl,(lbCurSel ##ctrl)])
/*
	File: fn_vehTakeAllItem.sqf
	Author: Killerknight
	
	Description:
	Take all (max items) from selected and add it to the players inventory
*/
private["_ctrl","_num","_index","_data","_old","_value","_weight","_diff"];

if(!DarfEinzahlen) exitWith {[localize "STR_NOTF_Trunk_Store_Stop",true,"fast","orange","Error"]spawn Life_fnc_msg;};
if(DarfEinzahlen) then {
	DarfEinzahlen = false;
	[] spawn {
		sleep 1;
		DarfEinzahlen = true;
	};
};

disableSerialization;
if(isNull Life_trunk_vehicle OR !alive Life_trunk_vehicle) exitWith {[localize "STR_MISC_VehDoesntExist",true,"fast","orange","Error"]spawn Life_fnc_msg;};
if(!alive player) exitwith {closeDialog 0;};

if((lbCurSel 3502) == -1) exitWith {[localize "STR_Global_NoSelection",true,"fast","orange","Error"]spawn Life_fnc_msg;};
_ctrl = ctrlSelData(3502);
_config = configName (missionConfigFile >> "VirtualItems" >> _ctrl);
_num2 = getNumber(missionConfigFile >> "VirtualItems" >> _config  >> "weight");
_num1 = (floor (((Life_maxWeight) - (Life_carryWeight)) / _num2));
_num = if (_num1 <= ((((Life_trunk_vehicle getVariable "Trunk") select 0) select (lbCurSel 3502)) select 1)) then {_num1}else{((((Life_trunk_vehicle getVariable "Trunk") select 0) select (lbCurSel 3502)) select 1)};
if(_num < 1) exitWith {["Du hast kein Platz dafür.",true,"fast","orange","Error"]spawn Life_fnc_msg;};

_index = [_ctrl,((Life_trunk_vehicle getVariable "Trunk") select 0)] call TON_fnc_index;
_data = (Life_trunk_vehicle getVariable "Trunk") select 0;
_old = Life_trunk_vehicle getVariable "Trunk";
if(_index == -1) exitWith {};
_value = _data select _index select 1;
if(_num > _value) exitWith {[localize "STR_MISC_NotEnough",true,"fast","orange","Error"]spawn Life_fnc_msg;};
_num = [_ctrl,_num,Life_carryWeight,Life_maxWeight] call Life_fnc_calWeightDiff;
if(_num == 0) exitWith {[localize "STR_NOTF_InvFull",true,"fast","orange","Error"]spawn Life_fnc_msg;};
_weight = ([_ctrl] call Life_fnc_itemWeight) * _num;
if(_ctrl == "money") then {
	if(_num == _value) then {
		_data set[_index,-1];
		_data = _data - [-1];
	} else {
		_data set[_index,[_ctrl,(_value - _num)]];
	};
	
	Life_cash = Life_cash + _num;
	Life_trunk_vehicle setVariable["Trunk",[_data,(_old select 1) - _weight],true];
	[Life_trunk_vehicle] call Life_fnc_vehInventory;
} else {
	if([true,_ctrl,_num] call Life_fnc_handleInv) then {
		if(_num == _value) then {
			_data set[_index,-1];
			_data = _data - [-1];
		} else {
			_data set[_index,[_ctrl,(_value - _num)]];
		};
		Life_trunk_vehicle setVariable["Trunk",[_data,(_old select 1) - _weight],true];
		[Life_trunk_vehicle] call Life_fnc_vehInventory;
	} else {
		[localize "STR_NOTF_InvFull",true,"fast","orange","Error"]spawn Life_fnc_msg;
	};
};

 

 

so with this done it should work, if i forgot something please let me know below

 

Edited by Deadlesszombie
  • Like 9

Share this post


Link to post
Share on other sites
On 22/03/2017 at 6:54 PM, Hyper4u.'<3 said:

Screenshot?

Are you kidding me? Quoting the fist gigantic post to ask for a screenshot! Plz dude edit your post and remove the quote! People keep quoting the first post with the gigantic tutorial all the time without a good reason to do so in every freaking thread and because of this they make every comment page of the thread itself a hell to scroll down! You don't need to quote the first post to ask for a fix, you don't need to quote the first post to complain about something, you don't need to quote the first post to thank the author and etc! If you need to quote the first post to report a problem with the code and\or to add a fix, just quote the part that matters.

Edited by xShARkx
  • Like 1

Share this post


Link to post
Share on other sites
50 minutes ago, xShARkx said:

Are you kidding me? Quoting the fist gigantic post to ask for a screenshot! Plz dude edit your post and remove the quote! People keep quoting the first post with the gigantic tutorial all the time without a good reason to do so in every freaking thread and because of this they make every comment page of the thread itself a hell to scroll down! You don't need to quote the first post to ask for a fix, you don't need to quote the first post to complain about something, you don't need to quote the first post to thank the author and etc! If you need to quote the first post to report a problem with the code and\or to add a fix, just quote the part that matters.

you mad bro?

  • Like 1

Share this post


Link to post
Share on other sites
1 hour ago, Hyper4u.'<3 said:

you mad bro?


No, he's correct. It's very irritating when people quote an entire tutorial. Just tag the person if you want attention.

  • Like 1

Share this post


Link to post
Share on other sites
12 hours ago, Killerknight said:

 

@xShARkx i´ve contacted an admin, so now the coments are clean again, thanks for your contribute :)

 

10 hours ago, Dark said:


No, he's correct. It's very irritating when people quote an entire tutorial. Just tag the person if you want attention.

 

3 hours ago, Snipes Murphy said:

@Dark +1 that i literally just hate that. 

 

Yeah, it's retarded! Seriously, they should make a rule in this forum against that or disable the freaking first post quote in every thread! Freaking morons that can't think a little before doing something, about how their actions will affect shit! They keep doing this all the time, just like here(ask for a screenshot) for no good reason! If you need to get the attention of the developer of the script of someone in the thread, then tag him using "@".

This makes every comment page in every thread a freaking hell to scroll down! Not only that but it also fucks up people that are looking for useful fixes or enchantments\new features added by the author or others in the comments of the thread, because that people are in the "automatic" search mode, looking for posts with code in them while they are scrolling the thread and then they spot a post with code in it but when they look closely its just a quote from first post but even so they keep scrolling down until the end of it because maybe by the end of the quote you will find useful shit, but 90% of the time are just morons thanking the author, reporting problems and asking for trivial shit.

C'mon forums have been around for a long time already, use your head and use it properly!

Edited by xShARkx

Share this post


Link to post
Share on other sites
12 hours ago, xShARkx said:

 

 

 

Yeah, it's retarded! Seriously, they should make a rule in this forum against that or disable the freaking first post quote in every thread! Freaking morons that can't think a little before doing something, about how their actions will affect shit! They keep doing this all the time, just like here(ask for a screenshot) for no good reason! If you need to get the attention of the developer of the script of someone in the thread, then tag him using "@".

This makes every comment page in every thread a freaking hell to scroll down! Not only that but it also fucks up people that are looking for useful fixes or enchantments\new features added by the author or others in the comments of the thread, because that people are in the "automatic" search mode, looking for posts with code in them while they are scrolling the thread and then they spot a post with code in it but when they look closely its just a quote from first post but even so they keep scrolling down until the end of it because maybe by the end of the quote you will find useful shit, but 90% of the time are just morons thanking the author, reporting problems and asking for trivial shit.

C'mon forums have been around for a long time already, use your head and use it properly!

Look like a isolate situation, just report it silently and we gonna fix it.

 

Not a reason for add more toxic convo on the forum, dont take that personnal just say.

 

Thank for you contribution, we probably gonna use that T menu in us server.

 

Cheers!

Share this post


Link to post
Share on other sites
3 hours ago, MoNtEcRiStO© said:

Look like a isolate situation, just report it silently and we gonna fix it.

 

Not a reason for add more toxic convo on the forum, dont take that personnal just say.

 

Thank for you contribution, we probably gonna use that T menu in us server.

 

Cheers!

Isolate situation? No it's not, at least not that much! Indeed it's better now but a few weeks, months ago, in every thread and their comments pages in the script section you had this problem!

Quick example that it's not an isolated situation:

I hardly take anything personal so also don't take this personal but to me what is toxic is that this retarded thing(retarded first post quotes for no good reason) happens again and again and again. Another cancer is people posting their rtp logs in their post itself instead of using pastebin or others services a like.

I think that my posts and the others posts here in this thread about this "problem" should be deleted because this subject is not related anyhow to the objective of this thread that is to share a script with a new trunk for AL.

Anyways thanks :)

Edited by xShARkx

Share this post


Link to post
Share on other sites
On 2017-03-24 at 4:16 PM, Dark said:


No, he's correct. It's very irritating when people quote an entire tutorial. Just tag the person if you want attention.

triggered

Share this post


Link to post
Share on other sites

basically it looks like it works, but i get erros in client rpt that i would like to get rid off

 

13:42:33 Error in expression < (((life_maxWeight) - (life_carryWeight)) / _num2));
_num = if (_num1 <= ((((life_t>
13:42:33   Error position: </ _num2));
_num = if (_num1 <= ((((life_t>
13:42:33   Error Zero divisor
13:42:33 File core\vehicle\fn_vehTakeAllItem.sqf [life_fnc_vehTakeAllItem], line 29

 

Edited by cappino

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

×