Jump to content
Sign in to follow this  
SniPeZz_Qc

Need some help with get RscCombo data

Recommended Posts

Hi everyone i'm trying to get what the player have selected with RscCombo and display it but i can't get it work after hours of trying.

.hpp

		class textRaison : Life_RscCombo {

	idc = 0896;

	text = "";
	sizeEx = 0.035;
	x = 0.33;
	y = 0.29;
	w = 0.36;
	h = 0.03;

	};

	class Details1 : Life_RscTitle
	{
		idc = 0902;
		text = "";
		sizeEx = 0.035;
		colorBackground[] = {0, 0, 0, 0};

		x = 0.34;
		y = 0.36;
		w = 0.36;
		h = 0.32;
	};

.sqf

#include <macro.h>
/*
File: fn_wanted_add.sqf
Author: snipezz
*/
private["_display","_units","_type","_raison","_details","_choix"];

disableSerialization;

//waitUntil {!isNull findDisplay 2406767};
_display = findDisplay 0898;
_units = _display displayCtrl 0894;
_raison = _display displayCtrl 0896;
_details = _display displayCtrl 0902;

_choix = lbData [0896,lbCurSel 0896];
_choix = call compile format["%1",_choix];

_type = ["Meurtre","Echapper de prison","Viole"];

lbClear _units;
{
if(alive _x) then
{
	_units lbAdd format["%1",_x getVariable["realname",name _x]];
	_units lbSetData [(lbSize _units)-1,str(_x)];
};
} foreach playableUnits;

lbClear _raison;
{
_raison lbAdd format [_x];
_raison lbSetData [(lbSize _raison)-1,str(_x)];
} forEach _type;

lbClear _details;
{
_details lbAdd format ["%1",_choix];
_details lbSetData [(lbSize _details)-1,str(_x)];
} forEach _choix;

In game error :

AtwBIU3.png

Thanks you for helping me.

Share this post


Link to post
Share on other sites

_choix is a number and not an array, whatever you are storing in control 0896 is not an array, not to mention _details (Control 0902) is not a combo list, it is just a standard RscText type so using lbAdd will not work. What you are probably wanting is below, remove lbClear _details and the code below and replace with simply this:

_details ctrlSetText _choix;

Share this post


Link to post
Share on other sites
_choix is a number and not an array, whatever you are storing in control 0896 is not an array, not to mention _details (Control 0902) is not a combo list, it is just a standard RscText type so using lbAdd will not work. What you are probably wanting is below, remove lbClear _details and the code below and replace with simply this:

_details ctrlSetText _choix;

Thank you for your help you are amazing but I can't get it working. Now it display only the first choice and not the one I selected.

http://i.imgur.com/cEGCMmq.jpg (524 kB)

http://i.imgur.com/2uVshMw.jpg (528 kB)

#include <macro.h>
/*
File: fn_wanted_add.sqf
Author: snipezz
*/
private["_display","_units","_type","_raison","_details","_choix"];

disableSerialization;

//waitUntil {!isNull findDisplay 2406767};
_display = findDisplay 0898;
_units = _display displayCtrl 0894;
_raison = _display displayCtrl 0896;
_details = _display displayCtrl 0902;

_choix = lbData [0896,0];
//_choix = call compile format["%1",_choix];

_type = ["Meurtre","Echapper de prison","Viole"];

lbClear _units;
{
if(alive _x) then
{
	_units lbAdd format["%1",_x getVariable["realname",name _x]];
	_units lbSetData [(lbSize _units)-1,str(_x)];
};
} foreach playableUnits;

lbClear _raison;
{
_raison lbAdd format [_x];
_raison lbSetData [(lbSize _raison)-1,str(_x)];
} forEach _type;

_details ctrlSetText _choix;

thank you again

Share this post


Link to post
Share on other sites

Your line is referring to the first index and not the index you have selected. Hence why you are receiving the first entry.

Replace this

_choix = lbData [0896,0];

With this

