Jump to content
Sign in to follow this  
Naiss

Listbox and button help (Dialog Code)

Recommended Posts

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

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 by Iceman77

Share this post


Link to post
Share on other sites

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
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 by Iceman77

Share this post


Link to post
Share on other sites

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

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

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×