nebulazerz 18 Posted July 18, 2016 I have had an addaction shop working for both gear and vehicles for a while now but those are ugly and players dont like them not to mention some of the trouble of having to keep track of action ids if you want them to not mess with your other addActions or HoldActions on players. So because of these issues with addaction shop menus I am switching over to a dialog UI. I have already created the UI but I am not exactly sure how to populate my lists with the vehicles I want my players to buy for the prices I want them to buy it for the same way I did my addaction shops. I will post what I have here and hopefully someone will be able to help me with this. Example of my old addAction Shop (path to get to prowler and spawning it): removeAllActions player; player AddAction ["<t color=""#DF7401"">" +"Cars/Trucks/Unarmed", "Classes\Blu\Vehicles\carMenu.sqf", "", 0, false, false, "", 'player distance (getPosATL vehMenuBluSpawn) < 5']; player AddAction ["<t color=""#DF7401"">" +"Armed/Technical", "Classes\Blu\Vehicles\techMenu.sqf", "", 0, false, false, "", 'player distance (getPosATL vehMenuBluSpawn) < 5']; player AddAction ["<t color=""#DF7401"">" +"APC", "Classes\Blu\Vehicles\APCMenu.sqf", "", 0, false, false, "", 'player distance (getPosATL vehMenuBluSpawn) < 5']; player AddAction ["<t color=""#DF7401"">" +"Tank", "Classes\Blu\Vehicles\TankMenu.sqf", "", 0, false, false, "", 'player distance (getPosATL vehMenuBluSpawn) < 5']; player AddAction ["<t color=""#DF7401"">" +"Heli", "Classes\Blu\Vehicles\heliMenu.sqf", "", 0, false, false, "", 'player distance (getPosATL vehMenuBluSpawn) < 5']; player AddAction ["<t color=""#DF7401"">" +"VTOL", "Classes\Blu\Vehicles\VTOLMenu.sqf", "", 0, false, false, "", 'player distance (getPosATL vehMenuBluSpawn) < 5']; player AddAction ["<t color=""#DF7401"">" +"Other", "Classes\Blu\Vehicles\otherMenu.sqf", "", 0, false, false, "", 'player distance (getPosATL vehMenuBluSpawn) < 5']; player AddAction ["<t color=""#000000"">" +"Exit", "Classes\menuExit.sqf", "", 0, false, false, "", 'player distance (getPosATL vehMenuBluSpawn) < 5']; removeAllActions player; player AddAction ["<t color=""#DF7401"">" +"Prowler Unarmed($500)", "Classes\Blu\Vehicles\Prowler\prowlerSpawn.sqf", "", 0, false, false, "", 'player distance (getPosATL vehMenuBluSpawn) < 5']; player AddAction ["<t color=""#DF7401"">" +"Offroad($400)", "Classes\Blu\Vehicles\Offroad\offroadSpawn.sqf", "", 0, false, false, "", 'player distance (getPosATL vehMenuBluSpawn) < 5']; player AddAction ["<t color=""#DF7401"">" +"ATV($100)", "Classes\Blu\Vehicles\ATV\ATV_Spawn.sqf", "", 0, false, false, "", 'player distance (getPosATL vehMenuBluSpawn) < 5']; player AddAction ["<t color=""#DF7401"">" +"HEMTT Transport ($5,000)", "Classes\Blu\Vehicles\HEMTT\HEMTT_T_Spawn.sqf", "", 0, false, false, "", 'player distance (getPosATL vehMenuBluSpawn) < 5']; player AddAction ["<t color=""#DF7401"">" +"HEMTT Transport Covered ($5,100)", "Classes\Blu\Vehicles\HEMTT\HEMTT_T_C_Spawn.sqf", "", 0, false, false, "", 'player distance (getPosATL vehMenuBluSpawn) < 5']; player AddAction ["<t color=""#000000"">" +"Back", "Classes\vehMenuBluSpawn.sqf", "", 0, false, false, "", 'player distance (getPosATL vehMenuBluSpawn) < 5']; disableSerialization; private["_positionA","_positionB","_positionC","_direction","_nearestTargetsA","_nearestTargetsB","_nearestTargetsC","_nearestTargetsAll","_scanArea"]; //Create Markers createMarker ["BluVehASpawnA",[3144.326,13558.014]]; "BluVehASpawnA" setMarkerType "Empty"; "BluVehASpawnA" setMarkerSize [2, 2]; createMarker ["BluVehASpawnB",[3164.017,13585.148]]; "BluVehASpawnB" setMarkerType "Empty"; "BluVehASpawnB" setMarkerSize [2, 2]; createMarker ["BluVehASpawnC",[3129.197,13519.111]]; "BluVehASpawnC" setMarkerType "Empty"; "BluVehASpawnC" setMarkerSize [2, 2]; //Check if the marker has any cars near it _positionA = getMarkerPos "BluVehASpawnA"; _positionB = getMarkerPos "BluVehASpawnB"; _positionC = getMarkerPos "BluVehASpawnC"; _scanArea = 10; _direction = 210; _nearestTargetsA = nearestObjects[_positionA,["landVehicle","Air","Ship"],_scanArea] select 0; _nearestTargetsB = nearestObjects[_positionB,["landVehicle","Air","Ship"],_scanArea] select 0; _nearestTargetsC = nearestObjects[_positionC,["landVehicle","Air","Ship"],_scanArea] select 0; //if the marker has no cars near it then spawn the new car with nothing in inventory if ((!isNil "_nearestTargetsA") and (!isNil "_nearestTargetsB") && (!isNil "_nearestTargetsC") ) then { hint " MATERIALIZATION AREA FULL "; removeAllactions player; }else{ _itemName= "Unarmed LSV"; _cost=500; // Detect who called the script _buyer = _this select 1; // Check how much money they have, if the value is not found set it to 0. _cash = _buyer getVariable["cash", 0]; // If they have enough money... if (_cash >= _cost) then { // Set their new balance to money - price. _balance = _cash - _cost; // Update their wallet with their new balance _buyer setVariable["cash", _balance, true]; [] call fnc_updateStats; hint format ["You Bought An %1 For $%2",_itemName,_cost]; //Create Vehicle _veh = createVehicle ["B_T_LSV_01_unarmed_F", getMarkerPos "BluVehASpawnA", ["BluVehASpawnB","BluVehASpawnC"], 0, "NONE"]; _veh setVariable ["BIS_enableRandomization", false]; _veh setDir _direction; clearWeaponCargoGlobal _veh; clearMagazineCargoGlobal _veh; clearItemCargoGlobal _veh; deleteMarker "BluVehASpawnA"; deleteMarker "BluVehASpawnB"; deleteMarker "BluVehASpawnC"; removeAllactions player; }else{ hint "Not enough money"; removeAllactions player; }; }; Can I populate the list on the left there the same way I have my addaction menu then when a vehicle is selected, a picture of the item is shown above the buy/sell buttons and its price/info is below the buy/sell button? I can now populate the list and even tell players a price, but it wont spawn a vehicle now and it will not take money from me. There is no error either. New UI So Far: #define true 1 #define false 0 class RscTUTVehDialog { idd=1601; movingEnable = false; enableSimulation = true; fadein=0; duration = 1e+011; fadeout=0; onLoad= ""; controlsBackground[]= { vehBack, vehFrame, RscHeaderBack, RscVehBack, RscVehInfoBack }; controls[]={ btnCancel, btnConfirm, RscVehList, vehStatText, serverTitleText, RscPlayerFlagLeft, btnLand, btnAir, btnSea }; objects[]={}; class vehBack: IGUIBack { idc = 0; x = 0 * safezoneW + safezoneX; y = 0 * safezoneH + safezoneY; w = 1 * safezoneW; h = 1 * safezoneH; colorBackground[] = {0.1,0.1,0.1,0.1}; }; class vehFrame: IGUIBack { idc = 1; x = 0.25 * safezoneW + safezoneX; y = 0.25 * safezoneH + safezoneY; w = 0.5 * safezoneW; h = 0.5 * safezoneH; colorBackground[] = {0.1,0.1,0.1,0.1}; }; class RscHeaderBack: IGUIBack { idc = 2; x = 0.255 * safezoneW + safezoneX; y = 0.2575 * safezoneH + safezoneY; w = 0.49 * safezoneW; h = 0.05 * safezoneH; colorBackground[] = {0.1,0.1,0.1,0.1}; }; class RscVehBack: IGUIBack { idc = 3; x = 0.255 * safezoneW + safezoneX; y = 0.3125 * safezoneH + safezoneY; w = 0.2425 * safezoneW; h = 0.4275 * safezoneH; colorBackground[] = {0.1,0.1,0.1,0.1}; }; class RscVehInfoBack: IGUIBack { idc = 4; x = 0.5025 * safezoneW + safezoneX; y = 0.355 * safezoneH + safezoneY; w = 0.2425 * safezoneW; h = 0.34 * safezoneH; colorBackground[] = {0.1,0.1,0.1,0.1}; }; class btnCancel: RscShortcutButton { idc = 5; text = "Cancel"; colorBackground[] = {0.5,0.5,0.5,0.5}; colorBackground2[] = {0.1,0.1,0.1,0.1}; colorBackgroundFocused[] = {0.1,0.1,0.1,1}; onButtonClick = "closeDialog 1601;"; x = 0.5025 * safezoneW + safezoneX; y = 0.7025 * safezoneH + safezoneY; w = 0.12 * safezoneW; h = 0.0375 * safezoneH; }; class btnConfirm: RscShortcutButton { idc = 6; text = "Confirm"; colorBackground[] = {0.5,0.5,0.5,0.5}; colorBackground2[] = {0.1,0.1,0.1,0.1}; colorBackgroundFocused[] = {0.1,0.1,0.1,1}; onButtonClick = "[] call TUT_gui_VehCreate;"; x = 0.625 * safezoneW + safezoneX; y = 0.7025 * safezoneH + safezoneY; w = 0.12 * safezoneW; h = 0.0375 * safezoneH; }; class RscVehList: RscListBox { idc = 7; onLBSelChanged = "[] spawn TUT_gui_VehInfo;"; colorText[] = {1,1,1,1}; colorDisabled[] = {1,1,1,0.25}; colorScrollbar[] = {1,0,0,0}; colorSelect[] = {1,1,1,1}; colorSelect2[] = {1,1,1,1}; colorSelectBackground[] = {0,0,0,0.5}; colorSelectBackground2[] = {0.1,0.1,0.1,0.1}; colorBackground[] = {0.1,0.1,0.1,0.1}; shadow = 0.75; x = 0.26 * safezoneW + safezoneX; y = 0.3225 * safezoneH + safezoneY; w = 0.2325 * safezoneW; h = 0.41 * safezoneH }; class vehStatText: RscStructuredText { idc = 8; colorText[] = {1,1,1,1}; colorBackground[] = {0.1,0.1,0.1,0.1}; shadow = 0.75; size = 0.037; x = 0.508 * safezoneW + safezoneX; y = 0.365 * safezoneH + safezoneY; w = 0.2325 * safezoneW; h = 0.32 * safezoneH onMouseButtonDown = ""; onMouseButtonUp = ""; onMouseZChanged = ""; text = ""; }; class serverTitleText: RscStructuredText { idc = 10; colorText[] = {1,1,1,1}; colorBackground[] = {0.1,0.1,0.1,0.1}; shadow = 0.75; x = 0.305 * safezoneW + safezoneX; y = 0.265 * safezoneH + safezoneY; w = 0.435 * safezoneW; h = 0.04 * safezoneH; onMouseButtonDown = ""; onMouseButtonUp = ""; onMouseZChanged = ""; text = ""; }; class RscPlayerFlagLeft: RscPicture { idc = 11; colorBackground[] = {0,0,0,1}; sizeEx = 0.1; text = ""; x = 0.2575 * safezoneW + safezoneX; y = 0.26 * safezoneH + safezoneY; w = 0.05 * safezoneW; h = 0.045* safezoneH; }; class btnLand: RscShortcutButton { idc = 12; text = "Land"; colorBackground[] = {0.5,0.5,0.5,0.5}; colorBackground2[] = {0.1,0.1,0.1,0.1}; colorBackgroundFocused[] = {0.1,0.1,0.1,1}; onButtonClick = "[] call TUT_fnc_OpenVehUI;"; x = 0.5025 * safezoneW + safezoneX; y = 0.3125 * safezoneH + safezoneY; w = 0.0775 * safezoneW; h = 0.0375 * safezoneH; }; class btnSea: RscShortcutButton { idc = 13; text = "Air"; colorBackground[] = {0.5,0.5,0.5,0.5}; colorBackground2[] = {0.1,0.1,0.1,0.1}; colorBackgroundFocused[] = {0.1,0.1,0.1,1}; onButtonClick = "[] call TUT_fnc_OpenVehUI;"; x = 0.585 * safezoneW + safezoneX; y = 0.3125 * safezoneH + safezoneY; w = 0.0775* safezoneW; h = 0.0375 * safezoneH; }; class btnAir: RscShortcutButton { idc = 14; text = "Other"; colorBackground[] = {0.5,0.5,0.5,0.5}; colorBackground2[] = {0.1,0.1,0.1,0.1}; colorBackgroundFocused[] = {0.1,0.1,0.1,1}; onButtonClick = "[] call TUT_fnc_OpenVehUI;"; x = 0.6675 * safezoneW + safezoneX; y = 0.3125 * safezoneH + safezoneY; w = 0.0775 * safezoneW; h = 0.0375 * safezoneH; }; }; TUT_fnc_OpenVehUI = { private ["_flag"]; disableSerialization; player action ["WeaponOnBack", player]; createDialog "RscTUTVehDialog"; [["Buy Prowler($500)", 1, 500, "B_T_LSV_01_unarmed_F"], ["Buy Hemtt($5,000)", 2, 5000, "B_Truck_01_transport_F"]] call TUT_gui_LoadVeh; _serverTitleCbo = ((findDisplay 1601) displayCtrl (10)); _plr = profileName; _title = "Vehicle Shop"; _serverTitleCbo ctrlSetStructuredText parseText format ["<t align='left'>%1</t><t align='right'>%2</t>",_plr,_title]; _plrClass = typeOf player; _side = getNumber(configFile >> "cfgVehicles" >> _plrClass>> "side"); _flagCbo = ((findDisplay 1601) displayCtrl (11)); switch (_side) do { case 0: {_flag = "\A3\Data_F\Flags\Flag_CSAT_CO.paa";}; case 1: {_flag = "\A3\Data_F\Flags\Flag_nato_CO.paa";}; case 2: {_flag = "\A3\Data_F\Flags\Flag_AAF_CO.paa";}; }; _flagCbo ctrlSetText _flag; }; TUT_gui_LoadVeh = { _cbo = ((findDisplay 1601) displayCtrl (7)); lbCLear _cbo; { _x params["_label", "_level", "_cost", "_class"]; _index = lbAdd [7, _label]; _cbo lbSetData[(lbSize _cbo)-1, _class]; _picture = (getText(configFile >> "cfgVehicles" >> _class >> "picture")); _cbo lbSetPicture[(lbSize _cbo)-1,_picture]; // add label, cost here? } forEach _this; }; TUT_gui_VehInfo = { private ["_weapArray","_class","_crewCount","_model","_maxSpeed","_invSpace","_armor"]; disableSerialization; _id = lbCurSel 7; _class = lbData [7, _id]; _weapons = []; _weaponsClass = getArray(configFile >> "cfgVehicles" >> _class >> "weapons"); { _name = getText (configFile >> "cfgWeapons" >> _x >> "displayName"); _weapons = _weapons + [ _name]; }forEach _weaponsClass; if (isClass (configFile >> "cfgVehicles" >> _class >> "Turrets" >> "M2_Turret")) then { _weapArray = getArray(configFile >> "cfgVehicles" >> _class >> "Turrets" >> "M2_Turret" >> "weapons"); } else { _weapArray = getArray(configFile >> "cfgVehicles" >> _class >> "Turrets" >> "MainTurret" >> "weapons"); _weapArray = _weapArray + (getArray(configFile >> "cfgVehicles" >> _class >> "Turrets" >> "FrontTurret" >> "weapons")); _weapArray = _weapArray + (getArray(configFile >> "cfgVehicles" >> _class >> "Turrets" >> "RearTurret" >> "weapons")); }; { _name = getText (configFile >> "cfgWeapons" >> _x >> "displayName"); _weapons = _weapons + [ _name]; }forEach _weapArray; _crewCount = [_class,true] call BIS_fnc_crewCount; _model = getText(configFile >> "cfgVehicles" >> _class >> "model"); _maxSpeed = getNumber(configFile >> "cfgVehicles" >> _class >> "maxSpeed"); _invSpace = getNumber(configFile >> "cfgVehicles" >> _class >> "maximumLoad"); _armor = getNumber(configFile >> "cfgVehicles" >> _class >> "armor"); _textCbo = ((findDisplay 1601) displayCtrl (8)); _separator = parseText "-------------------------------------------------------------------------------------"; _textCbo ctrlSetStructuredText parseText format ["<t align='left'>Weapons:</t><br/> <t align='left'>%1</t> <t align='left'>%6</t><br/> <t align='left'>Passengers:</t> <t align='right'>%2</t> <t align='left'>%6</t><br/> <t align='left'>Max Speed:</t> <t align='right'>%3</t> <t align='left'>%6</t><br/> <t align='left'>Inventory:</t> <t align='right'>%4</t> <t align='left'>%6</t><br/> <t align='left'>Armor:</t> <t align='right'>%5</t> <t align='left'>%6</t><br/>",_weapons,_crewCount,_maxSpeed,_invSpace,_armor, _separator]; }; TUT_gui_VehCreate = { _x params["_label", "_level", "_cost", "_class"]; _cash = player getVariable["cash", 0]; if (_level <= level) then { if (_cash >= _cost) then { // Set their new balance to money - price. _balance = _cash - _cost; // Update their wallet with their new balance player setVariable["cash", _balance, true]; [] call fnc_updateStats; _idVeh = lbCurSel 7; _classVeh = lbData [7, _idVeh]; _emptyPos = position player findEmptyPosition [5,50,_classVeh]; if (count _emptyPos == 0) then { hint "Vehicle cannot be spawned here"; } else { _veh = createVehicle [_classVeh, _emptyPos, [], 0,""]; }; closeDialog 1601; }else{ hint "Not Enough Money"; }; }else{ hint "Level Too Low"; }; }; Share this post Link to post Share on other sites
revide 33 Posted July 18, 2016 Take a look in the BI Wiki: Good starting points: https://community.bistudio.com/wiki/Category:Dialogs Maybe these https://community.bistudio.com/wiki/DialogControls-ListBoxes Or These https://community.bistudio.com/wiki/DialogControls-ControlsGroupfor more advanced stuff It's all possible, but very time intense with fiddeling around in the gui editor and scripting all the buttons and displays. I dont think someone does this for free for you. Share this post Link to post Share on other sites
nebulazerz 18 Posted July 18, 2016 Take a look in the BI Wiki: Good starting points: https://community.bistudio.com/wiki/Category:Dialogs Maybe these https://community.bistudio.com/wiki/DialogControls-ListBoxes Or These https://community.bistudio.com/wiki/DialogControls-ControlsGroupfor more advanced stuff It's all possible, but very time intense with fiddeling around in the gui editor and scripting all the buttons and displays. I dont think someone does this for free for you. I can do it all myself once I know where to start, Once it works for one vehicle it will be easy to replicate it from there. I need to be pointed in the right direction of where to start with making my own array to populate the left side. I will worry about the selling part after. I already have the UI part out of the way also, now its just the functions, i just dont know how to structure the array in the function for this yet. Edit: Basically, How do I translate this removeAllActions player; player AddAction ["<t color=""#DF7401"">" +"Cars/Trucks/Unarmed", "Classes\Blu\Vehicles\carMenu.sqf", "", 0, false, false, "", 'player distance (getPosATL vehMenuBluSpawn) < 5']; player AddAction ["<t color=""#DF7401"">" +"Armed/Technical", "Classes\Blu\Vehicles\techMenu.sqf", "", 0, false, false, "", 'player distance (getPosATL vehMenuBluSpawn) < 5']; player AddAction ["<t color=""#DF7401"">" +"APC", "Classes\Blu\Vehicles\APCMenu.sqf", "", 0, false, false, "", 'player distance (getPosATL vehMenuBluSpawn) < 5']; player AddAction ["<t color=""#DF7401"">" +"Tank", "Classes\Blu\Vehicles\TankMenu.sqf", "", 0, false, false, "", 'player distance (getPosATL vehMenuBluSpawn) < 5']; player AddAction ["<t color=""#DF7401"">" +"Heli", "Classes\Blu\Vehicles\heliMenu.sqf", "", 0, false, false, "", 'player distance (getPosATL vehMenuBluSpawn) < 5']; player AddAction ["<t color=""#DF7401"">" +"VTOL", "Classes\Blu\Vehicles\VTOLMenu.sqf", "", 0, false, false, "", 'player distance (getPosATL vehMenuBluSpawn) < 5']; player AddAction ["<t color=""#DF7401"">" +"Other", "Classes\Blu\Vehicles\otherMenu.sqf", "", 0, false, false, "", 'player distance (getPosATL vehMenuBluSpawn) < 5']; player AddAction ["<t color=""#000000"">" +"Exit", "Classes\menuExit.sqf", "", 0, false, false, "", 'player distance (getPosATL vehMenuBluSpawn) < 5']; into the box on the left but instead of add action, its filling the UI with text that can be double clicked or selected with a new button if easier. then will then go to the next menu until you get to your vehicle. then have it execute the scripts I already have. really not too much, just need to know how to structure my array in the function being used when calling this fnc_openVShop = { player action ["WeaponOnBack", player]; createDialog "RscVShopDialog"; }; Share this post Link to post Share on other sites
revide 33 Posted July 18, 2016 I can do it all myself once I know where to start, Once it works for one vehicle it will be easy to replicate it from there. I need to be pointed in the right direction of where to start with making my own array to populate the left side. I will worry about the selling part after. I already have the UI part out of the way also, now its just the functions, i just dont know how to structure the array in the function for this yet. You're NOT done with the UI part. If you really want the pics of vehicle showing and maybe an Add To Cart button you have to use the ControlsGroup and add a picture, price, name, etc. with structuredtext or multiple texts. It's not that easy as you probably think. The scripting part does not only involve how to fill an array, it involves the complete management of the currently selected item in the virtual List since you are not using ListBoxes but ControlGroups. You need to have add and remove functions for the cart, a checkout and so on. //Edit: You surely can "just" use the ListBox thing and add a bunch of vehicles, but then there is no real question on how to populate an array, since you can easy add an item to the box and give it some hidden parameters, like costs, type, etc. Then just get the current selected item on checkout and you're done Share this post Link to post Share on other sites
nebulazerz 18 Posted July 18, 2016 in this script this guy is calling his vehicles he is populating from cfgVehicles. Can I copy cfgVehicles and change the code to have variables and use it in my missionfile? I feel like this would be the simple solution. edit: I am basically trying to do it like this guys but instead of populating it from just the mass vehicle selection that BI has I want my own "cfgVehicle". does anyone know how its structured or where its located? edit2: also I am using this to make the UI to make things faster and easier TUT_fnc_OpenVehUI = { private ["_flag"]; disableSerialization; player action ["WeaponOnBack", player]; createDialog "RscTUTVehDialog"; ["Car"] call TUT_gui_LoadVeh; _serverTitleCbo = ((findDisplay 1601) displayCtrl (10)); _plr = profileName; _title = "VEHICLE SELECTOR TITLE"; _serverTitleCbo ctrlSetStructuredText parseText format ["<t align='left'>%1</t><t align='right'>%2</t>",_plr,_title]; _plrClass = typeOf player; _side = getNumber(configFile >> "cfgVehicles" >> _plrClass>> "side"); _flagCbo = ((findDisplay 1601) displayCtrl (11)); switch (_side) do { case 0: {_flag = "\A3\Data_F\Flags\Flag_CSAT_CO.paa";}; case 1: {_flag = "\A3\Data_F\Flags\Flag_nato_CO.paa";}; case 2: {_flag = "\A3\Data_F\Flags\Flag_AAF_CO.paa";}; }; _flagCbo ctrlSetText _flag; }; Share this post Link to post Share on other sites
nebulazerz 18 Posted July 18, 2016 I found this page on Config Replacement, I think theoretically I should be able to copy the entire cfgVehicles and recreate it for my needs and call it from the mission file. Can anyone confirm this as possible? Share this post Link to post Share on other sites
Grumpy Old Man 3546 Posted July 18, 2016 Why would you want to change the entire cfgVehicles? Why not just filter it via a function the way you want? No need for an addOn to do that. Better start out on some more basic stuff, things get a lot easier if you get a grasp for things before trying to do something like a vehicle shop with functions, ctrlEventHandlers and stuff. Cheers Share this post Link to post Share on other sites
nebulazerz 18 Posted July 18, 2016 Why would you want to change the entire cfgVehicles? Why not just filter it via a function the way you want? No need for an addOn to do that. Better start out on some more basic stuff, things get a lot easier if you get a grasp for things before trying to do something like a vehicle shop with functions, ctrlEventHandlers and stuff. Cheers I have done pretty much everything you could think of besides shop UI at this point and where I am at in my mission, this is what I need and is the current wall for finishing it. thanks for letting me know that would need an addon though. I just need to figure out arrays and I should be able to get this done with functions. Ill just keep watching tutorials until i figure it out. Share this post Link to post Share on other sites
nebulazerz 18 Posted July 19, 2016 I have some made some big progress. I can populate the list with only the vehicles I want and I can restrict the vehicle from showing up if you are not the right level (not exactly how i wanted it but its progress) but now It takes the money when I open the vehicle menu as if I have already paid for the vehicles then lets me spawn one of the two I have there without taking more money. I will post the rest of the code that came with this UI TUT_fnc_OpenVehUI = { private ["_flag"]; disableSerialization; player action ["WeaponOnBack", player]; createDialog "RscTUTVehDialog"; [["Buy Prowler($500)",1,500,"B_T_LSV_01_unarmed_F"], ["Buy Hemtt($5,000)",1,5000,"B_Truck_01_transport_F"]] call TUT_gui_LoadVeh; _serverTitleCbo = ((findDisplay 1601) displayCtrl (10)); _plr = profileName; _title = "VEHICLE SELECTOR TITLE"; _serverTitleCbo ctrlSetStructuredText parseText format ["<t align='left'>%1</t><t align='right'>%2</t>",_plr,_title]; _plrClass = typeOf player; _side = getNumber(configFile >> "cfgVehicles" >> _plrClass>> "side"); _flagCbo = ((findDisplay 1601) displayCtrl (11)); switch (_side) do { case 0: {_flag = "\A3\Data_F\Flags\Flag_CSAT_CO.paa";}; case 1: {_flag = "\A3\Data_F\Flags\Flag_nato_CO.paa";}; case 2: {_flag = "\A3\Data_F\Flags\Flag_AAF_CO.paa";}; }; _flagCbo ctrlSetText _flag; }; TUT_gui_LoadVeh = { _cbo = ((findDisplay 1601) displayCtrl (7)); lbCLear _cbo; { _x params["_label", "_level", "_cost", "_class"]; _cash = player getVariable["cash", 0]; if (_level <= level) then { if (_cash >= _cost) then { // Set their new balance to money - price. _balance = _cash - _cost; // Update their wallet with their new balance player setVariable["cash", _balance, true]; [] call fnc_updateStats; _index = _cbo lbAdd(getText(configFile >> "cfgVehicles" >> _class >> "displayName")); _cbo lbSetData[(lbSize _cbo)-1, _class]; _picture = (getText(configFile >> "cfgVehicles" >> _class >> "picture")); _cbo lbSetPicture[(lbSize _cbo)-1,_picture]; // add label, cost here? _cbo ctrlSetStructuredText parseText _label; }else{ hint "Not Enough Money"; }; }else{ hint "Level Too Low"; }; } forEach _this; }; TUT_gui_VehInfo = { private ["_weapArray","_class","_crewCount","_model","_maxSpeed","_invSpace","_armor"]; disableSerialization; _id = lbCurSel 7; _class = lbData [7, _id]; _weapons = []; _weaponsClass = getArray(configFile >> "cfgVehicles" >> _class >> "weapons"); { _name = getText (configFile >> "cfgWeapons" >> _x >> "displayName"); _weapons = _weapons + [ _name]; }forEach _weaponsClass; if (isClass (configFile >> "cfgVehicles" >> _class >> "Turrets" >> "M2_Turret")) then { _weapArray = getArray(configFile >> "cfgVehicles" >> _class >> "Turrets" >> "M2_Turret" >> "weapons"); } else { _weapArray = getArray(configFile >> "cfgVehicles" >> _class >> "Turrets" >> "MainTurret" >> "weapons"); _weapArray = _weapArray + (getArray(configFile >> "cfgVehicles" >> _class >> "Turrets" >> "FrontTurret" >> "weapons")); _weapArray = _weapArray + (getArray(configFile >> "cfgVehicles" >> _class >> "Turrets" >> "RearTurret" >> "weapons")); }; { _name = getText (configFile >> "cfgWeapons" >> _x >> "displayName"); _weapons = _weapons + [ _name]; }forEach _weapArray; _crewCount = [_class,true] call BIS_fnc_crewCount; _model = getText(configFile >> "cfgVehicles" >> _class >> "model"); _maxSpeed = getNumber(configFile >> "cfgVehicles" >> _class >> "maxSpeed"); _invSpace = getNumber(configFile >> "cfgVehicles" >> _class >> "maximumLoad"); _armor = getNumber(configFile >> "cfgVehicles" >> _class >> "armor"); _textCbo = ((findDisplay 1601) displayCtrl (8)); _separator = parseText "-------------------------------------------------------------------------------------"; _textCbo ctrlSetStructuredText parseText format ["<t align='left'>Weapons:</t><br/> <t align='left'>%1</t> <t align='left'>%6</t><br/> <t align='left'>Passengers:</t> <t align='right'>%2</t> <t align='left'>%6</t><br/> <t align='left'>Max Speed:</t> <t align='right'>%3</t> <t align='left'>%6</t><br/> <t align='left'>Inventory:</t> <t align='right'>%4</t> <t align='left'>%6</t><br/> <t align='left'>Armor:</t> <t align='right'>%5</t> <t align='left'>%6</t><br/>",_weapons,_crewCount,_maxSpeed,_invSpace,_armor, _separator]; }; TUT_gui_VehCreate = { _idVeh = lbCurSel 7; _classVeh = lbData [7, _idVeh]; _emptyPos = position player findEmptyPosition [5,50,_classVeh]; if (count _emptyPos == 0) then { hint "Vehicle cannot be spawned here"; } else { _veh = createVehicle [_classVeh, _emptyPos, [], 0,""]; }; closeDialog 1601; }; Share this post Link to post Share on other sites
Grumpy Old Man 3546 Posted July 19, 2016 You need a separate function being executed only when the buy button has been clicked and a vehicle has been selected. Remove all cash related stuff from your other functions. Cheers 1 Share this post Link to post Share on other sites
nebulazerz 18 Posted July 19, 2016 This will Show the correct prices and picture of the vehicle on the list but I still cant get them to spawn the vehicles and take my money. Is there a command to pass the array into the "confirm" function at the bottom of the page? Here is what I have as of right now #define true 1 #define false 0 class RscTUTVehDialog { idd=1601; movingEnable = false; enableSimulation = true; fadein=0; duration = 1e+011; fadeout=0; onLoad= ""; controlsBackground[]= { vehBack, vehFrame, RscHeaderBack, RscVehBack, RscVehInfoBack }; controls[]={ btnCancel, btnConfirm, RscVehList, vehStatText, serverTitleText, RscPlayerFlagLeft, btnLand, btnAir, btnSea }; objects[]={}; class vehBack: IGUIBack { idc = 0; x = 0 * safezoneW + safezoneX; y = 0 * safezoneH + safezoneY; w = 1 * safezoneW; h = 1 * safezoneH; colorBackground[] = {0.1,0.1,0.1,0.1}; }; class vehFrame: IGUIBack { idc = 1; x = 0.25 * safezoneW + safezoneX; y = 0.25 * safezoneH + safezoneY; w = 0.5 * safezoneW; h = 0.5 * safezoneH; colorBackground[] = {0.1,0.1,0.1,0.1}; }; class RscHeaderBack: IGUIBack { idc = 2; x = 0.255 * safezoneW + safezoneX; y = 0.2575 * safezoneH + safezoneY; w = 0.49 * safezoneW; h = 0.05 * safezoneH; colorBackground[] = {0.1,0.1,0.1,0.1}; }; class RscVehBack: IGUIBack { idc = 3; x = 0.255 * safezoneW + safezoneX; y = 0.3125 * safezoneH + safezoneY; w = 0.2425 * safezoneW; h = 0.4275 * safezoneH; colorBackground[] = {0.1,0.1,0.1,0.1}; }; class RscVehInfoBack: IGUIBack { idc = 4; x = 0.5025 * safezoneW + safezoneX; y = 0.355 * safezoneH + safezoneY; w = 0.2425 * safezoneW; h = 0.34 * safezoneH; colorBackground[] = {0.1,0.1,0.1,0.1}; }; class btnCancel: RscShortcutButton { idc = 5; text = "Cancel"; colorBackground[] = {0.5,0.5,0.5,0.5}; colorBackground2[] = {0.1,0.1,0.1,0.1}; colorBackgroundFocused[] = {0.1,0.1,0.1,1}; onButtonClick = "closeDialog 1601;"; x = 0.5025 * safezoneW + safezoneX; y = 0.7025 * safezoneH + safezoneY; w = 0.12 * safezoneW; h = 0.0375 * safezoneH; }; class btnConfirm: RscShortcutButton { idc = 6; text = "Confirm"; colorBackground[] = {0.5,0.5,0.5,0.5}; colorBackground2[] = {0.1,0.1,0.1,0.1}; colorBackgroundFocused[] = {0.1,0.1,0.1,1}; onButtonClick = "[] call TUT_gui_VehCreate;"; x = 0.625 * safezoneW + safezoneX; y = 0.7025 * safezoneH + safezoneY; w = 0.12 * safezoneW; h = 0.0375 * safezoneH; }; class RscVehList: RscListBox { idc = 7; onLBSelChanged = "[] spawn TUT_gui_VehInfo;"; colorText[] = {1,1,1,1}; colorDisabled[] = {1,1,1,0.25}; colorScrollbar[] = {1,0,0,0}; colorSelect[] = {1,1,1,1}; colorSelect2[] = {1,1,1,1}; colorSelectBackground[] = {0,0,0,0.5}; colorSelectBackground2[] = {0.1,0.1,0.1,0.1}; colorBackground[] = {0.1,0.1,0.1,0.1}; shadow = 0.75; x = 0.26 * safezoneW + safezoneX; y = 0.3225 * safezoneH + safezoneY; w = 0.2325 * safezoneW; h = 0.41 * safezoneH }; class vehStatText: RscStructuredText { idc = 8; colorText[] = {1,1,1,1}; colorBackground[] = {0.1,0.1,0.1,0.1}; shadow = 0.75; size = 0.037; x = 0.508 * safezoneW + safezoneX; y = 0.365 * safezoneH + safezoneY; w = 0.2325 * safezoneW; h = 0.32 * safezoneH onMouseButtonDown = ""; onMouseButtonUp = ""; onMouseZChanged = ""; text = ""; }; class serverTitleText: RscStructuredText { idc = 10; colorText[] = {1,1,1,1}; colorBackground[] = {0.1,0.1,0.1,0.1}; shadow = 0.75; x = 0.305 * safezoneW + safezoneX; y = 0.265 * safezoneH + safezoneY; w = 0.435 * safezoneW; h = 0.04 * safezoneH; onMouseButtonDown = ""; onMouseButtonUp = ""; onMouseZChanged = ""; text = ""; }; class RscPlayerFlagLeft: RscPicture { idc = 11; colorBackground[] = {0,0,0,1}; sizeEx = 0.1; text = ""; x = 0.2575 * safezoneW + safezoneX; y = 0.26 * safezoneH + safezoneY; w = 0.05 * safezoneW; h = 0.045* safezoneH; }; class btnLand: RscShortcutButton { idc = 12; text = "Land"; colorBackground[] = {0.5,0.5,0.5,0.5}; colorBackground2[] = {0.1,0.1,0.1,0.1}; colorBackgroundFocused[] = {0.1,0.1,0.1,1}; onButtonClick = "[] call TUT_fnc_OpenVehUI;"; x = 0.5025 * safezoneW + safezoneX; y = 0.3125 * safezoneH + safezoneY; w = 0.0775 * safezoneW; h = 0.0375 * safezoneH; }; class btnSea: RscShortcutButton { idc = 13; text = "Air"; colorBackground[] = {0.5,0.5,0.5,0.5}; colorBackground2[] = {0.1,0.1,0.1,0.1}; colorBackgroundFocused[] = {0.1,0.1,0.1,1}; onButtonClick = "[] call TUT_fnc_OpenVehUI;"; x = 0.585 * safezoneW + safezoneX; y = 0.3125 * safezoneH + safezoneY; w = 0.0775* safezoneW; h = 0.0375 * safezoneH; }; class btnAir: RscShortcutButton { idc = 14; text = "Other"; colorBackground[] = {0.5,0.5,0.5,0.5}; colorBackground2[] = {0.1,0.1,0.1,0.1}; colorBackgroundFocused[] = {0.1,0.1,0.1,1}; onButtonClick = "[] call TUT_fnc_OpenVehUI;"; x = 0.6675 * safezoneW + safezoneX; y = 0.3125 * safezoneH + safezoneY; w = 0.0775 * safezoneW; h = 0.0375 * safezoneH; }; }; TUT_fnc_OpenVehUI = { private ["_flag"]; disableSerialization; player action ["WeaponOnBack", player]; createDialog "RscTUTVehDialog"; [["Buy Prowler($500)", 1, 500, "B_T_LSV_01_unarmed_F"], ["Buy Hemtt($5,000)", 2, 5000, "B_Truck_01_transport_F"]] call TUT_gui_LoadVeh; _serverTitleCbo = ((findDisplay 1601) displayCtrl (10)); _plr = profileName; _title = "VEHICLE SELECTOR TITLE"; _serverTitleCbo ctrlSetStructuredText parseText format ["<t align='left'>%1</t><t align='right'>%2</t>",_plr,_title]; _plrClass = typeOf player; _side = getNumber(configFile >> "cfgVehicles" >> _plrClass>> "side"); _flagCbo = ((findDisplay 1601) displayCtrl (11)); switch (_side) do { case 0: {_flag = "\A3\Data_F\Flags\Flag_CSAT_CO.paa";}; case 1: {_flag = "\A3\Data_F\Flags\Flag_nato_CO.paa";}; case 2: {_flag = "\A3\Data_F\Flags\Flag_AAF_CO.paa";}; }; _flagCbo ctrlSetText _flag; }; TUT_gui_LoadVeh = { _cbo = ((findDisplay 1601) displayCtrl (7)); lbCLear _cbo; { _x params["_label", "_level", "_cost", "_class"]; _index = lbAdd [7, _label]; _cbo lbSetData[(lbSize _cbo)-1, _class]; _picture = (getText(configFile >> "cfgVehicles" >> _class >> "picture")); _cbo lbSetPicture[(lbSize _cbo)-1,_picture]; // add label, cost here? } forEach _this; }; TUT_gui_VehInfo = { private ["_weapArray","_class","_crewCount","_model","_maxSpeed","_invSpace","_armor"]; disableSerialization; _id = lbCurSel 7; _class = lbData [7, _id]; _weapons = []; _weaponsClass = getArray(configFile >> "cfgVehicles" >> _class >> "weapons"); { _name = getText (configFile >> "cfgWeapons" >> _x >> "displayName"); _weapons = _weapons + [ _name]; }forEach _weaponsClass; if (isClass (configFile >> "cfgVehicles" >> _class >> "Turrets" >> "M2_Turret")) then { _weapArray = getArray(configFile >> "cfgVehicles" >> _class >> "Turrets" >> "M2_Turret" >> "weapons"); } else { _weapArray = getArray(configFile >> "cfgVehicles" >> _class >> "Turrets" >> "MainTurret" >> "weapons"); _weapArray = _weapArray + (getArray(configFile >> "cfgVehicles" >> _class >> "Turrets" >> "FrontTurret" >> "weapons")); _weapArray = _weapArray + (getArray(configFile >> "cfgVehicles" >> _class >> "Turrets" >> "RearTurret" >> "weapons")); }; { _name = getText (configFile >> "cfgWeapons" >> _x >> "displayName"); _weapons = _weapons + [ _name]; }forEach _weapArray; _crewCount = [_class,true] call BIS_fnc_crewCount; _model = getText(configFile >> "cfgVehicles" >> _class >> "model"); _maxSpeed = getNumber(configFile >> "cfgVehicles" >> _class >> "maxSpeed"); _invSpace = getNumber(configFile >> "cfgVehicles" >> _class >> "maximumLoad"); _armor = getNumber(configFile >> "cfgVehicles" >> _class >> "armor"); _textCbo = ((findDisplay 1601) displayCtrl (8)); _separator = parseText "-------------------------------------------------------------------------------------"; _textCbo ctrlSetStructuredText parseText format ["<t align='left'>Weapons:</t><br/> <t align='left'>%1</t> <t align='left'>%6</t><br/> <t align='left'>Passengers:</t> <t align='right'>%2</t> <t align='left'>%6</t><br/> <t align='left'>Max Speed:</t> <t align='right'>%3</t> <t align='left'>%6</t><br/> <t align='left'>Inventory:</t> <t align='right'>%4</t> <t align='left'>%6</t><br/> <t align='left'>Armor:</t> <t align='right'>%5</t> <t align='left'>%6</t><br/>",_weapons,_crewCount,_maxSpeed,_invSpace,_armor, _separator]; }; TUT_gui_VehCreate = { _x params["_label", "_level", "_cost", "_class"]; _cash = player getVariable["cash", 0]; if (_level <= level) then { if (_cash >= _cost) then { // Set their new balance to money - price. _balance = _cash - _cost; // Update their wallet with their new balance player setVariable["cash", _balance, true]; [] call fnc_updateStats; _idVeh = lbCurSel 7; _classVeh = lbData [7, _idVeh]; _emptyPos = position player findEmptyPosition [5,50,_classVeh]; if (count _emptyPos == 0) then { hint "Vehicle cannot be spawned here"; } else { _veh = createVehicle [_classVeh, _emptyPos, [], 0,""]; }; closeDialog 1601; }else{ hint "Not Enough Money"; }; }else{ hint "Level Too Low"; }; }; Share this post Link to post Share on other sites
nebulazerz 18 Posted July 20, 2016 With Kylanias help I have 2 types of vehicle shops that let you buy vehicles and they work perfectly for what I need but I am wondering if anyone has a way to condense this down. Also there is a weird bug when I try to use a button on the GUI to switch back and forth between the Land and Air GUI. I can bring up either menu no problem with addaction as many times as I want and I can use the button to switch from Land to Air or Air to Land but once I try to go back to one from the other a second time, the UI bugs out and looks like this and wont work until I close the UI and re open it. Is there a way to condense this down to one .hpp or even one page of functions? Is there a way to use a button to switch between two different UI and back again without any bugs? Here is the working but buggy when switching menu via button code TUT_gui_veh.hpp #define true 1 #define false 0 class RscTUTVehDialog { idd=1601; movingEnable = false; enableSimulation = true; fadein=0; duration = 1e+011; fadeout=0; onLoad= ""; controlsBackground[]= { vehBack, vehFrame, RscHeaderBack, RscVehBack, RscVehInfoBack }; controls[]={ btnCancel, btnConfirm, RscVehList, vehStatText, serverTitleText, RscPlayerFlagLeft, btnLand, btnAir, btnOther }; objects[]={}; class vehBack: IGUIBack { idc = 0; x = 0 * safezoneW + safezoneX; y = 0 * safezoneH + safezoneY; w = 1 * safezoneW; h = 1 * safezoneH; colorBackground[] = {0.1,0.1,0.1,0.1}; }; class vehFrame: IGUIBack { idc = 1; x = 0.25 * safezoneW + safezoneX; y = 0.25 * safezoneH + safezoneY; w = 0.5 * safezoneW; h = 0.5 * safezoneH; colorBackground[] = {0.1,0.1,0.1,0.1}; }; class RscHeaderBack: IGUIBack { idc = 2; x = 0.255 * safezoneW + safezoneX; y = 0.2575 * safezoneH + safezoneY; w = 0.49 * safezoneW; h = 0.05 * safezoneH; colorBackground[] = {0.1,0.1,0.1,0.1}; }; class RscVehBack: IGUIBack { idc = 3; x = 0.255 * safezoneW + safezoneX; y = 0.3125 * safezoneH + safezoneY; w = 0.2425 * safezoneW; h = 0.4275 * safezoneH; colorBackground[] = {0.1,0.1,0.1,0.1}; }; class RscVehInfoBack: IGUIBack { idc = 4; x = 0.5025 * safezoneW + safezoneX; y = 0.355 * safezoneH + safezoneY; w = 0.2425 * safezoneW; h = 0.34 * safezoneH; colorBackground[] = {0.1,0.1,0.1,0.1}; }; class btnCancel: RscShortcutButton { idc = 5; text = "Cancel"; colorBackground[] = {0.5,0.5,0.5,0.5}; colorBackground2[] = {0.1,0.1,0.1,0.1}; colorBackgroundFocused[] = {0.1,0.1,0.1,1}; onButtonClick = "closeDialog 1601;"; x = 0.5025 * safezoneW + safezoneX; y = 0.7025 * safezoneH + safezoneY; w = 0.12 * safezoneW; h = 0.0375 * safezoneH; }; class btnConfirm: RscShortcutButton { idc = 6; text = "Confirm"; colorBackground[] = {0.5,0.5,0.5,0.5}; colorBackground2[] = {0.1,0.1,0.1,0.1}; colorBackgroundFocused[] = {0.1,0.1,0.1,1}; onButtonClick = "[] call TUT_gui_VehCreate;"; x = 0.625 * safezoneW + safezoneX; y = 0.7025 * safezoneH + safezoneY; w = 0.12 * safezoneW; h = 0.0375 * safezoneH; }; class RscVehList: RscListBox { idc = 7; onLBSelChanged = "[] spawn TUT_gui_VehInfo;"; colorText[] = {1,1,1,1}; colorDisabled[] = {1,1,1,0.25}; colorScrollbar[] = {1,0,0,0}; colorSelect[] = {1,1,1,1}; colorSelect2[] = {1,1,1,1}; colorSelectBackground[] = {0,0,0,0.5}; colorSelectBackground2[] = {0.1,0.1,0.1,0.1}; colorBackground[] = {0.1,0.1,0.1,0.1}; shadow = 0.75; x = 0.26 * safezoneW + safezoneX; y = 0.3225 * safezoneH + safezoneY; w = 0.2325 * safezoneW; h = 0.41 * safezoneH }; class vehStatText: RscStructuredText { idc = 8; colorText[] = {1,1,1,1}; colorBackground[] = {0.1,0.1,0.1,0.1}; shadow = 0.75; size = 0.037; x = 0.508 * safezoneW + safezoneX; y = 0.365 * safezoneH + safezoneY; w = 0.2325 * safezoneW; h = 0.32 * safezoneH onMouseButtonDown = ""; onMouseButtonUp = ""; onMouseZChanged = ""; text = ""; }; class serverTitleText: RscStructuredText { idc = 10; colorText[] = {1,1,1,1}; colorBackground[] = {0.1,0.1,0.1,0.1}; shadow = 0.75; x = 0.305 * safezoneW + safezoneX; y = 0.265 * safezoneH + safezoneY; w = 0.435 * safezoneW; h = 0.04 * safezoneH; onMouseButtonDown = ""; onMouseButtonUp = ""; onMouseZChanged = ""; text = ""; }; class RscPlayerFlagLeft: RscPicture { idc = 11; colorBackground[] = {0,0,0,1}; sizeEx = 0.1; text = ""; x = 0.2575 * safezoneW + safezoneX; y = 0.26 * safezoneH + safezoneY; w = 0.05 * safezoneW; h = 0.045* safezoneH; }; class btnLand: RscShortcutButton { idc = 12; text = "Land"; colorBackground[] = {0.4,0.4,0.4,1}; colorBackground2[] = {0.4,0.4,0.4,1}; colorBackgroundFocused[] = {0.4,0.4,0.4,1}; onButtonClick = ""; x = 0.5025 * safezoneW + safezoneX; y = 0.3125 * safezoneH + safezoneY; w = 0.0775 * safezoneW; h = 0.0375 * safezoneH; }; class btnAir: RscShortcutButton { idc = 13; text = "Air"; colorBackground[] = {0.4,0.4,0.4,1}; colorBackground2[] = {0.4,0.4,0.4,1}; colorBackgroundFocused[] = {0.4,0.4,0.4,1}; onButtonClick = "closeDialog 1601;[] call TUT_fnc_OpenAirVehUI;"; x = 0.585 * safezoneW + safezoneX; y = 0.3125 * safezoneH + safezoneY; w = 0.0775* safezoneW; h = 0.0375 * safezoneH; }; class btnOther: RscShortcutButton { idc = 14; text = "Other"; colorBackground[] = {0.4,0.4,0.4,1}; colorBackground2[] = {0.4,0.4,0.4,1}; colorBackgroundFocused[] = {0.4,0.4,0.4,1}; onButtonClick = ""; x = 0.6675 * safezoneW + safezoneX; y = 0.3125 * safezoneH + safezoneY; w = 0.0775 * safezoneW; h = 0.0375 * safezoneH; }; }; TUT_gui_veh_air.hpp #define true 1 #define false 0 class RscTUTVehAirDialog { idd=1602; movingEnable = false; enableSimulation = true; fadein=0; duration = 1e+011; fadeout=0; onLoad= ""; controlsBackground[]= { vehBackB, vehFrameB, RscHeaderBackB, RscVehBackB, RscVehInfoBackB }; controls[]={ btnCancelB, btnConfirmB, RscVehListB, vehStatTextB, serverTitleTextB, RscPlayerFlagLeftB, btnLandB, btnAirB, btnOtherB }; objects[]={}; class vehBackB: IGUIBack { idc = 0; x = 0 * safezoneW + safezoneX; y = 0 * safezoneH + safezoneY; w = 1 * safezoneW; h = 1 * safezoneH; colorBackground[] = {0.1,0.1,0.1,0.1}; }; class vehFrameB: IGUIBack { idc = 1; x = 0.25 * safezoneW + safezoneX; y = 0.25 * safezoneH + safezoneY; w = 0.5 * safezoneW; h = 0.5 * safezoneH; colorBackground[] = {0.1,0.1,0.1,0.1}; }; class RscHeaderBackB: IGUIBack { idc = 2; x = 0.255 * safezoneW + safezoneX; y = 0.2575 * safezoneH + safezoneY; w = 0.49 * safezoneW; h = 0.05 * safezoneH; colorBackground[] = {0.1,0.1,0.1,0.1}; }; class RscVehBackB: IGUIBack { idc = 3; x = 0.255 * safezoneW + safezoneX; y = 0.3125 * safezoneH + safezoneY; w = 0.2425 * safezoneW; h = 0.4275 * safezoneH; colorBackground[] = {0.1,0.1,0.1,0.1}; }; class RscVehInfoBackB: IGUIBack { idc = 4; x = 0.5025 * safezoneW + safezoneX; y = 0.355 * safezoneH + safezoneY; w = 0.2425 * safezoneW; h = 0.34 * safezoneH; colorBackground[] = {0.1,0.1,0.1,0.1}; }; class btnCancelB: RscShortcutButton { idc = 5; text = "Cancel"; colorBackground[] = {0.5,0.5,0.5,0.5}; colorBackground2[] = {0.1,0.1,0.1,0.1}; colorBackgroundFocused[] = {0.1,0.1,0.1,1}; onButtonClick = "closeDialog 1602;"; x = 0.5025 * safezoneW + safezoneX; y = 0.7025 * safezoneH + safezoneY; w = 0.12 * safezoneW; h = 0.0375 * safezoneH; }; class btnConfirmB: RscShortcutButton { idc = 6; text = "Confirm"; colorBackground[] = {0.5,0.5,0.5,0.5}; colorBackground2[] = {0.1,0.1,0.1,0.1}; colorBackgroundFocused[] = {0.1,0.1,0.1,1}; onButtonClick = "[] call TUT_gui_AirVehCreate;"; x = 0.625 * safezoneW + safezoneX; y = 0.7025 * safezoneH + safezoneY; w = 0.12 * safezoneW; h = 0.0375 * safezoneH; }; class RscVehListB: RscListBox { idc = 7; onLBSelChanged = "[] spawn TUT_gui_AirVehInfo;"; colorText[] = {1,1,1,1}; colorDisabled[] = {1,1,1,0.25}; colorScrollbar[] = {1,0,0,0}; colorSelect[] = {1,1,1,1}; colorSelect2[] = {1,1,1,1}; colorSelectBackground[] = {0,0,0,0.5}; colorSelectBackground2[] = {0.1,0.1,0.1,0.1}; colorBackground[] = {0.1,0.1,0.1,0.1}; shadow = 0.75; x = 0.26 * safezoneW + safezoneX; y = 0.3225 * safezoneH + safezoneY; w = 0.2325 * safezoneW; h = 0.41 * safezoneH }; class vehStatTextB: RscStructuredText { idc = 8; colorText[] = {1,1,1,1}; colorBackground[] = {0.1,0.1,0.1,0.1}; shadow = 0.75; size = 0.037; x = 0.508 * safezoneW + safezoneX; y = 0.365 * safezoneH + safezoneY; w = 0.2325 * safezoneW; h = 0.32 * safezoneH onMouseButtonDown = ""; onMouseButtonUp = ""; onMouseZChanged = ""; text = ""; }; class serverTitleTextB: RscStructuredText { idc = 10; colorText[] = {1,1,1,1}; colorBackground[] = {0.1,0.1,0.1,0.1}; shadow = 0.75; x = 0.305 * safezoneW + safezoneX; y = 0.265 * safezoneH + safezoneY; w = 0.435 * safezoneW; h = 0.04 * safezoneH; onMouseButtonDown = ""; onMouseButtonUp = ""; onMouseZChanged = ""; text = ""; }; class RscPlayerFlagLeftB: RscPicture { idc = 11; colorBackground[] = {0,0,0,1}; sizeEx = 0.1; text = ""; x = 0.2575 * safezoneW + safezoneX; y = 0.26 * safezoneH + safezoneY; w = 0.05 * safezoneW; h = 0.045* safezoneH; }; class btnLandB: RscShortcutButton { idc = 12; text = "Land"; colorBackground[] = {0.4,0.4,0.4,1}; colorBackground2[] = {0.4,0.4,0.4,1}; colorBackgroundFocused[] = {0.4,0.4,0.4,1}; onButtonClick = "closeDialog 1602;[] call TUT_fnc_OpenVehUI;"; x = 0.5025 * safezoneW + safezoneX; y = 0.3125 * safezoneH + safezoneY; w = 0.0775 * safezoneW; h = 0.0375 * safezoneH; }; class btnAirB: RscShortcutButton { idc = 13; text = "Air"; colorBackground[] = {0.4,0.4,0.4,1}; colorBackground2[] = {0.4,0.4,0.4,1}; colorBackgroundFocused[] = {0.4,0.4,0.4,1}; onButtonClick = ""; x = 0.585 * safezoneW + safezoneX; y = 0.3125 * safezoneH + safezoneY; w = 0.0775* safezoneW; h = 0.0375 * safezoneH; }; class btnOtherB: RscShortcutButton { idc = 14; text = "Other"; colorBackground[] = {0.4,0.4,0.4,1}; colorBackground2[] = {0.4,0.4,0.4,1}; colorBackgroundFocused[] = {0.4,0.4,0.4,1}; onButtonClick = ""; x = 0.6675 * safezoneW + safezoneX; y = 0.3125 * safezoneH + safezoneY; w = 0.0775 * safezoneW; h = 0.0375 * safezoneH; }; }; TUT_fnc_veh.sqf neb_land_classes = [ "B_T_LSV_01_unarmed_F", "B_Truck_01_transport_F" ]; neb_land_classesDetail = [ ["Buy Prowler($500)", 1, 500], ["Buy Hemtt($5,000)", 2, 5000] ]; TUT_fnc_OpenVehUI = { private ["_flag"]; disableSerialization; player action ["WeaponOnBack", player]; createDialog "RscTUTVehDialog"; neb_land_classes call TUT_gui_LoadVeh; _serverTitleCbo = ((findDisplay 1601) displayCtrl (10)); _plr = profileName; _title = "Vehicle Shop"; _serverTitleCbo ctrlSetStructuredText parseText format ["<t align='left'>%1</t><t align='right'>%2</t>",_plr,_title]; _plrClass = typeOf player; _side = getNumber(configFile >> "cfgVehicles" >> _plrClass>> "side"); _flagCbo = ((findDisplay 1601) displayCtrl (11)); switch (_side) do { case 0: {_flag = "\A3\Data_F\Flags\Flag_CSAT_CO.paa";}; case 1: {_flag = "\A3\Data_F\Flags\Flag_nato_CO.paa";}; case 2: {_flag = "\A3\Data_F\Flags\Flag_AAF_CO.paa";}; }; _flagCbo ctrlSetText _flag; }; TUT_gui_LoadVeh = { _cbo = ((findDisplay 1601) displayCtrl (7)); lbCLear _cbo; { _class = _x; (neb_land_classesDetail select (neb_land_classes find _class)) params["_label", "_level", "_cost"]; _index = lbAdd [7, _label]; _cbo lbSetData[(lbSize _cbo)-1, _class]; _picture = (getText(configFile >> "cfgVehicles" >> _class >> "picture")); _cbo lbSetPicture[(lbSize _cbo)-1,_picture]; // add label, cost here? } forEach _this; }; TUT_gui_VehInfo = { private ["_weapArray","_class","_crewCount","_model","_maxSpeed","_invSpace","_armor"]; disableSerialization; _id = lbCurSel 7; _class = lbData [7, _id]; _weapons = []; _weaponsClass = getArray(configFile >> "cfgVehicles" >> _class >> "weapons"); { _name = getText (configFile >> "cfgWeapons" >> _x >> "displayName"); _weapons = _weapons + [ _name]; }forEach _weaponsClass; if (isClass (configFile >> "cfgVehicles" >> _class >> "Turrets" >> "M2_Turret")) then { _weapArray = getArray(configFile >> "cfgVehicles" >> _class >> "Turrets" >> "M2_Turret" >> "weapons"); } else { _weapArray = getArray(configFile >> "cfgVehicles" >> _class >> "Turrets" >> "MainTurret" >> "weapons"); _weapArray = _weapArray + (getArray(configFile >> "cfgVehicles" >> _class >> "Turrets" >> "FrontTurret" >> "weapons")); _weapArray = _weapArray + (getArray(configFile >> "cfgVehicles" >> _class >> "Turrets" >> "RearTurret" >> "weapons")); }; { _name = getText (configFile >> "cfgWeapons" >> _x >> "displayName"); _weapons = _weapons + [ _name]; }forEach _weapArray; _crewCount = [_class,true] call BIS_fnc_crewCount; _model = getText(configFile >> "cfgVehicles" >> _class >> "model"); _maxSpeed = getNumber(configFile >> "cfgVehicles" >> _class >> "maxSpeed"); _invSpace = getNumber(configFile >> "cfgVehicles" >> _class >> "maximumLoad"); _armor = getNumber(configFile >> "cfgVehicles" >> _class >> "armor"); _textCbo = ((findDisplay 1601) displayCtrl (8)); _separator = parseText "-------------------------------------------------------------------------------------"; _textCbo ctrlSetStructuredText parseText format ["<t align='left'>Weapons:</t><br/> <t align='left'>%1</t> <t align='left'>%6</t><br/> <t align='left'>Passengers:</t> <t align='right'>%2</t> <t align='left'>%6</t><br/> <t align='left'>Max Speed:</t> <t align='right'>%3</t> <t align='left'>%6</t><br/> <t align='left'>Inventory:</t> <t align='right'>%4</t> <t align='left'>%6</t><br/> <t align='left'>Armor:</t> <t align='right'>%5</t> <t align='left'>%6</t><br/>",_weapons,_crewCount,_maxSpeed,_invSpace,_armor, _separator]; }; TUT_gui_VehCreate = { _idVeh = lbCurSel 7; _classVeh = lbData [7, _idVeh]; (neb_land_classesDetail select (neb_land_classes find _classVeh)) params["_label", "_level", "_cost"]; if ([_cost] call neb_fnc_core_pay) then { [] call fnc_updateStats; _emptyPos = position player findEmptyPosition [5,50,_classVeh]; if (count _emptyPos == 0) then { hint "Vehicle cannot be spawned here"; _refund = [-(_cost)] call neb_fnc_core_pay; [] call fnc_updateStats; } else { _veh = createVehicle [_classVeh, _emptyPos, [], 0,""]; clearWeaponCargoGlobal _veh; clearMagazineCargoGlobal _veh; clearItemCargoGlobal _veh; }; closeDialog 1601; } else { hint "Can't afford that!"; }; }; TUT_fnc_veh_air.sqf neb_air_classes = [ "B_Heli_Light_01_F", "B_T_VTOL_01_armed_F" ]; neb_air_classesDetail = [ ["Buy Littlebird($5,000)", 3, 5000], ["Buy VTOL($20,000)", 5, 20000] ]; TUT_fnc_OpenAirVehUI = { private ["_flag"]; disableSerialization; player action ["WeaponOnBack", player]; createDialog "RscTUTVehAirDialog"; neb_air_classes call TUT_gui_LoadAirVeh; _serverTitleCbo = ((findDisplay 1602) displayCtrl (10)); _plr = profileName; _title = "Vehicle Shop"; _serverTitleCbo ctrlSetStructuredText parseText format ["<t align='left'>%1</t><t align='right'>%2</t>",_plr,_title]; _plrClass = typeOf player; _side = getNumber(configFile >> "cfgVehicles" >> _plrClass>> "side"); _flagCbo = ((findDisplay 1602) displayCtrl (11)); switch (_side) do { case 0: {_flag = "\A3\Data_F\Flags\Flag_CSAT_CO.paa";}; case 1: {_flag = "\A3\Data_F\Flags\Flag_nato_CO.paa";}; case 2: {_flag = "\A3\Data_F\Flags\Flag_AAF_CO.paa";}; }; _flagCbo ctrlSetText _flag; }; TUT_gui_LoadAirVeh = { _cbo = ((findDisplay 1602) displayCtrl (7)); lbCLear _cbo; { _class = _x; (neb_air_classesDetail select (neb_air_classes find _class)) params["_label", "_level", "_cost"]; _index = lbAdd [7, _label]; _cbo lbSetData[(lbSize _cbo)-1, _class]; _picture = (getText(configFile >> "cfgVehicles" >> _class >> "picture")); _cbo lbSetPicture[(lbSize _cbo)-1,_picture]; // add label, cost here? } forEach _this; }; TUT_gui_AirVehInfo = { private ["_weapArray","_class","_crewCount","_model","_maxSpeed","_invSpace","_armor"]; disableSerialization; _id = lbCurSel 7; _class = lbData [7, _id]; _weapons = []; _weaponsClass = getArray(configFile >> "cfgVehicles" >> _class >> "weapons"); { _name = getText (configFile >> "cfgWeapons" >> _x >> "displayName"); _weapons = _weapons + [ _name]; }forEach _weaponsClass; if (isClass (configFile >> "cfgVehicles" >> _class >> "Turrets" >> "M2_Turret")) then { _weapArray = getArray(configFile >> "cfgVehicles" >> _class >> "Turrets" >> "M2_Turret" >> "weapons"); } else { _weapArray = getArray(configFile >> "cfgVehicles" >> _class >> "Turrets" >> "MainTurret" >> "weapons"); _weapArray = _weapArray + (getArray(configFile >> "cfgVehicles" >> _class >> "Turrets" >> "FrontTurret" >> "weapons")); _weapArray = _weapArray + (getArray(configFile >> "cfgVehicles" >> _class >> "Turrets" >> "RearTurret" >> "weapons")); }; { _name = getText (configFile >> "cfgWeapons" >> _x >> "displayName"); _weapons = _weapons + [ _name]; }forEach _weapArray; _crewCount = [_class,true] call BIS_fnc_crewCount; _model = getText(configFile >> "cfgVehicles" >> _class >> "model"); _maxSpeed = getNumber(configFile >> "cfgVehicles" >> _class >> "maxSpeed"); _invSpace = getNumber(configFile >> "cfgVehicles" >> _class >> "maximumLoad"); _armor = getNumber(configFile >> "cfgVehicles" >> _class >> "armor"); _textCbo = ((findDisplay 1602) displayCtrl (8)); _separator = parseText "-------------------------------------------------------------------------------------"; _textCbo ctrlSetStructuredText parseText format ["<t align='left'>Weapons:</t><br/> <t align='left'>%1</t> <t align='left'>%6</t><br/> <t align='left'>Passengers:</t> <t align='right'>%2</t> <t align='left'>%6</t><br/> <t align='left'>Max Speed:</t> <t align='right'>%3</t> <t align='left'>%6</t><br/> <t align='left'>Inventory:</t> <t align='right'>%4</t> <t align='left'>%6</t><br/> <t align='left'>Armor:</t> <t align='right'>%5</t> <t align='left'>%6</t><br/>",_weapons,_crewCount,_maxSpeed,_invSpace,_armor, _separator]; }; TUT_gui_AirVehCreate = { _idVeh = lbCurSel 7; _classVeh = lbData [7, _idVeh]; (neb_air_classesDetail select (neb_air_classes find _classVeh)) params["_label", "_level", "_cost"]; if ([_cost] call neb_fnc_core_pay) then { [] call fnc_updateStats; _emptyPos = position player findEmptyPosition [5,50,_classVeh]; if (count _emptyPos == 0) then { hint "Vehicle cannot be spawned here"; _refund = [-(_cost)] call neb_fnc_core_pay; [] call fnc_updateStats; } else { _veh = createVehicle [_classVeh, _emptyPos, [], 0,""]; clearWeaponCargoGlobal _veh; clearMagazineCargoGlobal _veh; clearItemCargoGlobal _veh; }; closeDialog 1602; } else { hint "Can't afford that!"; }; }; Share this post Link to post Share on other sites
Grumpy Old Man 3546 Posted July 20, 2016 If you're really that much into scripting, set up your own functions library. This helps a ton with keeping a view on all your functions, without having to scroll up and down hundreds of lines just to edit that variable you're looking for. Also you can access all your functions from any script, so you don't have to define functions in your files all over the place. What errors do you get when switching between dialog? Cheers Share this post Link to post Share on other sites
kylania 568 Posted July 20, 2016 If you're really that much into scripting, set up your own functions library. He's got that and once things are more settled we'll be moving more functions over to that format. :) Share this post Link to post Share on other sites
nebulazerz 18 Posted July 20, 2016 If you're really that much into scripting, set up your own functions library. This helps a ton with keeping a view on all your functions, without having to scroll up and down hundreds of lines just to edit that variable you're looking for. Also you can access all your functions from any script, so you don't have to define functions in your files all over the place. What errors do you get when switching between dialog? Cheers There are no errors just that buggy looking UI with no function after switching between UI pages multiple times, is there a known issue with this? I even tried to create a quick "main menu" page to see if going to another UI before going back to another similar one would fix the issue but it still happens after browsing through the menu back and forth a few times. I actually do have a function library and parts of these scripts are calling functions in the function library to make it work. The vehicle spawning part of this works fine... until you switch between the menus a few times. If I close out completely by pressing esc and go back into the UI it fixes it and vehicles spawn correctly again. Here is the current code. EDIT: here are the base defines im using in case anyone wants to try this out From Top to Bottom: initPlayerLocal.sqf TUT_gui_veh_menu.hpp TUT_gui_veh_.hpp TUT_gui_veh_air.hpp TUT_fnc_veh.sqf TUT_fnc_veh_air.sqf neb_fnc_OpenBluVehUI = { createDialog "VehShopMenu"; }; _vehDialog = [] spawn compile PreprocessFileLineNumbers "dialog\TUT_fnc_veh.sqf"; waitUntil {scriptDone _vehDialog}; _vehDialogAir = [] spawn compile PreprocessFileLineNumbers "dialog\TUT_fnc_veh_air.sqf"; waitUntil {scriptDone _vehDialogAir}; class VehShopMenu { class controls { class MainMenuBackA : IGUIBack { idc = 0; x = "0 * safezoneW + safezoneX"; y = "0 * safezoneH + safezoneY"; w = "1 * safezoneW"; h = "1 * safezoneH"; colorBackground[] = {0.3,0.3,0.3,0.3}; }; class MyIGUIBack1 : IGUIBack { idc = 1; x = "0.25 * safezoneW + safezoneX"; y = "0.25 * safezoneH + safezoneY"; w = "(960 / 1920) * SafeZoneW"; h = "(225 / 1080) * SafeZoneH"; colorBackground[] = {0.3,0.3,0.3,0.3}; }; class BasicButtonA : RscButton { x = "SafeZoneX + (555 / 1920) * SafeZoneW"; y = "SafeZoneY + (344.999999999999 / 1080) * SafeZoneH"; w = "(90 / 1920) * SafeZoneW"; h = "(75 / 1080) * SafeZoneH"; text = "Basic"; idc = 2; onButtonClick = "closeDialog 1701;[] call TUT_fnc_OpenVehUI;"; }; class ArmedButtonA : RscButton { x = "SafeZoneX + (735 / 1920) * SafeZoneW"; y = "SafeZoneY + (344.999999999999 / 1080) * SafeZoneH"; w = "(90 / 1920) * SafeZoneW"; h = "(75 / 1080) * SafeZoneH"; text = "Armed"; idc = 3; onButtonClick = ""; }; class ArmorButtonA : RscButton { x = "SafeZoneX + (915 / 1920) * SafeZoneW"; y = "SafeZoneY + (344.999999999999 / 1080) * SafeZoneH"; w = "(90 / 1920) * SafeZoneW"; h = "(74.9999999999999 / 1080) * SafeZoneH"; text = "Armor"; idc = 4; onButtonClick = ""; }; class SupportButtonA : RscButton { x = "SafeZoneX + (1095 / 1920) * SafeZoneW"; y = "SafeZoneY + (347.763157894737 / 1080) * SafeZoneH"; w = "(90 / 1920) * SafeZoneW"; h = "(72.2368421052631 / 1080) * SafeZoneH"; text = "Support"; idc = 5; onButtonClick = ""; }; class AirButtonA : RscButton { x = "SafeZoneX + (1275 / 1920) * SafeZoneW"; y = "SafeZoneY + (345 / 1080) * SafeZoneH"; w = "(90 / 1920) * SafeZoneW"; h = "(75 / 1080) * SafeZoneH"; text = "Air"; idc = 6; onButtonClick = "closeDialog 1701;[] call TUT_fnc_OpenAirVehUI;"; }; class ExitButton : RscButton { x = "SafeZoneX + (1425 / 1920) * SafeZoneW"; y = "SafeZoneY + (270 / 1080) * SafeZoneH"; w = "(15 / 1920) * SafeZoneW"; h = "(15 / 1080) * SafeZoneH"; text = "x"; sizeEx = 0.02; idc = 7; onButtonClick = "closeDialog 1701;"; }; }; idd = 1701; movingEnable = false; enableSimulation = true; fadein=0; duration = 1e+011; fadeout=0; onLoad= ""; }; #define true 1 #define false 0 class RscTUTVehDialog { idd=1601; movingEnable = false; enableSimulation = true; fadein=0; duration = 1e+011; fadeout=0; onLoad= ""; controlsBackground[]= { vehBack, vehFrame, RscHeaderBack, RscVehBack, RscVehInfoBack }; controls[]={ btnCancel, btnConfirm, RscVehList, vehStatText, serverTitleText, RscPlayerFlagLeft, btnMenu }; objects[]={}; class vehBack: IGUIBack { idc = 0; x = 0 * safezoneW + safezoneX; y = 0 * safezoneH + safezoneY; w = 1 * safezoneW; h = 1 * safezoneH; colorBackground[] = {0.1,0.1,0.1,0.1}; }; class vehFrame: IGUIBack { idc = 1; x = 0.25 * safezoneW + safezoneX; y = 0.25 * safezoneH + safezoneY; w = 0.5 * safezoneW; h = 0.5 * safezoneH; colorBackground[] = {0.1,0.1,0.1,0.1}; }; class RscHeaderBack: IGUIBack { idc = 2; x = 0.255 * safezoneW + safezoneX; y = 0.2575 * safezoneH + safezoneY; w = 0.49 * safezoneW; h = 0.05 * safezoneH; colorBackground[] = {0.1,0.1,0.1,0.1}; }; class RscVehBack: IGUIBack { idc = 3; x = 0.255 * safezoneW + safezoneX; y = 0.3125 * safezoneH + safezoneY; w = 0.2425 * safezoneW; h = 0.4275 * safezoneH; colorBackground[] = {0.1,0.1,0.1,0.1}; }; class RscVehInfoBack: IGUIBack { idc = 4; x = 0.5025 * safezoneW + safezoneX; y = 0.355 * safezoneH + safezoneY; w = 0.2425 * safezoneW; h = 0.34 * safezoneH; colorBackground[] = {0.1,0.1,0.1,0.1}; }; class btnCancel: RscShortcutButton { idc = 5; text = "Cancel"; colorBackground[] = {0.5,0.5,0.5,0.5}; colorBackground2[] = {0.1,0.1,0.1,0.1}; colorBackgroundFocused[] = {0.1,0.1,0.1,1}; onButtonClick = "closeDialog 1601;"; x = 0.5025 * safezoneW + safezoneX; y = 0.7025 * safezoneH + safezoneY; w = 0.12 * safezoneW; h = 0.0375 * safezoneH; }; class btnConfirm: RscShortcutButton { idc = 6; text = "Confirm"; colorBackground[] = {0.5,0.5,0.5,0.5}; colorBackground2[] = {0.1,0.1,0.1,0.1}; colorBackgroundFocused[] = {0.1,0.1,0.1,1}; onButtonClick = "[] call TUT_gui_VehCreate;"; x = 0.625 * safezoneW + safezoneX; y = 0.7025 * safezoneH + safezoneY; w = 0.12 * safezoneW; h = 0.0375 * safezoneH; }; class RscVehList: RscListBox { idc = 7; onLBSelChanged = "[] spawn TUT_gui_VehInfo;"; colorText[] = {1,1,1,1}; colorDisabled[] = {1,1,1,0.25}; colorScrollbar[] = {1,0,0,0}; colorSelect[] = {1,1,1,1}; colorSelect2[] = {1,1,1,1}; colorSelectBackground[] = {0,0,0,0.5}; colorSelectBackground2[] = {0.1,0.1,0.1,0.1}; colorBackground[] = {0.1,0.1,0.1,0.1}; shadow = 0.75; x = 0.26 * safezoneW + safezoneX; y = 0.3225 * safezoneH + safezoneY; w = 0.2325 * safezoneW; h = 0.41 * safezoneH }; class vehStatText: RscStructuredText { idc = 8; colorText[] = {1,1,1,1}; colorBackground[] = {0.1,0.1,0.1,0.1}; shadow = 0.75; size = 0.037; x = 0.508 * safezoneW + safezoneX; y = 0.365 * safezoneH + safezoneY; w = 0.2325 * safezoneW; h = 0.32 * safezoneH onMouseButtonDown = ""; onMouseButtonUp = ""; onMouseZChanged = ""; text = ""; }; class serverTitleText: RscStructuredText { idc = 10; colorText[] = {1,1,1,1}; colorBackground[] = {0.1,0.1,0.1,0.1}; shadow = 0.75; x = 0.305 * safezoneW + safezoneX; y = 0.265 * safezoneH + safezoneY; w = 0.435 * safezoneW; h = 0.04 * safezoneH; onMouseButtonDown = ""; onMouseButtonUp = ""; onMouseZChanged = ""; text = ""; }; class RscPlayerFlagLeft: RscPicture { idc = 11; colorBackground[] = {0,0,0,1}; sizeEx = 0.1; text = ""; x = 0.2575 * safezoneW + safezoneX; y = 0.26 * safezoneH + safezoneY; w = 0.05 * safezoneW; h = 0.045* safezoneH; }; class btnMenu: RscShortcutButton { idc = 13; text = "Menu"; colorBackground[] = {0.4,0.4,0.4,1}; colorBackground2[] = {0.4,0.4,0.4,1}; colorBackgroundFocused[] = {0.4,0.4,0.4,1}; onButtonClick = "closeDialog 1601;[] call neb_fnc_OpenBluVehUI"; x = 0.585 * safezoneW + safezoneX; y = 0.3125 * safezoneH + safezoneY; w = 0.0775* safezoneW; h = 0.0375 * safezoneH; }; }; #define true 1 #define false 0 class RscTUTVehAirDialog { idd=1602; movingEnable = false; enableSimulation = true; fadein=0; duration = 1e+011; fadeout=0; onLoad= ""; controlsBackground[]= { vehBackB, vehFrameB, RscHeaderBackB, RscVehBackB, RscVehInfoBackB }; controls[]={ btnCancelB, btnConfirmB, RscVehListB, vehStatTextB, serverTitleTextB, RscPlayerFlagLeftB, btnMenuB }; objects[]={}; class vehBackB: IGUIBack { idc = 0; x = 0 * safezoneW + safezoneX; y = 0 * safezoneH + safezoneY; w = 1 * safezoneW; h = 1 * safezoneH; colorBackground[] = {0.1,0.1,0.1,0.1}; }; class vehFrameB: IGUIBack { idc = 1; x = 0.25 * safezoneW + safezoneX; y = 0.25 * safezoneH + safezoneY; w = 0.5 * safezoneW; h = 0.5 * safezoneH; colorBackground[] = {0.1,0.1,0.1,0.1}; }; class RscHeaderBackB: IGUIBack { idc = 2; x = 0.255 * safezoneW + safezoneX; y = 0.2575 * safezoneH + safezoneY; w = 0.49 * safezoneW; h = 0.05 * safezoneH; colorBackground[] = {0.1,0.1,0.1,0.1}; }; class RscVehBackB: IGUIBack { idc = 3; x = 0.255 * safezoneW + safezoneX; y = 0.3125 * safezoneH + safezoneY; w = 0.2425 * safezoneW; h = 0.4275 * safezoneH; colorBackground[] = {0.1,0.1,0.1,0.1}; }; class RscVehInfoBackB: IGUIBack { idc = 4; x = 0.5025 * safezoneW + safezoneX; y = 0.355 * safezoneH + safezoneY; w = 0.2425 * safezoneW; h = 0.34 * safezoneH; colorBackground[] = {0.1,0.1,0.1,0.1}; }; class btnCancelB: RscShortcutButton { idc = 5; text = "Cancel"; colorBackground[] = {0.5,0.5,0.5,0.5}; colorBackground2[] = {0.1,0.1,0.1,0.1}; colorBackgroundFocused[] = {0.1,0.1,0.1,1}; onButtonClick = "closeDialog 1602;"; x = 0.5025 * safezoneW + safezoneX; y = 0.7025 * safezoneH + safezoneY; w = 0.12 * safezoneW; h = 0.0375 * safezoneH; }; class btnConfirmB: RscShortcutButton { idc = 6; text = "Confirm"; colorBackground[] = {0.5,0.5,0.5,0.5}; colorBackground2[] = {0.1,0.1,0.1,0.1}; colorBackgroundFocused[] = {0.1,0.1,0.1,1}; onButtonClick = "[] call TUT_gui_AirVehCreate;"; x = 0.625 * safezoneW + safezoneX; y = 0.7025 * safezoneH + safezoneY; w = 0.12 * safezoneW; h = 0.0375 * safezoneH; }; class RscVehListB: RscListBox { idc = 7; onLBSelChanged = "[] spawn TUT_gui_AirVehInfo;"; colorText[] = {1,1,1,1}; colorDisabled[] = {1,1,1,0.25}; colorScrollbar[] = {1,0,0,0}; colorSelect[] = {1,1,1,1}; colorSelect2[] = {1,1,1,1}; colorSelectBackground[] = {0,0,0,0.5}; colorSelectBackground2[] = {0.1,0.1,0.1,0.1}; colorBackground[] = {0.1,0.1,0.1,0.1}; shadow = 0.75; x = 0.26 * safezoneW + safezoneX; y = 0.3225 * safezoneH + safezoneY; w = 0.2325 * safezoneW; h = 0.41 * safezoneH }; class vehStatTextB: RscStructuredText { idc = 8; colorText[] = {1,1,1,1}; colorBackground[] = {0.1,0.1,0.1,0.1}; shadow = 0.75; size = 0.037; x = 0.508 * safezoneW + safezoneX; y = 0.365 * safezoneH + safezoneY; w = 0.2325 * safezoneW; h = 0.32 * safezoneH onMouseButtonDown = ""; onMouseButtonUp = ""; onMouseZChanged = ""; text = ""; }; class serverTitleTextB: RscStructuredText { idc = 10; colorText[] = {1,1,1,1}; colorBackground[] = {0.1,0.1,0.1,0.1}; shadow = 0.75; x = 0.305 * safezoneW + safezoneX; y = 0.265 * safezoneH + safezoneY; w = 0.435 * safezoneW; h = 0.04 * safezoneH; onMouseButtonDown = ""; onMouseButtonUp = ""; onMouseZChanged = ""; text = ""; }; class RscPlayerFlagLeftB: RscPicture { idc = 11; colorBackground[] = {0,0,0,1}; sizeEx = 0.1; text = ""; x = 0.2575 * safezoneW + safezoneX; y = 0.26 * safezoneH + safezoneY; w = 0.05 * safezoneW; h = 0.045* safezoneH; }; class btnMenuB: RscShortcutButton { idc = 13; text = "Menu"; colorBackground[] = {0.4,0.4,0.4,1}; colorBackground2[] = {0.4,0.4,0.4,1}; colorBackgroundFocused[] = {0.4,0.4,0.4,1}; onButtonClick = "closeDialog 1602;[] call neb_fnc_OpenBluVehUI;"; x = 0.585 * safezoneW + safezoneX; y = 0.3125 * safezoneH + safezoneY; w = 0.0775* safezoneW; h = 0.0375 * safezoneH; }; }; neb_land_classes = [ "B_T_LSV_01_unarmed_F", "B_Truck_01_transport_F" ]; neb_land_classesDetail = [ ["Buy Prowler($500)", 1, 500], ["Buy Hemtt($5,000)", 2, 5000] ]; TUT_fnc_OpenVehUI = { private ["_flag"]; disableSerialization; createDialog "RscTUTVehDialog"; neb_land_classes call TUT_gui_LoadVeh; _serverTitleCbo = ((findDisplay 1601) displayCtrl (10)); _plr = profileName; _title = "Vehicle Shop"; _serverTitleCbo ctrlSetStructuredText parseText format ["<t align='left'>%1</t><t align='right'>%2</t>",_plr,_title]; _plrClass = typeOf player; _side = getNumber(configFile >> "cfgVehicles" >> _plrClass>> "side"); _flagCbo = ((findDisplay 1601) displayCtrl (11)); switch (_side) do { case 0: {_flag = "\A3\Data_F\Flags\Flag_CSAT_CO.paa";}; case 1: {_flag = "\A3\Data_F\Flags\Flag_nato_CO.paa";}; case 2: {_flag = "\A3\Data_F\Flags\Flag_AAF_CO.paa";}; }; _flagCbo ctrlSetText _flag; }; TUT_gui_LoadVeh = { _cbo = ((findDisplay 1601) displayCtrl (7)); lbCLear _cbo; { _class = _x; (neb_land_classesDetail select (neb_land_classes find _class)) params["_label", "_level", "_cost"]; _index = lbAdd [7, _label]; _cbo lbSetData[(lbSize _cbo)-1, _class]; _picture = (getText(configFile >> "cfgVehicles" >> _class >> "picture")); _cbo lbSetPicture[(lbSize _cbo)-1,_picture]; // add label, cost here? } forEach _this; }; TUT_gui_VehInfo = { private ["_weapArray","_class","_crewCount","_model","_maxSpeed","_invSpace","_armor"]; disableSerialization; _id = lbCurSel 7; _class = lbData [7, _id]; _weapons = []; _weaponsClass = getArray(configFile >> "cfgVehicles" >> _class >> "weapons"); { _name = getText (configFile >> "cfgWeapons" >> _x >> "displayName"); _weapons = _weapons + [ _name]; }forEach _weaponsClass; if (isClass (configFile >> "cfgVehicles" >> _class >> "Turrets" >> "M2_Turret")) then { _weapArray = getArray(configFile >> "cfgVehicles" >> _class >> "Turrets" >> "M2_Turret" >> "weapons"); } else { _weapArray = getArray(configFile >> "cfgVehicles" >> _class >> "Turrets" >> "MainTurret" >> "weapons"); _weapArray = _weapArray + (getArray(configFile >> "cfgVehicles" >> _class >> "Turrets" >> "FrontTurret" >> "weapons")); _weapArray = _weapArray + (getArray(configFile >> "cfgVehicles" >> _class >> "Turrets" >> "RearTurret" >> "weapons")); }; { _name = getText (configFile >> "cfgWeapons" >> _x >> "displayName"); _weapons = _weapons + [ _name]; }forEach _weapArray; _crewCount = [_class,true] call BIS_fnc_crewCount; _model = getText(configFile >> "cfgVehicles" >> _class >> "model"); _maxSpeed = getNumber(configFile >> "cfgVehicles" >> _class >> "maxSpeed"); _invSpace = getNumber(configFile >> "cfgVehicles" >> _class >> "maximumLoad"); _armor = getNumber(configFile >> "cfgVehicles" >> _class >> "armor"); _textCbo = ((findDisplay 1601) displayCtrl (8)); _separator = parseText "-------------------------------------------------------------------------------------"; _textCbo ctrlSetStructuredText parseText format ["<t align='left'>Weapons:</t><br/> <t align='left'>%1</t> <t align='left'>%6</t><br/> <t align='left'>Passengers:</t> <t align='right'>%2</t> <t align='left'>%6</t><br/> <t align='left'>Max Speed:</t> <t align='right'>%3</t> <t align='left'>%6</t><br/> <t align='left'>Inventory:</t> <t align='right'>%4</t> <t align='left'>%6</t><br/> <t align='left'>Armor:</t> <t align='right'>%5</t> <t align='left'>%6</t><br/>",_weapons,_crewCount,_maxSpeed,_invSpace,_armor, _separator]; }; TUT_gui_VehCreate = { _idVeh = lbCurSel 7; _classVeh = lbData [7, _idVeh]; (neb_land_classesDetail select (neb_land_classes find _classVeh)) params["_label", "_level", "_cost"]; if ([_cost] call neb_fnc_core_pay) then { [] call fnc_updateStats; _emptyPos = position player findEmptyPosition [5,50,_classVeh]; if (count _emptyPos == 0) then { hint "Vehicle cannot be spawned here"; _refund = [-(_cost)] call neb_fnc_core_pay; [] call fnc_updateStats; } else { _veh = createVehicle [_classVeh, _emptyPos, [], 0,""]; clearWeaponCargoGlobal _veh; clearMagazineCargoGlobal _veh; clearItemCargoGlobal _veh; }; closeDialog 1601; } else { hint "Can't afford that!"; }; }; neb_air_classes = [ "B_Heli_Light_01_F", "B_T_VTOL_01_armed_F" ]; neb_air_classesDetail = [ ["Buy Littlebird($5,000)", 3, 5000], ["Buy VTOL($20,000)", 5, 20000] ]; TUT_fnc_OpenAirVehUI = { private ["_flag"]; disableSerialization; createDialog "RscTUTVehAirDialog"; neb_air_classes call TUT_gui_LoadAirVeh; _serverTitleCbo = ((findDisplay 1602) displayCtrl (10)); _plr = profileName; _title = "Vehicle Shop"; _serverTitleCbo ctrlSetStructuredText parseText format ["<t align='left'>%1</t><t align='right'>%2</t>",_plr,_title]; _plrClass = typeOf player; _side = getNumber(configFile >> "cfgVehicles" >> _plrClass>> "side"); _flagCbo = ((findDisplay 1602) displayCtrl (11)); switch (_side) do { case 0: {_flag = "\A3\Data_F\Flags\Flag_CSAT_CO.paa";}; case 1: {_flag = "\A3\Data_F\Flags\Flag_nato_CO.paa";}; case 2: {_flag = "\A3\Data_F\Flags\Flag_AAF_CO.paa";}; }; _flagCbo ctrlSetText _flag; }; TUT_gui_LoadAirVeh = { _cbo = ((findDisplay 1602) displayCtrl (7)); lbCLear _cbo; { _class = _x; (neb_air_classesDetail select (neb_air_classes find _class)) params["_label", "_level", "_cost"]; _index = lbAdd [7, _label]; _cbo lbSetData[(lbSize _cbo)-1, _class]; _picture = (getText(configFile >> "cfgVehicles" >> _class >> "picture")); _cbo lbSetPicture[(lbSize _cbo)-1,_picture]; // add label, cost here? } forEach _this; }; TUT_gui_AirVehInfo = { private ["_weapArray","_class","_crewCount","_model","_maxSpeed","_invSpace","_armor"]; disableSerialization; _id = lbCurSel 7; _class = lbData [7, _id]; _weapons = []; _weaponsClass = getArray(configFile >> "cfgVehicles" >> _class >> "weapons"); { _name = getText (configFile >> "cfgWeapons" >> _x >> "displayName"); _weapons = _weapons + [ _name]; }forEach _weaponsClass; if (isClass (configFile >> "cfgVehicles" >> _class >> "Turrets" >> "M2_Turret")) then { _weapArray = getArray(configFile >> "cfgVehicles" >> _class >> "Turrets" >> "M2_Turret" >> "weapons"); } else { _weapArray = getArray(configFile >> "cfgVehicles" >> _class >> "Turrets" >> "MainTurret" >> "weapons"); _weapArray = _weapArray + (getArray(configFile >> "cfgVehicles" >> _class >> "Turrets" >> "FrontTurret" >> "weapons")); _weapArray = _weapArray + (getArray(configFile >> "cfgVehicles" >> _class >> "Turrets" >> "RearTurret" >> "weapons")); }; { _name = getText (configFile >> "cfgWeapons" >> _x >> "displayName"); _weapons = _weapons + [ _name]; }forEach _weapArray; _crewCount = [_class,true] call BIS_fnc_crewCount; _model = getText(configFile >> "cfgVehicles" >> _class >> "model"); _maxSpeed = getNumber(configFile >> "cfgVehicles" >> _class >> "maxSpeed"); _invSpace = getNumber(configFile >> "cfgVehicles" >> _class >> "maximumLoad"); _armor = getNumber(configFile >> "cfgVehicles" >> _class >> "armor"); _textCbo = ((findDisplay 1602) displayCtrl (8)); _separator = parseText "-------------------------------------------------------------------------------------"; _textCbo ctrlSetStructuredText parseText format ["<t align='left'>Weapons:</t><br/> <t align='left'>%1</t> <t align='left'>%6</t><br/> <t align='left'>Passengers:</t> <t align='right'>%2</t> <t align='left'>%6</t><br/> <t align='left'>Max Speed:</t> <t align='right'>%3</t> <t align='left'>%6</t><br/> <t align='left'>Inventory:</t> <t align='right'>%4</t> <t align='left'>%6</t><br/> <t align='left'>Armor:</t> <t align='right'>%5</t> <t align='left'>%6</t><br/>",_weapons,_crewCount,_maxSpeed,_invSpace,_armor, _separator]; }; TUT_gui_AirVehCreate = { _idVeh = lbCurSel 7; _classVeh = lbData [7, _idVeh]; (neb_air_classesDetail select (neb_air_classes find _classVeh)) params["_label", "_level", "_cost"]; if ([_cost] call neb_fnc_core_pay) then { [] call fnc_updateStats; _emptyPos = position player findEmptyPosition [5,50,_classVeh]; if (count _emptyPos == 0) then { hint "Vehicle cannot be spawned here"; _refund = [-(_cost)] call neb_fnc_core_pay; [] call fnc_updateStats; } else { _veh = createVehicle [_classVeh, _emptyPos, [], 0,""]; clearWeaponCargoGlobal _veh; clearMagazineCargoGlobal _veh; clearItemCargoGlobal _veh; }; closeDialog 1602; } else { hint "Can't afford that!"; }; }; Share this post Link to post Share on other sites
nebulazerz 18 Posted July 20, 2016 If you're really that much into scripting, set up your own functions library. This helps a ton with keeping a view on all your functions, without having to scroll up and down hundreds of lines just to edit that variable you're looking for. Also you can access all your functions from any script, so you don't have to define functions in your files all over the place. What errors do you get when switching between dialog? Cheers I was playing around with it some more and I tried to spawn a vehicle while the menu was all bugged out and it gave me this error (ignore the sector taken message, i was messing with the shop while in the sector). Anyone know what error zero divisor is? EDIT: also trying a bunch of stuff like this to force close the dialogs first but nothing is working. I tried sleeps also. No one has seen this bug before? EDIT: it seems that the previous menus are not closing even though I am closing their dialogs but i cannot figure out how to force them closed so they can be opened fresh again. EDIT: From the RPT: this is the only error that is in the RPT checking it while using the GUI also. "This error occurs when the variable you are trying to divide has a value of zero, or when you attempt to divide a variable by 0. It also occurs when you attempt to access an element of an array which does not exist." (How can it not exist? It works the first time.) 16:25:50 Error in expression <a [7, _idVeh]; (neb_land_classesDetail select (neb_land_classes find _classVeh)> 16:25:50 Error position: <select (neb_land_classes find _classVeh)> 16:25:50 Error Zero divisor 16:25:50 File C:\Users\Nebulazer\Documents\Arma 3 - Other Profiles\Nebulazerz\mpmissions\BaseWars.Tanoa\dialog\TUT_fnc_veh.sqf, line 107 neb_fnc_OpenBluVehUI = { disableSerialization; if (!dialog) then { createDialog "VehShopMenu"; }else{ { closeDialog _x; } forEach _x; createDialog "VehShopMenu"; }; }; Share this post Link to post Share on other sites