_choix = lbData [0896, lbCurSel 0896];

This will return a string of what you have selected in the ComboBox.

Share this post


Link to post
Share on other sites

One last question that i can't figured out myself.

Why the "" appear in my text:

http://i.imgur.com/61qEzia.jpg (511 kB)

.sqf

#include <macro.h>
/*
File: fn_wanted_add.sqf
Author: snipezz
*/
private["_display","_units","_type","_raison","_details","_choix","_unit","_details1","_details2","_nom"];

disableSerialization;

_display = findDisplay 0898;
_units = _display displayCtrl 0894;
_raison = _display displayCtrl 0896;
_details = _display displayCtrl 0902;
_details1 = _display displayCtrl 0903;
_details2 = _display displayCtrl 0908;

_choix = lbData [0896, lbCurSel 0896];
_unit = lbData [0894, lbCurSel 0894];
_unit = call compile format["%1", _unit];

_type = ["Meurtre" , "Echapper de prison" , "Viole"];

lbClear _units;
{
if(alive _x) then
{
	_units lbAdd format["%1",_x getVariable["realname",name _x]];
	_units lbSetData [(lbSize _units)-1,str(_x)];
};
} foreach playableUnits;

lbClear _raison;
{
_raison lbAdd format [_x];
_raison lbSetData [(lbSize _raison)-1,str(_x)];
} forEach _type;


_details ctrlSetText format [_choix];
_details1 ctrlSetText format["%1",_unit getVariable["realname",name _unit]];


switch (_choix) do
{
case "Meutre":
{
	_details2 ctrlSetText "323";
};
case "Echapper de prison":
{
	_details2 ctrlSetText "3323";
};
case "Viole":
{
	_details2 ctrlSetText "3423";
};
};

.hpp

class life_wanted_add {
idd = 0898;
name= "life_wanted_add";
movingEnable = false;
enableSimulation = true;
onLoad = "[] spawn life_fnc_wanted_add";

class controlsBackground {
	class Life_RscTitleBackground:Life_RscText {
		colorBackground[] = {"(profilenamespace getvariable ['GUI_BCG_RGB_R',0.3843])", "(profilenamespace getvariable ['GUI_BCG_RGB_G',0.7019])", "(profilenamespace getvariable ['GUI_BCG_RGB_B',0.8862])", "(profilenamespace getvariable ['GUI_BCG_RGB_A',0.7])"};
		idc = -1;
		x = 0.1;
		y = 0.2;
		w = 0.6;
		h = (1 / 25);
	};

	class MainBackground:Life_RscText {
		colorBackground[] = {0, 0, 0, 0.7};
		idc = -1;
		x = 0.1;
		y = 0.2 + (11 / 250);
		w = 0.6;
		h = 0.6 - (22 / 250);
	};
};

class controls {


	class Title : Life_RscTitle {
		colorBackground[] = {0, 0, 0, 0};
		idc = -1;
		text = "$STR_Wanted_Title";
		x = 0.1;
		y = 0.2;
		w = 0.6;
		h = (1 / 25);
	};

	class WantedConnection : Title {
		idc = 2404;
		style = 1;
		text = "";
	};

	class ListJoueur : Life_RscListBox
	{
		idc = 0894;
		text = "";
		sizeEx = 0.035;
		x = 0.12; y = 0.29;
		w = 0.2; h = 0.4;
		onLBSelChanged = "[_this] spawn life_fnc_wanted_add";
	};

	class textRaison2 : Life_RscTitle {
		colorBackground[] = {0, 0, 0, 0};
		idc = 0901;
		shadow = 0;
		text = "Raison :";
		x = 0.33;
		y = 0.25;
		w = 0.36;
		h = 0.03;
	};

	class textRaison3 : Life_RscTitle {
		colorBackground[] = {0, 0, 0, 0};
		idc = 0897;
		shadow = 0;
		text = "Joueur :";
		x = 0.12;
		y = 0.25;
		w = 0.36;
		h = 0.03;
	};

