Jump to content
Sign in to follow this  
Naiss

player list in a dialog

Recommended Posts

okey so im creating a player menu dialog and i want it to show all the players in 1 list box thats under RPP_playerlist in the code

Dialog:

class RPProject_playermenu
{
   idd = 30045;
   movingenable = true;
   onLoad = "uiNamespace setVariable ['Lifeman', (_this select 0)]"; 

class Controls
{	
	class RPP_PlayerMenu: RscFrame
	{
		idc = 2200;
		x = 0.379688 * safezoneW + safezoneX;
		y = 0.302077 * safezoneH + safezoneY;
		w = 0.246354 * safezoneW;
		h = 0.38485 * safezoneH;

	};
	class RPP_TEXT: RscText
	{
		idc = 1000;
		text = "RP Project Player Menu"; //--- ToDo: Localize;
		x = 0.448438 * safezoneW + safezoneX;
		y = 0.313073 * safezoneH + safezoneY;
		w = 0.114583 * safezoneW;
		h = 0.0219914 * safezoneH;
	};
	class RPP_Playerlist: RscListbox   //i want the player list in to this listbox
	{
		idc = 1500;
		x = 0.385417 * safezoneW + safezoneX;
		y = 0.34606 * safezoneH + safezoneY;
		w = 0.0572917 * safezoneW;
		h = 0.274893 * safezoneH;
	};
	class RPP_Skillslist: RscListbox
	{
		idc = 1501;
		x = 0.471354 * safezoneW + safezoneX;
		y = 0.34606 * safezoneH + safezoneY;
		w = 0.0572917 * safezoneW;
		h = 0.274893 * safezoneH;
	};
	class RPP_Itemlist: RscListbox
	{
		idc = 1502;
		x = 0.557292 * safezoneW + safezoneX;
		y = 0.34606 * safezoneH + safezoneY;
		w = 0.0572917 * safezoneW;
		h = 0.274893 * safezoneH;
	};
	class RscButton_1600: RscButton
	{
		idc = 1600;
		text = "Drop"; //--- ToDo: Localize;
		x = 0.385417 * safezoneW + safezoneX;
		y = 0.642944 * safezoneH + safezoneY;
		w = 0.0401042 * safezoneW;
		h = 0.0219914 * safezoneH;
	};
	class RscButton_1601: RscButton
	{
		idc = 1601;
		text = "Use"; //--- ToDo: Localize;
		x = 0.448438 * safezoneW + safezoneX;
		y = 0.642944 * safezoneH + safezoneY;
		w = 0.0401042 * safezoneW;
		h = 0.0219914 * safezoneH;
	};
	class RscButton_1602: RscButton
	{
		idc = 1602;
		text = "Give"; //--- ToDo: Localize;
		x = 0.511458 * safezoneW + safezoneX;
		y = 0.642944 * safezoneH + safezoneY;
		w = 0.0401042 * safezoneW;
		h = 0.0219914 * safezoneH;
	};
	class RscButton_1603: RscButton
	{
		idc = 1603;
		text = "Remove"; //--- ToDo: Localize;
		x = 0.56875 * safezoneW + safezoneX;
		y = 0.642944 * safezoneH + safezoneY;
		w = 0.0401042 * safezoneW;
		h = 0.0219914 * safezoneH;
	};
};
};	

please help me :)

Share this post


Link to post
Share on other sites

init.sqf

_actionId = player addAction ["Create Dialog", "dialogInit.sqf"];

dialogInit.sqf

createDialog "RPProject_playermenu";
waitUntil {!isNull (findDisplay 30045)};

lbClear 1500; // Just to be safe, the Lb doesn't need to be cleared upon Ui init obviously. But it's a good idea to clear it if populating a Lb with various 'item types' at any given time

{
if (isPlayer _x) then {
	_index = lbAdd [1500, name _x];
       _data = lbSetData [1500, _index, getPosATL _x]; // Set some data (in this case a position of the unit) for later reference based on any UI Events
       lbSetTooltip [1500, _index, name _x]; // Set some tool tips, because they're nice to have
};
} forEach allUnits;

Edited by Iceman77

Share this post


Link to post
Share on other sites
okey so im creating a player menu dialog and i want it to show all the players in 1 list box thats under RPP_playerlist in the code

Dialog:

class RPProject_playermenu
{
   idd = 30045;
   movingenable = true;
   onLoad = "uiNamespace setVariable ['Lifeman', (_this select 0)]"; 

class Controls
{	
	class RPP_PlayerMenu: RscFrame
	{
		idc = 2200;
		x = 0.379688 * safezoneW + safezoneX;
		y = 0.302077 * safezoneH + safezoneY;
		w = 0.246354 * safezoneW;
		h = 0.38485 * safezoneH;

	};
	class RPP_TEXT: RscText
	{
		idc = 1000;
		text = "RP Project Player Menu"; //--- ToDo: Localize;
		x = 0.448438 * safezoneW + safezoneX;
		y = 0.313073 * safezoneH + safezoneY;
		w = 0.114583 * safezoneW;
		h = 0.0219914 * safezoneH;
	};
	class RPP_Playerlist: RscListbox   //i want the player list in to this listbox
	{
		idc = 1500;
		x = 0.385417 * safezoneW + safezoneX;
		y = 0.34606 * safezoneH + safezoneY;
		w = 0.0572917 * safezoneW;
		h = 0.274893 * safezoneH;
	};
	class RPP_Skillslist: RscListbox
	{
		idc = 1501;
		x = 0.471354 * safezoneW + safezoneX;
		y = 0.34606 * safezoneH + safezoneY;
		w = 0.0572917 * safezoneW;
		h = 0.274893 * safezoneH;
	};
	class RPP_Itemlist: RscListbox
	{
		idc = 1502;
		x = 0.557292 * safezoneW + safezoneX;
		y = 0.34606 * safezoneH + safezoneY;
		w = 0.0572917 * safezoneW;
		h = 0.274893 * safezoneH;
	};
	class RscButton_1600: RscButton
	{
		idc = 1600;
		text = "Drop"; //--- ToDo: Localize;
		x = 0.385417 * safezoneW + safezoneX;
		y = 0.642944 * safezoneH + safezoneY;
		w = 0.0401042 * safezoneW;
		h = 0.0219914 * safezoneH;
	};
	class RscButton_1601: RscButton
	{
		idc = 1601;
		text = "Use"; //--- ToDo: Localize;
		x = 0.448438 * safezoneW + safezoneX;
		y = 0.642944 * safezoneH + safezoneY;
		w = 0.0401042 * safezoneW;
		h = 0.0219914 * safezoneH;
	};
	class RscButton_1602: RscButton
	{
		idc = 1602;
		text = "Give"; //--- ToDo: Localize;
		x = 0.511458 * safezoneW + safezoneX;
		y = 0.642944 * safezoneH + safezoneY;
		w = 0.0401042 * safezoneW;
		h = 0.0219914 * safezoneH;
	};
	class RscButton_1603: RscButton
	{
		idc = 1603;
		text = "Remove"; //--- ToDo: Localize;
		x = 0.56875 * safezoneW + safezoneX;
		y = 0.642944 * safezoneH + safezoneY;
		w = 0.0401042 * safezoneW;
		h = 0.0219914 * safezoneH;
	};
};
};	

please help me :)

Did icemans suggestion work?

Share this post


Link to post
Share on other sites
No it actually wouldn't work because the data parameter needs to be a string. Be nice if it could be an object, array, number etc :p.

---------- Post added at 18:38 ---------- Previous post was at 18:16 ----------

Ticket >> http://feedback.arma3.com/view.php?id=21369

If he was storing coordinates he can just do: _data = lbSetData [1500, _index, str(getPosATL _x)];

Then when he needs to utilize it he can just do call compile on the data field to compile it to an array. It's a bit more of a pain with objects however. With units I've always had to name them something like unit_1, unit_2,unit_3 etc etc to be able to store and compile it for later use as there is no real effective solution for converting an object to str and then compiling back as an object if no varName is set.

But no doubt it would be nice to be able to store other data types besides a string in the data field.

Share this post


Link to post
Share on other sites
You might be interested in playableUnits if you only want players to show up in your menu.

Yeah. You still have to check if the playable guy is controlled by an actual player though. Unless the ai is disabled ofcourse. But if they aren't, then you'll need to check.

Share this post


Link to post
Share on other sites

@ Lifeman - Here's how to convert the string name you stored as data into an object. Should work. Cheers.

private ["_name","_unitPos"]; 
call compile format ["_name = %1;", lbData [1500, lbCurSel 1500]];
_unitPos = getPosATL _name;
// . . .

Edited by Iceman77

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  

×