Jump to content
Sign in to follow this  
BEAKSBY

Hint, parseText format, composeText,... confused please help

Recommended Posts

Hi Folkes,

I'm trying to make my hint message easier to script. Instead of one continuous line I would like to parse it so I can read the script better.

Why don't the following two scripts equal?

This works:

hint parsetext format ["<t size='0.85' align='left'>You killed: </t><t size='0.85' align='left'>%1</t><br/><t size='0.85' align='left'>You gained $</t><t size='0.85' color='#ff0000' align='left'> %2</t><br/><t size='0.85' align='left'>Cash Remaining $</t> <t size='0.85' color='#ff0000' align='left'>%3</t>", _textKilled, _amount, _money];

But this doesn't match up?

_text1 = parsetext format ["<t size='0.85' align='left'>You killed: </t><t size='0.85' align='left'>%1</t><br/>", _textKilled];
_text2 = parsetext format ["<t size='0.85' align='left'>You gained $</t><t size='0.85' color='#ff0000' align='left'> %1</t><br/>",_amount];
_text3 = parsetext format ["<t size='0.85' align='left'>Cash Remaining $</t> <t size='0.85' color='#ff0000' align='left'>%1</t>",_money];
hint parseText (_text1 + _text2 + _text3);


/* My notes on hint
https://community.bistudio.com/wiki/hint
starL  = "<img image='\ca\ui\data\debr_star.paa' align='left'/>";
_starL  = _starL + _starL + _starL;
_starR  = "<img image='\ca\ui\data\debr_star.paa' align='right'/>";
_starR  = _starR + _starR + _starR;
_title  = "<t color='#ff0000' size='1.2' shadow='1' shadowColor='#000000' align='center'>TITLE</t><br/><br/>";
_text   = "Bla bla bla bla bla...";
hint parseText (_starL + _starR + _title + _text);
*/

Share this post


Link to post
Share on other sites

You are parsing the text twice. Ret doing this

_text1 = format ["<t size='0.85' align='left'>You killed: </t><t size='0.85' align='left'>%1</t><br/>", _textKilled]; 
_text2 = format ["<t size='0.85' align='left'>You gained $</t><t size='0.85' color='#ff0000' align='left'> %1</t><br/>",_amount]; 
_text3 = format ["<t size='0.85' align='left'>Cash Remaining $</t> <t size='0.85' color='#ff0000' align='left'>%1</t>",_money]; 
hint parseText (_text1 + _text2 + _text3); 

Share this post


Link to post
Share on other sites

Hi Again,

Please help with this one, it is supposed to display all the units from the do loop in the hint display.

                
_textcrew = [];
for "_i" from  0 to (count veh)-1  do {   // check value for each unit in vehicle
if (_unitInVehicle == ((veh select _i) select 1)) then {_unitsInVehicleSumValue = _unitsInVehicleSumValue + (((veh select _i) select 0)/2)};   // each unit value is half original price 
_vehicle = getText (configFile >> "cfgVehicles" >> ((veh select _i) select 1) >> "displayname");
_picture = getText (configFile >> "cfgVehicles" >> ((veh select _i) select 1) >> "picture");
_textcrew = parseText (_textcrew + format ["<t size='0.85' ><img size='1' image='%1'/><t size='0.85'> %2", _picture,_vehicle]);
hint _textcrew;
}; 

The hint with this works but does not add the _textcrew as desired.

_textcrew = parseText format ["<t size='0.85' ><img size='1' image='%1'/><t size='0.85'> %2", _picture,_vehicle];
hint _textcrew;

Edited by BEAKSBY

Share this post


Link to post
Share on other sites

possibly something like this

 _textcrew = str _textcrew + str (parseText  format ["<t size='0.85' ><img size='1' image='%1'/><t size='0.85'> %2", _picture,_vehicle]);

Share this post


Link to post
Share on other sites

I've tried this...

_textcrew = [];
for "_i" from  0 to (count veh)-1  do {   //---check value for each unit killed in vehicle and obtain its name and picture
if (_unitInVehicle == ((veh select _i) select 1)) then {_unitsInVehicleSumValue = _unitsInVehicleSumValue + (((veh select _i) select 0)/2);   // each unit value is half original price listed above
_vehicle = getText (configFile >> "cfgVehicles" >> ((veh select _i) select 1) >> "displayname");		             
_picture = getText (configFile >> "cfgVehicles" >> ((veh select _i) select 1) >> "picture");
_textcrew = str _textcrew + str (parseText format ["<t size='0.85' ><img size='1' image='%1'/><t size='0.85'> %2", _picture,_vehicle]);
hint _textcrew;
};
}; 