	class textRaison4 : Life_RscTitle {
		colorBackground[] = {0, 0, 0, 0};
		idc = 0904;
		shadow = 0;
		text = "Details :";
		x = 0.32;
		y = 0.34;
		w = 0.36;
		h = 0.03;
	};

	class textRaison5 : Life_RscTitle {
		colorBackground[] = {0, 0, 0, 0};
		idc = 0905;
		shadow = 0;
		text = "Nom :";
		x = 0.33;
		y = 0.41;
		w = 0.36;
		h = 0.03;
	};

	class textRaison6 : Life_RscTitle {
		colorBackground[] = {0, 0, 0, 0};
		idc = 0906;
		shadow = 0;
		text = "Raison :";
		x = 0.33;
		y = 0.47;
		w = 0.36;
		h = 0.03;
	};

	class textRaison7 : Life_RscTitle {
		colorBackground[] = {0, 0, 0, 0};
		idc = 0907;
		shadow = 0;
		text = "Prime :";
		x = 0.33;
		y = 0.53;
		w = 0.36;
		h = 0.03;
	};

	class textRaison : Life_RscCombo {

		idc = 0896;

		//text = "";
		shadow = 0;
		sizeEx = 0.035;
		x = 0.33;
		y = 0.29;
		w = 0.36;
		h = 0.03;
		onLBSelChanged = "[_this] spawn life_fnc_wanted_add";

	};

	class DetailsRaison : Life_RscTitle
	{
		idc = 0902;
		text = "";
		shadow = 0;
		sizeEx = 0.035;
		colorBackground[] = {0, 0, 0, 0};

		x = 0.41;
		y = 0.47;
		w = 0.36;
		h = 0.03;
	};

	class DetailsNom : Life_RscTitle
	{
		idc = 0903;
		text = "";
		shadow = 0;
		sizeEx = 0.035;
		colorBackground[] = {0, 0, 0, 0};

		x = 0.39;
		y = 0.41;
		w = 0.36;
		h = 0.03;
	};

	class DetailsPrime : Life_RscTitle
	{
		idc = 0908;
		//text = "";
		shadow = 0;
		sizeEx = 0.035;
		colorBackground[] = {0, 0, 0, 0};

		x = 0.40;
		y = 0.53;
		w = 0.36;
		h = 0.03;
	};

	/*
	class BountyPrice : Life_RscText
	{
		idc = 2403;
		text = "";
		x = 0.34;
		y = 0.03;
		w = 0.6;
		h = 0.6;
	};*/

	class CloseButtonKey : Life_RscButtonMenu {
		idc = -1;
		text = "$STR_Global_Close";
		onButtonClick = "closeDialog 0;";
		x = -0.06 + (6.25 / 40) + (1 / 250 / (safezoneW / safezoneH));
		y = 0.8 - (1 / 25);
		w = (6.25 / 40);
		h = (1 / 25);
	};

	class AddButtonKey2 : Life_RscButtonMenu {
		idc = 0900;
		text = "$STR_Wanted_Confirm";
		onButtonClick = "[] call life_fnc_pardon; closeDialog 0;";
		x = 0.1 + (6.25 / 40) + (1 / 250 / (safezoneW / safezoneH));
		y = 0.8 - (1 / 25);
		w = (6.25 / 40);
		h = (1 / 25);
	};
};
};

Share this post


Link to post
Share on other sites

I think because below you are setting a string, to a string:

_type = ["Meurtre" , "Echapper de prison" , "Viole"];//already an array of strings

{
_raison lbAdd format [_x];
_raison lbSetData [(lbSize _raison)-1,str(_x)];
} forEach _type;

//can just be

{
_raison lbAdd format [_x];
_raison lbSetData [(lbSize _raison)-1,_x];
} forEach _type;

Share this post


Link to post
Share on other sites

Yeah JShock is right, it is returning ""Meurtre"" due to the string being turned into another string.

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  

×