gokitty1199 225 Posted May 29, 2018 i have a listbox with players inside it with the players name set as the lbText and the lbData set as their actual name like R Alpha 1-1:1 (name). however i had to add that name in as a string to the listbox, now when i go to extract that name out of there its in the form of a string and i cannot seem to convert it to anything of use. i have found\tried __unit = missionNamespace getVariable [_unitClass, objNull]; and it returns null unless i give that is selected a variable name, if the unit has a variable name then it works just fine, however i do not want to set variable names for every unit just for this, any ideas? using hint and setdamage as a test _index = lbCurSel 1001; _unit = lbData [1001, 0]; _obj = missionNamespace getVariable [_unit, objNull]; hint str _obj; _obj setDamage 1; Share this post Link to post Share on other sites
HazJ 1289 Posted May 29, 2018 One way is: call compile _string Though a lot of people don't like this method. There are other ways but this is just quick and does the job. Share this post Link to post Share on other sites
gokitty1199 225 Posted May 29, 2018 5 minutes ago, HazJ said: One way is: call compile _string Though a lot of people don't like this method. There are other ways but this is just quick and does the job. tried that as well and i have the exact same result using that to. heres where it creates the list _unit = (_this select 1); _name = name _unit; createDialog "inviteDialog"; ctrlSetText [1001, _name]; lbAdd [1001, _name]; lbSetCurSel [1001, 0]; lbSetData [1001, 0, str _unit]; heres the script the button runs when it is pressed(just with your reply in it) _index = lbCurSel 1001; _unit = lbData [1001, 0]; _obj = call compile _unit; hint str _obj; _obj setDamage 1; Share this post Link to post Share on other sites
Mr H. 402 Posted May 29, 2018 lbSetData [1001, 0, name _unit]; in your other script: _selectedPlayer = [lbData [ 1001, (lbCurSel 1001)]]; _selectedPlayerConverted = objNull; { if (str _x == _selectedPlayer) then {_selectedPlayerConverted = _x}; }forEach allUnits; and now selectedPlayerConverted is your unit Share this post Link to post Share on other sites
HazJ 1289 Posted May 29, 2018 Also... Larrow's method. Share this post Link to post Share on other sites
gokitty1199 225 Posted May 29, 2018 ^ as stated by HazJ, @Larrow's method worked like a charm //setting the data lbSetData[1001, 0, [_unit] call BIS_fnc_objectVar]; //getting the data _unit = missionNamespace getVariable(lbData [1001, 0]); _unit setDamage 1; 1 Share this post Link to post Share on other sites
KillerAussie 2 Posted May 29, 2018 "call compile" just doesn't like working with the default player variable. You have to assign a variable in editor. Don't ask me why but here is some example. // Player without variable assigned in editor _player1 = str player; _player1 = call compile _player1; _player1 // Returns Null // Player with variable assinged in editor _player1 = str player; _player1 = call compile _player1; _player1 // Returns Player Share this post Link to post Share on other sites
Larrow 2821 Posted May 29, 2018 7 hours ago, gokitty1199 said: if the unit has a variable name then it works just fine, however i do not want to set variable names for every unit 5 hours ago, gokitty1199 said: ^ as stated by HazJ, @Larrow's method worked like a charm //setting the data lbSetData[1001, 0, [_unit] call BIS_fnc_objectVar]; //getting the data _unit = missionNamespace getVariable(lbData [1001, 0]); _unit setDamage 1; Although this is giving every unit a vehicleVarName and a reference in missionNamespace. If you wanted to avoid filling up missionNamespace with global variables you can also use netID. //setting the data lbSetData[1001, 0, [_unit] call BIS_fnc_netId]; //getting the data _unit = lbData [1001, 0] call BIS_fnc_objectFromNetId; _unit setDamage 1; 3 1 Share this post Link to post Share on other sites
HazJ 1289 Posted June 3, 2018 There is also: https://community.bistudio.com/wiki/objectFromNetId I believe it does the same as the function except the command works only in MP. If you have no intention of SP then best to use command engine solution. Share this post Link to post Share on other sites
Larrow 2821 Posted June 4, 2018 1 hour ago, HazJ said: If you have no intention of SP then best to use command engine solution. Makes very little difference. The function already sees if you are in MP and uses the command version if so. So there is very little overhead other than calling the function and an if statement. All for the added benefit of knowing your both SP and MP safe. Share this post Link to post Share on other sites