...and it returns this [] crewman. But the vehicle has a crew of 3. SO I was expecting crewmancrewmancrewman. It also doesn't seem to find the pictures for soldiers in configFile >> "cfgVehicles" >>

However, this works beautifully with picture and displayname,

_textvehicle = "";
for "_i" from  0 to (count veh)-1  do {   //---also add the value of vehicle killed and obtain its name and picture
if (_unitType == ((veh select _i) select 1)) then {_unitValue = (((veh select _i) select 0)/2);   //---each unit value is half original price listed above
_vehicle = getText (configFile >> "cfgVehicles" >> ((veh select _i) select 1) >> "displayname");		             
_picture = getText (configFile >> "cfgVehicles" >> ((veh select _i) select 1) >> "picture");
_textvehicle = parsetext format ["<t size='0.85' ><img size='1' image='%1'/><t size='0.85'> %2", _picture,_vehicle];
hint _textvehicle;
};	
}; 

Note the declaration for the vehicles variable is _textvehicle = "";

I think for the crew I need to declare an array of empty strings?

Edited by BEAKSBY

Share this post


Link to post
Share on other sites

But isn't veh an array of vehicle_types and costs?

It's not pointing to an actual vehicle is it.

((veh select _i) select 1)) is type of vehicle.

Share this post


Link to post
Share on other sites

correct veh is an array

veh = [[1200, "B_MBT_01_TUSK_F"],[900, "B_APC_Tracked_01_rcws_F"],[750, "B_APC_Tracked_01_AA_F"],[600, "I_APC_Wheeled_03_cannon_F"],

[300,"B_MRAP_01_gmg_F"],[150,"B_MRAP_01_hmg_F"],[100,"B_G_Offroad_01_armed_F"],[200,"B_static_AT_F"],[200, "B_static_AA_F"],[150,"B_soldier_LAT_F"],

[100,"B_G_Soldier_LAT_F"],[25, "B_Soldier_F"],[150,"B_GMG_01_high_F"],[100,"B_HMG_01_high_F"],[1200, "O_MBT_02_cannon_F"],[900, "O_APC_Tracked_02_cannon_F"],

[750, "O_APC_Tracked_02_AA_F"],[600, "O_APC_Wheeled_02_rcws_F"],[300,"O_MRAP_02_gmg_F"],[150,"O_MRAP_02_hmg_F"],[100,"O_G_Offroad_01_armed_F"],

[200,"O_static_AT_F"],[200, "O_static_AA_F"],[150,"O_soldierU_LAT_F"],[100,"O_G_Soldier_LAT_F"],[150,"O_GMG_01_high_F"],[100,"O_HMG_01_high_F"],

[25, "O_Soldier_F"], [66, "O_crew_F"],[66, "B_crew_F"]];

Basically I was trying to build a string for the units killed inside the vehicle as well as the vehicle itself and pass it to my money script. So it would display "you killed [vehicle and units killed inside], you gained [total of vehicle and units killed inside] and current account [current balance + gained for kills - purchased vehicles].

I've got everything working so far except for the concatonated string of units killed inside and the vehicle.

Pictures of the units and vehicles is a "nice to have" and would be faster that reading a message with string/text information.

Edited by BEAKSBY

Share this post


Link to post
Share on other sites

If you have an evh attached to the vehicle youshould be able to obtain enough info.

this addeventhandler ["killed",{_this execvm "script.sqf"}];

_textvehicle = "";
_unit = (_this select 0);
money=0;

{
__x =_x;	
{
if (( typeof _x) in __x ) then {money = money + (__x select 0)};	
} foreach crew _unit + [_unit]; 
} foreach veh; 

_vehicle = getText (configFile >> "cfgVehicles" >> typeof _unit >> "displayname");                     
_picture = getText (configFile >> "cfgVehicles" >> typeof _unit  >> "picture");

_textvehicle = parsetext format ["<img size='2' image='%1'/><t size='1.2'><br/> %2 <t size='1'><br/> %3 Crew <t size='0.85'> <br/>Reward %4", _picture,_vehicle,count crew _unit,money];

hint _textvehicle;

If it's not a vehicle than you could call another script from the EVH or add checks to the script so it runs the correct parsetext format.

Share this post


Link to post
Share on other sites

Thanks F2k Sel,

Damn.

You're good you.

:)

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  

×