Naiss 28 Posted October 21, 2014 Okey so i got a dialog with 1 button and 1 listbox with the players and my Question is how can i run a code on the guy i select in the list box, Will this work: _p = _this select 0; //the person in the list box, if im wrong here please correct me //what im trying to do in the _p is that the player i select from the list box, idk if i would use this select here or something else [player, "test_Function", _p] call BIS_fnc_MP; Share this post Link to post Share on other sites
iceman77 18 Posted October 21, 2014 (edited) Something like this maybe? Store the unit's name as data createDialog "TEST_DIALOG"; waitUntil {!(isNull (findDisplay 5000))}; private ["_index"]; { _index = lbAdd [ 1500, name _x ]; lbSetData [ 1500, _index, name _x ]; } forEach playableUnits; button action or event.. w/e private ["_data"]; _data = lbData [ 1500, ( lbCurSel 1500 ) ]; [[], "test_Function", _data, false] call BIS_fnc_MP; // Set the target to the lb currently selected index's data (name) May need to convert the string to an object along the way :p Edited October 21, 2014 by Iceman77 Share this post Link to post Share on other sites
Naiss 28 Posted October 21, 2014 Thanks iceman i will test this when i get time :) ---------- Post added at 13:29 ---------- Previous post was at 12:19 ---------- okey so i want to get the name of the player in a hint that i select from the list box, how would i do that Share this post Link to post Share on other sites
iceman77 18 Posted October 21, 2014 (edited) okey so i want to get the name of the player in a hint that i select from the list box, how would i do that // . . . etc etc { _index = lbAdd [ 1500, name _x ]; // add the unit's name visually lbSetData [ 1500, _index, name _x ]; // store the name of the unit as data for the given index of said LB } forEach playableUnits; Button click / UI Event private ["_data"]; _data = lbData [ 1500, ( lbCurSel 1500 ) ]; // retrieve the stored data from the LB's currently selected index (in our case, the name) hint format ["%1", _data]; // Print the _data string Edited October 21, 2014 by Iceman77 Share this post Link to post Share on other sites
Naiss 28 Posted October 21, 2014 okey thanks but what im trying to do now is that i want to do a if statement in a while loop but i can't use the _data because the dialog wont be open the whole time so how would i make the guy i selected in the listbox to an variable or something? Share this post Link to post Share on other sites
iceman77 18 Posted October 21, 2014 You'll need to convert the data string into an object. Like removing the "". Idk though, someone else may have to chip in on the best way to do that. Hence the little foot note in my original post. Share this post Link to post Share on other sites