cybercoco 16 Posted December 20, 2015 Hi, This stores the motor's health of the vehicle in the local variable _motorhealth _motorhealth = vehiclename getHit "motor"; then i want the result (_motorhealth) to show as the title of a addAction. The following code snippet is taken from the internet (raw) : _myname = name player; _addaction = amo addAction [_myname,"scripts\rearm.sqf"]; And the following is my non-working code _motorhealth = vehiclename getHit "motor"; vehiclename addAction [_motorhealth,"niania.sqf"]; Any ideas how it might work ? C.Coco Share this post Link to post Share on other sites
MrCopyright 107 Posted December 20, 2015 The title of the addAction has to be a string, so simply placing str _motorhealth should do the trick. Share this post Link to post Share on other sites
cybercoco 16 Posted December 20, 2015 Hey, thank you for your response. I have tried : str_motorhealth = wonno getHit "motor"; player sidechat format ["%1",str_motorhealth]; sleep 4; _lite = wonno addAction ["%1",str_motorhealth,""]; sleep 4; wonno removeaction _lite; You can see in the code, i've included "sidechat format" to debugg it and it does output it on sidechat. However it doesn't work as a addaction title... Hope there's a way ! Share this post Link to post Share on other sites
jshock 512 Posted December 20, 2015 wonno addAction [format ["%1",_motorhealth],{}]; Or wonno addAction [str(_motorhealth),{}]; 1 Share this post Link to post Share on other sites
cybercoco 16 Posted December 21, 2015 Yes ! The first code works and displays the variable as the addAction's title. this addAction [format ["%1",_variable],"file.sqf"]; Thank you Mrcopyright and Jshock ! Share this post Link to post Share on other sites
cybercoco 16 Posted December 22, 2015 oh, and another thing, I know that this makes the addAction red. this AddAction ["<t color=""#FF3B3E"">" + "Hi there", "file.sqf"]; So if i want to apply it to my code... Is that correct : this addAction ["<t color=""#FF3B3E"">" + "format ["%1",_variable]","file.sqf"]; I haven't tested it ingame... Share this post Link to post Share on other sites
jshock 512 Posted December 22, 2015 this addAction [format["<t color='#FF3B3E'>%1</t>",_variable],"file.sqf"]; Share this post Link to post Share on other sites
cybercoco 16 Posted December 22, 2015 Thanks again ! Share this post Link to post Share on other sites
cybercoco 16 Posted December 22, 2015 Sorry, me again ... Why won't this create an addAction ? _won = nearestObjects [player, ["C_Offroad_01_F"], 50]; _won1 = str _won select [1,5]; player sidechat _won1; // it outputs wonno _won1 addaction ["working","niania.sqf"]; Can I actually use a variable as the object target of addAction ? Share this post Link to post Share on other sites
MrCopyright 107 Posted December 22, 2015 The above code will not work because you're trying to place the addAction on a string. The data type has to be an object. Try this: _won = nearestObjects [player, ["C_Offroad_01_F"], 50]; _won1 = str _won select [1,5]; player sidechat _won1; // it outputs wonno _wonObject = call compile _won1; _wonObject addaction ["working","niania.sqf"]; And in reply to your question, you can have a variable as the target of an addAction as long as the variable's data type is an object. For example: _myVariable = player; _myVariable addAction ["Works", "works.sqf"]; Share this post Link to post Share on other sites
cybercoco 16 Posted December 22, 2015 Thank you so much for the help, that's very encouraging. I think i'm done now, maybe not, there's always something to do... _won = nearestObjects [player, ["C_Offroad_01_F"], 50]; _won = str _won select [1,5]; _won = call compile _won; // stores it into a variable ? an object ?? _won addaction ["working fine","niania.sqf"]; _hpmotor = _won getHit "motor"; hint format ["%1's health : %2",_won,_hpmotor]; And it works ! Share this post Link to post Share on other sites
MrCopyright 107 Posted December 22, 2015 No worries, glad to have helped. Share this post Link to post Share on other sites