Jump to content
npmproductions13

Virtual Garage Custom List not working for BIS_fnc_garage

Recommended Posts

I cannot seem to get the custom/filtered list working for the BIS_fnc_garage function.

The documentation for the function does not seem to work when I add the BIS_fnc_garage_data which takes an array of whitelisted vehicles.

 

Official Docs: https://community.bistudio.com/wiki/BIS_fnc_garage

 

Here is my code:

Spoiler

 


_garageObject = param[0];
_garageObject addaction [ "<t color='#FF0000'>Edit Vehicle</t>",{

BIS_fnc_garage_center = vehicle player;

uinamespace setvariable ["bis_fnc_garage_defaultClass", typeOf vehicle player ];

["Open",true] call BIS_fnc_garage; 

BIS_fnc_garage_data = [
	[
		"\a3\soft_f\offroad_01\offroad_01_unarmed_f",
		[
			gettext (configfile >> "cfgvehicles" >> "O_MRAP_02_gmg_F" >> "model")
		],
		"\a3\soft_f\mrap_02\mrap_02_gmg_f",
		[
            [ ( configFile >> 'cfgVehicles' >> 'O_MRAP_02_gmg_F' ) ]
		]
	]
];

h = [] spawn {
	waitUntil { isNull ( uinamespace getvariable ["BIS_fnc_arsenal_cam",objnull] ) };
	BIS_fnc_garage_data = nil;
    hint "Should be nil now";
};

}, [], 1, true, true, "", "!( isNull cursortarget ) "];

 

I put this together with an example from Larow and the documentation if memory serves me right. Any help with getting this working would be appreciated. 👍

Share this post


Link to post
Share on other sites

two things I notice:

1) You are setting the data after the Garage is already open. try executing BIS_fnc_garage_data = ... before ["Open"] call BIS_fnc_garage

2) You are opening an unlimited Garage by passing the second parameter "true". Try ["Open"] call BIS_fnc_garage instead

Share this post


Link to post
Share on other sites

Thanks for the comment 7erra. I've actually spotted that error and corrected these after making my initial post but have the same result.

 

My most recent code is

Spoiler

_garageObject = param[0];
_garageObject addaction [ "<t color='#FF0000'>Edit Vehicle</t>",{

BIS_fnc_garage_center = vehicle player;

//hint "Opened?";
//sleep 5;

BIS_fnc_garage_data = [
	//CARS
	[
		//model
		"\a3\soft_f\offroad_01\offroad_01_unarmed_f",
		//config paths of classes that use above model
		[
			( configfile >> "CfgVehicles" >> "C_Offroad_01_F" )
		],
		gettext (configfile >> "CfgVehicles" >> "O_MRAP_02_gmg_F" >> "model"),
		[
			( configfile >> "CfgVehicles" >> "O_MRAP_02_gmg_F" )
		]
	],
	[],
	[],
	[],
	[],
	[]
];

		
uinamespace setvariable ["bis_fnc_garage_defaultClass", typeOf vehicle player ];
missionnamespace setvariable ["bis_fnc_garage_data", BIS_fnc_garage_data];

["Open", false] call BIS_fnc_garage;

h = [] spawn {
	waitUntil { isNull ( uinamespace getvariable ["BIS_fnc_arsenal_cam",objnull] ) };
	BIS_fnc_garage_data = nil;
    hint "Should be nil now";
};

}, [], 1, true, true, "", "!( isNull vehicle player ) "];

 

 

Any other ideas as to why this isn't working?

Share this post


Link to post
Share on other sites

Looking at the function you can also do this:

["Open", [false, _center]] call BIS_fnc_garage;

where the second param is the center you currently set with "BIS_fnc_garage_center = vehicle player;"

