Smart Games 76 Posted August 22, 2019 I made a gui to buy vehicles, but if i want to buy it it tells me this: "Error Type Any - Expected String" . the function to make it work: (fnc_vbuy) fnc_gv_add = { _dialog = findDisplay 7777; _ctrl = _dialog displayCtrl 22222; vtype = "ALL"; {_ctrl lbAdd format ["%1",_x];} forEach gvCars; {_ctrl lbAdd format ["%1",_x];} forEach gvAPCs; {_ctrl lbAdd format ["%1",_x];} forEach gvTanks; }; fnc_f1 = { _dialog = findDisplay 7777; _ctrl = _dialog displayCtrl 22222; vType = "ALL"; lbClear _ctrl; {_ctrl lbAdd format ["%1",_x];} forEach gvCars; {_ctrl lbAdd format ["%1",_x];} forEach gvAPCs; {_ctrl lbAdd format ["%1",_x];} forEach gvTanks; }; fnc_f2 = { _dialog = findDisplay 7777; _ctrl = _dialog displayCtrl 22222; vType = "LIGHT"; lbClear _ctrl; {_ctrl lbAdd format ["%1",_x];} forEach gvCars; }; fnc_f3 = { _dialog = findDisplay 7777; _ctrl = _dialog displayCtrl 22222; vType = "APC"; lbClear _ctrl; {_ctrl lbAdd format ["%1",_x];} forEach gvAPCs; }; fnc_f4 = { _dialog = findDisplay 7777; _ctrl = _dialog displayCtrl 22222; vType = "TANK"; lbClear _ctrl; {_ctrl lbAdd format ["%1",_x];} forEach gvTanks; }; fnc_lb_change = { _dialog = findDisplay 7777; _ctrl = _dialog displayCtrl 22223; _lb = _dialog displayCtrl 22222; _ctrl ctrlSetText format ["%1", _lb lbText (lbCurSel _lb) ]; }; fnc_vbuy = { _dialog = findDisplay 7777; _ctrl = _dialog displayCtrl 22222; if (vType == "ALL") then { if ((lbCurSel _ctrl) <= 15) then {_cname = gvCarsNames select (lbCurSel _ctrl)}; if (((lbCurSel _ctrl) <= 20) && (lbCurSel _lb > 15)) then {_cname = gvAPCsNames select (lbCurSel _ctrl)}; if ((lbCurSel _ctrl) > 20) then {_cname = gvTanksNames select (lbCurSel _ctrl)}; }; if (vType == "LIGHT") then { _cname = gvCarsNames select (lbCurSel _ctrl); }; if (vType == "APC") then { _cname = gvAPCsNames select (lbCurSel _ctrl); }; if (vType == "TANK") then { _cname = gvTanksNames select (lbCurSel _ctrl); }; _veh = createVehicle [_cname, position player, [], 0, "none"]; }; _ctrl is a listbox. my defines: gvCars = [ "Kubelwagen", "Kubelwagen (Camo)", "Kubelwagen (Hood)", "Kubelwagen (Hood)(Camo)", "Kubelwagen (Hood)(Sernyt)", "Kubelwagen (MG42)", "Kubelwagen (MG42)(Camo)", "Kubelwagen (MG42)(Sernyt)", "Kubelwagen (Sernyt)", "Opel Blitz (Ambulance)", "Opel Blitz (Ammo)", "Opel Blitz (Fuel)", "Opel Blitz (Open)", "Opel Blitz (Repair)", "Opel Blitz (Tent)" ]; gvAPCs = [ "Sd. Kfz. 251", "Sd. Kfz. 7/1", "Sd. Kfz. 7/1 (Ammo)", "Sd. Kfz. AA", "Sd. Kfz. 251 (2xMG42)", "Sd. Kfz. 222", "Sd. Kfz. 222 (Camo)", "Sd. Kfz. 222 (Gelbbraun)", "Sd. Kfz. 234/1 Autocannon", "Sd. Kfz. 234/2 Puma", "Sd. Kfz. 234/3 Stummel", "Sd. Kfz. 234/4 Parkwagen" ]; gvTanks = [ "FlakPanzer IV (Wirbelwind)", "PzKpfw IV Ausf.H", "PzKpfw IV Ausf.H (Tarn51(C))", "PzKpfw IV Ausf.H (Tarn51(D))", "PzKpfw IV Ausf.A Panther", "PzKpfw IV Ausf.B Kingtiger", "PzKpfw IV Ausf.B Kingtiger", "PzKpfw IV Ausf.B Kingtiger (Tarn51(C))", "PzKpfw IV Ausf.B Kingtiger (Tarn51(D))", "PzKpfw IV Ausf.E", "PzKpfw IV Ausf.E (Green)", "PzKpfw IV Ausf.E (Tarn51(C))", "PzKpfw IV Ausf.E (Tarn51(D))", "PzKpfw IV Ausf.E (Tarn52(C))", "PzKpfw IV Ausf.E (Tarn52(D))", "PzKpfw IV Ausf.E 2", "Sd.Kfz. 124 Wespe", "SPG STuG III Ausf.G" ]; gvCarsNames = [ "LIB_Kfz1", "LIB_Kfz1_camo", "LIB_Kfz1_hood", "LIB_Kfz1_hood_camo", "LIB_Kfz1_hood_seryt", "LIB_Kfz1_mg42", "LIB_Kfz1_mg42_camo", "LIB_Kfz1_mg42_sernyt","LIB_Kfz1_sernyt", "LIB_opelblitz_ambulance", "LIB_opelblitz_ammo", "LIB_opelblitz_fuel", "LIB_opelblitz_open_y_camo", "LIB_opelblitz_parm", "LIB_opelblitz_tent_y_camo" ]; gvAPCsNames = [ "LIB_sdkfz251", "LIB_sdkfz_7", "LIB_sdkfz_7_ammo", "LIB_sdkfz_7_aa", "LIB_sdkfz251_ffv", "lib_sdkfz222", "lib_sdkfz222_camo", "lib_sdkfz222_gelbbraun", "lib_sdkfz234_1", "lib_sdkfz234_2", "lib_sdkfz234_3", "lib_sdkfz234_4" ]; gvTanksNames = [ "lib_flakpanzeriv_wirbelwind", "lib_pzkpfwiv_h", "lib_pzkpfwiv_h_tarn51c", "lib_pzkpfwiv_h_tarn51d", "lib_pzkpfwv", "lib_pzkpfwivi_b", "lib_pzkpfwivi_b_tarn51c", "lib_pzkpfwivi_b_tarn51c", "lib_pzkpfwivi_b_tarn51d", "lib_pzkpfwivi_e", "lib_pzkpfwivi_e_2", "lib_pzkpfwivi_e_tarn51c", "lib_pzkpfwivi_e_tarn51d", "lib_pzkpfwivi_e_tarn52c", "lib_pzkpfwivi_e_tarn52d", "lib_pzkpfwvi_e_1", "lib_sdkfz124", "lib_strug_iii_g" ]; Any Ideas, Thanks! Share this post Link to post Share on other sites
Schatten 267 Posted August 22, 2019 4 minutes ago, Smart Games said: Error Type Any - Expected String Where? Provide full report related to this error from RPT-file please. Share this post Link to post Share on other sites
Schatten 267 Posted August 22, 2019 fnc_vbuy: if (((lbCurSel _ctrl) <= 20) && (lbCurSel _lb > 15)) then {_cname = gvAPCsNames select (lbCurSel _ctrl)}; Seems like _lb is undefined. 2 Share this post Link to post Share on other sites
Smart Games 76 Posted August 22, 2019 Thank you, i think i forgot it 1 Share this post Link to post Share on other sites
Larrow 2800 Posted August 22, 2019 and _cname at createVehicle line will be undefined as it is only ever initialised within IF scopes. There are easier ways to handle your setup, rather than having to remember what vType your currently displaying and if lbCurSel < or > than some number. Just store the actual vehicle type(gv#Name) in the listboxes data when you fill the listbox. Also get rid of all the format commands. A string(lbtext, gv#) turned into a string(format) to be displayed as a string(lbAdd, ctrlSetText) is just the original string. fnc_gv_add = { disableSerialization; _dialog = findDisplay 7777; _ctrl = _dialog displayCtrl 22222; { _index = _ctrl lbAdd _x; _ctrl lbSetData [ _index, ( gvCarsNames select _forEachIndex ) ]; } forEach gvCars; { _index = _ctrl lbAdd _x; _ctrl lbSetData [ _index, ( gvAPCsNames select _forEachIndex ) ]; } forEach gvAPCs; { _index = _ctrl lbAdd _x; _ctrl lbSetData [ _index, ( gvTanksNames select _forEachIndex ) ]; } forEach gvTanks; }; fnc_vbuy = { disableSerialization; _dialog = findDisplay 7777; _ctrl = _dialog displayCtrl 22222; _vehicleType = _ctrl lbData (lbCurSel _ctrl); _veh = createVehicle [_vehicleType, position player, [], 0, "none"]; }; Spoiler //Is this being called by an event? //Some combo box for example vehicleType( ALL, LIGHT etc ) //If so the ctrl and index selected can be passed fnc_gv_add = { disableSerialization; //Combo event // params[ "_combo", "_index" ]; // // _ctrl = ctrlParent _combo displayCtrl 22222; // _type = _combo lbText _index; //OR Pass in type to be displayed //ALL, LIGHT, APC, TANK params[ [ "_type", "ALL", [ "" ] ] ]; _dialog = findDisplay 7777; _ctrl = _dialog displayCtrl 22222; //This could be even simpler if your data was rearranged _vehicles = switch( toUpper _type ) do { case ( "ALL" ) : { [ gvCars + gvAPCs + gvTanks, gvCarsNames + gvAPCsNames + gvTanksNames ]; }; case ( "LIGHT" ) : { [ gvCars, gvCarsNames ]; }; case ( "APC" ) : { [ gvAPCs, gvAPCsNames ]; }; case ( "TANK" ) : { [ gvTanks, gvTanksNames ]; }; }; if !( isNil "_vehicles" ) then { lbClear _ctrl; { _index = _ctrl lbAdd _x; _ctrl lbSetData[ _index, _vehicles select 1 select _forEachIndex ]; } forEach ( _vehicles select 0 ); }; }; //Is this happening from an event? //If so the _lb and _index will be passed fnc_lb_change = { disableSerialization; params[ "_lb", "_index" ]; _ctrl = ctrlParent _lb displayCtrl 22223; _ctrl ctrlSetText ( _lb lbText _index ); }; //Is this an event from a button? //If so _button will be passed fnc_vbuy = { disableSerialization; params[ "_btn" ]; _ctrl = ctrlParent _btn displayCtrl 22222; _vehicleType = _ctrl lbData (lbCurSel _ctrl); _veh = createVehicle [_vehicleType, position player, [], 0, "none"]; }; 3 Share this post Link to post Share on other sites
Smart Games 76 Posted August 23, 2019 @Larrow, It's always great know that there is someone in this Forum, who wants to help you. I don't like to copy and paste code, thats why i didn't used everything you gave me. But i learned something new and now i know how to use it in the future and i have a working gui ,thank you 😄 Great Work! 3 Share this post Link to post Share on other sites