Also no need to set the global variables twice (global_var = value and missionNamespace setVariable ["global_var", value] are the same, capitalization doesn't matter)

 

Have you tried using the example from the biki to see if it works?

Share this post


Link to post
Share on other sites

Thanks again 7erra! I actually didn't know that globals targeted with missionNamespace setVariable was the same as global_var = x so thanks for giving me that insight.

 

I've tried every example found at https://community.bistudio.com/wiki/BIS_fnc_garage with no joy.

I also found an old thread that has or had a similar problem and I tried using the code found there by Larrow to no avail either.

 

That can be found here: 

 

 

I have updated my code but still the entire list filled with every vehicle is visible. Not quite sure what I'm doing wrong here.

Spoiler

_garageObject = param[0];
_garageObject addaction [ "<t color='#FF0000'>Edit Vehicle</t>",{

//make center where the current players vehicle is. (Check to make sure player in vehicle will be added later).
_center = vehicle player;

BIS_fnc_garage_data = [
	//CARS
	[
		//model
		"\a3\soft_f\offroad_01\offroad_01_unarmed_f",
		//config paths of classes that use above model
		[
			( configfile >> "CfgVehicles" >> "C_Offroad_01_F" )
		],
		gettext (configfile >> "CfgVehicles" >> "O_MRAP_02_gmg_F" >> "model"),
		[
			( configfile >> "CfgVehicles" >> "O_MRAP_02_gmg_F" )
		]
	],
	[],
	[],
	[],
	[],
	[]
];

["Open", [false, _center]] call BIS_fnc_garage;

h = [] spawn {
	waitUntil { isNull ( uinamespace getvariable ["BIS_fnc_arsenal_cam",objnull] ) };
	BIS_fnc_garage_data = nil;
    hint "Should be nil now";
};

}, [], 1, true, true, "", "!( isNull vehicle player ) "];

 

 

Edited by npmproductions13
Accidentally posted and left out details.

Share this post


Link to post
Share on other sites

Waste of time. Bis_fnc_Garage is a broken function.

If you want to spawn a unique type of vehicle,... just spawn it with createVehicle.
For applying textures or appearances, use commands like setObjectTextureGlobal . You can add an action for choices on it, but that's a lot of work at this point.

 

You can try something like that:

MGI_VEH_TEXTURE = ["<t color='#ff9922'>Change texture</t>",
  {
    params ["_veh","_plyr","_id"];
   	(_veh getVariable ["Texture_params",[]]) params ["_possTextures","_nameTextures"];
    private ["_txtSubMenu","_nameTexture","_texture"];
    _veh setVariable ["MGI_submenuforTextures",TRUE];
    for "_i" from 0 to (count _possTextures -1) do {
      _nameTexture = _nameTextures #_i;
      _txtSubMenu = format ["<t color='#ff9921'>texture: %1</t>",_nameTexture];
      _texture = _possTextures #_i;
      _veh addAction [_txtSubMenu,
        {
          params ["_veh","_plyr","_id","_texture"];
          {_veh setObjectTextureGlobal [_forEachIndex,_x]} forEach _texture;
          _veh setVariable ["MGI_submenuforTextures",FALSE];
        },
        _texture,12,FALSE,TRUE,"",
        "_target getVariable ['MGI_submenuforTextures',FALSE]"
      ];
    };
    private _timer = diag_tickTime;
    waitUntil {uisleep 0.5; !(_veh getVariable ["MGI_submenuforTextures",FALSE]) or diag_tickTime > _timer +10};
    _veh setVariable ["MGI_submenuforTextures",FALSE];
    {_veh removeAction _x} count (actionIDs _veh select {"'#ff9921'>texture" in (_veh actionParams _x)#0});
  },nil,12,FALSE,FALSE,"",
  "!(_target getVariable ['MGI_submenuforTextures',FALSE]) && _this in _target"
];



then, a trigger alpha (SP) or a code for spawning a vehicle (here a SUV):

0 = [] spawn {
  private _veh = createVehicle ["C_SUV_01_F", player getPos [10,getDir player],[],0,"none"];
  private _textArray = configProperties [(configOf _veh / "TextureSources"),"isClass _x",false];
  private _possTextures = +_textArray apply {getArray (_x/ "textures") apply {toLowerANSI (_x select [if (_x select [0] == "\") then [{1},{0}]])}};
  private _nameTextures = +_textArray apply {getText (_x/ "displayName")};
  _veh setVariable ["Texture_params",[_possTextures,_nameTextures]];
  if (count _possTextures >1) then {  
    _veh addAction MGI_VEH_TEXTURE;
  };
};


You can change the texture when inside the vehicle.

Share this post


Link to post
Share on other sites

Really!! It's a broken function and I wasted all my time trying to get it fixed 😠

 

Thanks for the insight into how to get the workaround working, I don't think I will be able to do what I wanted to do.

I will give your script a try though.

 

Cheers for the help both of you 😁👍

Share this post


Link to post
Share on other sites

Would it be possible or too much to ask you to add some comments to your solutions. I'm curious how each line works.

I can tell that the _veh vehicles config file is scanned or searched for but can't seem to reverse engineer it by moving though the config viewer.

Share this post


Link to post
Share on other sites
1 hour ago, npmproductions13 said:

Would it be possible or too much to ask you to add some comments to your solutions. I'm curious how each line works.

I can tell that the _veh vehicles config file is scanned or searched for but can't seem to reverse engineer it by moving though the config viewer.

 

Action's array (in init.sqf or trigger set to TRUE)

MGI_VEH_TEXTURE = ["<t color='#ff9922'>Change texture</t>",    // this is the first addAction for a menu when player is inside the spawned vehicle

{ params ["_veh","_plyr","_id"];

(_veh getVariable ["Texture_params",[]]) params ["_possTextures","_nameTextures"]; // passing an array specific to the vehicle

private ["_txtSubMenu","_nameTexture","_texture"];

_veh setVariable ["MGI_submenuforTextures",TRUE]; // just for managing the second step of addactions (with textures' names or back if any choice aftet 10 sec.)

for "_i" from 0 to (count _possTextures -1) do { // textures loop for menus

_nameTexture = _nameTextures #_i;

_txtSubMenu = format ["<t color='#ff9921'>texture: %1</t>",_nameTexture]; // specific action menu title for each textures

_texture = _possTextures #_i;

_veh addAction [_txtSubMenu, { params ["_veh","_plyr","_id","_texture"]; // specific action menu for each textures

{_veh setObjectTextureGlobal [_forEachIndex,_x]} forEach _texture; // applying texture if the action is chosen

_veh setVariable ["MGI_submenuforTextures",FALSE]; // resetting for main menu (1st action menu "change texture")

}, _texture, // passed parameter _texture (see addAction in BIKI)

12,FALSE,TRUE,"",

"_target getVariable ['MGI_submenuforTextures',FALSE]"  // condition (so true) for displaying the sub menus

];

};

private _timer = diag_tickTime; // timer for 1st cond. (need to get back to 1st menu if the player doesn't choose anything)

waitUntil {uisleep 0.5; !(_veh getVariable ["MGI_submenuforTextures",FALSE]) or diag_tickTime > _timer +10}; // timer's end or player's any choice

_veh setVariable ["MGI_submenuforTextures",FALSE]; // resets

{_veh removeAction _x} count (actionIDs _veh select {"'#ff9921'>texture" in (_veh actionParams _x)#0}); // delete all actions then sub menu lines

},nil,12,FALSE,FALSE,"",

"!(_target getVariable ['MGI_submenuforTextures',FALSE]) && _this in _target" // condition for 1st menu (variable && player inside vehicle)

];

 

I placed this following code in a radio trigger for SP preview. Choose your own way for spawning a vehicle...

0 = [] spawn {

private _veh = createVehicle ["C_SUV_01_F", player getPos [10,getDir player],[],0,"none"]; // create a SUV

private _textArray = configProperties [(configOf _veh / "TextureSources"),"isClass _x",false]; // pick the texture sources (classes) from cfgVehicles

private _possTextures = +_textArray apply {getArray (_x/ "textures") apply {toLowerANSI (_x select [if (_x select [0] == "\") then [{1},{0}]])}}; // transform the texture classes into their textures' array (from cfgVehicles) with potential issue for paths (some vehicles have a textures config returning elements like "\a3\...." some others return "a3\...." I needed to delete the first \ if any)

private _nameTextures = +_textArray apply {getText (_x/ "displayName")}; // get the display name of textures

_veh setVariable ["Texture_params",[_possTextures,_nameTextures]]; // pass that in variable for vehicle

if (count _possTextures >1) then { _veh addAction MGI_VEH_TEXTURE; // avoid that stuff if just one texture)

};

};

  • Thanks 1

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

×