Jump to content
Sign in to follow this  
hogmason

hint formating help

Recommended Posts

ok so i am calling a script that will show the reamaining targets this script is called using addaction command

2 things

1) why is the format not working

	if ((Target1_active ==0) && (Target2_active ==1) && (Enemy_Dead ==0)) then

	{
		[color="#FF0000"]Hintsilent "<t underline='true'>TARGETS REMAINING</t> <br/><br/> <t color='#ff0000'>HQ</t <br/><br/> <t color='#ff0000'>Eliminate all Russian Units</t";[/color]
	};


2)

i am using public variables to tell what is remaining to do but it doesnt seem to work does any 1 know what i have done wrong this is the full code


       //if all targets are still active
	if ((Target1_active ==1) && (Target2_active ==1) && (Enemy_Dead ==0)) then

	{
		Hintsilent "<t underline='true'>TARGETS REMAINING</t> <br/><br/> <t color='#ff0000'>Supply Dump</t <br/><br/> <t color='#ff0000'>HQ</t <br/><br/> <t color='#ff0000'>Eliminate all Russian Units</t";
	};

    //if Supply Dump and Eliminate Enemy targets are still active
	if ((Target1_active ==1) && (Target2_active ==0) && (Enemy_Dead ==0)) then

	{
		Hintsilent "<t underline='true'>TARGETS REMAINING</t> <br/><br/> <t color='#ff0000'>Supply Dump</t <br/><br/> <t color='#ff0000'>Eliminate all Russian Units</t";
	};		


    //if H.Q and Eliminate Enemy targets are still active
	if ((Target1_active ==0) && (Target2_active ==1) && (Enemy_Dead ==0)) then

	{
		Hintsilent "<t underline='true'>TARGETS REMAINING</t> <br/><br/> <t color='#ff0000'>HQ</t <br/><br/> <t color='#ff0000'>Eliminate all Russian Units</t";
	};		


   //if oNLY Eliminate Enemy targets are still active
   if ((Target1_active ==0) && (Target2_active ==0) && (Enemy_Dead ==0)) then

	{
		Hintsilent "<t underline='true'>TARGETS REMAINING</t> <br/><br/> <t color='#ff0000'>Eliminate all Russian Units</t";
	};	


Share this post


Link to post
Share on other sites

You could go with something like this:

_target 1 = "Supply Dump";
_target 2 = "HQ";
_enemy = "Eliminate all Russian Units";
_alldown = 0;
while {_alldown == 0} do {
if (Target1_active == 0) then {_target 1 = "";};
if (Target2_active == 0) then {_target 2 = "";};
if (Enemy_dead == 0) then {_enemy = "";};
hintsilent format ["TARGETS REMAINING,\n %1,\n %2,\ %3", _target 1, _target 2, _enemy];
sleep 1;
};

Though those If then If then if then are not pretty at all.

I don't know how you modify your public variables here, but i would have them set up as the string from the beginning. Whenever one of your objectives is completed, modify the corresponding varaible to be an empty string.

Then you only have to set a loop like this:

_alldown = 0;
while {_alldown == 0} do {
hintsilent format ["TARGETS REMAINING,\n %1,\n %2,\n %3", Target1_active, Target2_active, Enemy_dead];
sleep 1;
};

Share this post


Link to post
Share on other sites

Thanks guys,

Blackmamb

ive tried this and really like the idea its great but cant get it to work so i will just throw the details down

my variables are set by

for targets, on a sqf file called spawntargets.sqf

[color="#FF0000"]if (isnil "Target1_active") then {Target1_active = 0};
if (isnil "Target2_active") then {Target2_active = 0};[/color]

//////////////////////////////////////// target 1 /////////////////////////////////////////

[color="#FF0000"] Target1_active = 1; publicvariable "Target1_active";[/color]
       _distances = [100,200,300,400] call BIS_fnc_selectRandom;
       _target1positions = [getMarkerPos "E_Patrol", _distances, random 359, false, [0, 0]] call SHK_pos;	
       _target1 = createVehicle ["GUE_WarfareBVehicleServicePoint", _target1positions, [], 0, "NONE"];
		[color="#FF0000"]_target1 addeventhandler ["killed", { Target1_active = 0;publicvariable "Target1_active"; [sgt,nil,rgroupChat,"supply Dump has been destroyed"] call RE;}];[/color]
           _Target1 setVehicleInit "_Target1 addEventHandler [""HandleDamage"",{(_this select 4) == ""PipeBomb""}]" ;format ["%1 = this; this setVehicleVarName ""%1""",_target1];
           processInitCommands;			
sleep .5;

//////////////////////////////////////// target 2 /////////////

[color="#FF0000"]Target2_active = 1; publicvariable "Target2_active";[/color]
_distances = [100,200,300,400] call BIS_fnc_selectRandom;
      _target2positions = [getMarkerPos "E_Patrol", _distances, random 359, false, [0, 0]] call SHK_pos;	
      _target2 = createVehicle ["BTR90_HQ_unfolded", _target2positions, [], 0, "NONE"];
               [color="#FF0000"]_target2 addeventhandler ["killed", { Target2_active = 0;publicvariable "Target2_active"; [sgt,nil,rgroupChat,"HQ has been destroyed"] call RE;}];[/color]
               _Target2 setVehicleInit "_Target2 addEventHandler [""HandleDamage"",{(_this select 4) == ""PipeBomb""}]" ;format ["%1 = this; this setVehicleVarName ""%1""",_target2];
               processInitCommands;
sleep .5;

for enemy on a seperate sqf

if (isServer) then
{
  waituntil {!isnil "bis_fnc_init"};

   [color="#FF0000"]if (isnil "Enemy_Dead") then {Enemy_Dead = 0};[/color]

  Enemy_Dead = 0;publicvariable "Enemy_Dead";

     _dt = createTrigger ["EmptyDetector", getMarkerPos "REIN"];
     _dt setTriggerArea [600, 600, 0, false];
     _dt setTriggerActivation ["EAST", "NOT PRESENT", false];
    [color="#FF0000"] _dt setTriggerStatements ["this","Enemy_Dead = 1; publicvariable 'Enemy_Dead';", ""];
[/color]
};


and this is what i tried for the hints from you.


_target1 = "Supply Dump";
_target2 = "HQ";
_enemy = "Eliminate all Russian Units";
_alldown = 0;
while {_alldown == 0} do {
if (Target1_active == 1) then {_target1 = "";};
if (Target2_active == 1) then {_target2 = "";};
if (Enemy_dead == 0) then {_enemy = "";};
hintsilent format ["TARGETS REMAINING,\n %1,\n %2,\ %3", _target1, _target2, _enemy];
sleep 1;
};

Share this post


Link to post
Share on other sites

Damn i must have been real drunk when i wrote this. It's so damn ugly.

A few remarks:

1- first, i have not even looked at the detailed code yet, eventhandlers and all that. I assume you know what you're doing here, and that the issue's coming from somewhere else.

2- this is strange:

if (isnil "Target1_active") then {[color="#FF0000"]Target1_active = 0[/color]};
if (isnil "Target2_active") then {Target2_active = 0};

//////////////////////////////////////// target 1 /////////////////////////////////////////

 [color="#FF0000"]Target1_active = 1[/color]; publicvariable "Target1_active";

Seems like nothing is happening between those two lines. Wich makes me wonder: Why make two of them? (same for the second variable)

Anyway, the first two lines are missing semicolons so they don't do anything yet.

3- Seems like you somehow reversed it? In the last ugly bit of code (mine), you've set it up so that if Target1_active == 1 (meaning the target's still alive, i guess) the hint will display nothing. Should be the other way around. Same for the second variable. The third being set up backwards (Enemy_dead == 0 means the enemy is still alive), you still have the hint display nothing. So basically replace the 0 by 1 and 1 by 0.

4- That test (if then) is really ugly. I mean, really. It's gonna be performed each second, and there's three of them.

I'd go with something more like:

if (isnil "Target1_active") then {Target1_active = "Supply Dump";};
if (isnil "Target2_active") then {Target2_active = "HQ";};
publicvariable "Target1_active";
publicvariable "Target2_active";

blahblah

_target1 addeventhandler ["killed", { Target1_active = " ";publicvariable "Target1_active"; [sgt,nil,rgroupChat,"supply Dump has been destroyed"] call RE;}];
_target2 addeventhandler ["killed", { Target2_active = " ";publicvariable "Target2_active"; [sgt,nil,rgroupChat,"HQ has been destroyed"] call RE;}];

blahblah

if (isnil "Enemy_Dead") then {Enemy_Dead = "Eliminate all Russian Units";};
publicvariable "Enemy_Dead";

some more blah blah

_dt setTriggerStatements ["this","Enemy_Dead = " "; publicvariable 'Enemy_Dead';", ""];

_alldown = 0;
while {_alldown == 0} do {
hintsilent format ["TARGETS REMAINING,\n %1,\n %2,\n %3", Target1_active, Target2_active, Enemy_dead];
       sleep 1;
};

Not much gain, but i believe it's a good thing to get used to avoid unnecessary checks.

Share this post


Link to post
Share on other sites

cheers mate so i got it working with

_target_1 = "Supply Dump";
_target_2 = "HQ";
_enemy_3= "Eliminate all Russian Units";
_alldown = 0;
while {_alldown == 0} do {
if (Target1_active == 0) then {_target_1 = "";};
if (Target2_active == 0) then {_target_2 = "";};
if (Enemy_dead == 1) then {_enemy_3 = "";};
hintsilent formatText ["TARGETS REMAINING,\n %1,\n %2,\ %3", _target_1, _target_2, _enemy_3];
sleep 1;
};


but it shows all targets remaining even when there is no task available yet.

---------- Post added at 10:42 ---------- Previous post was at 10:25 ----------

why is this not working

[color="#FF0000"]if (Enemy_Dead == 0) then  //if this equals 0 then the enemy at task site is still alive so the below hint will show remaining targets
{[/color]

   _target_1 = "Supply Dump";
   _target_2 = "HQ";
   _enemy_3 = "Eliminate all Russian Units";
   _alldown = 0;
   while {_alldown == 0} do 
{
    if (Target1_active == 0) then {_target_1 = "";};
    if (Target2_active == 0) then {_target_2 = "";};
    if (Enemy_dead == 1) then {_enemy_3 = "";};
   hintsilent formatText ["TARGETS REMAINING,\n %1,\n %2,\ %3", _target_1, _target_2, _enemy_3];
   sleep 1;
    };

}
[color="#FF0000"]else // so if it equals 1 it means enemy are dead so the task would be compleate so thefere the below hint will show
{

   hintsilent formatText ["No Targets Available"];

};[/color]


Share this post


Link to post
Share on other sites

Oh my bad, i'm sorry. I didn't see you were calling this script from addAction!

Do you want the hint to be just displayed once, everytime you call the action?

I was thinking about something that was always displayed.

Share this post


Link to post
Share on other sites

The problem with addAction is that it's local. So you can't really have it run global scripts with feedback hints for everyone easily. Usually what you'd do is just have the addAction set and publicize a variable and have a trigger or publicvariableeventhandler actually run the script after that.

Share this post


Link to post
Share on other sites

What he said. And as we're talking about an occasional hint, you don't need the while bit.

    _target_1 = "Supply Dump";
   _target_2 = "HQ";
   _enemy_3 = "Eliminate all Russian Units";

    if (Target1_active == 0) then {_target_1 = "";};
    if (Target2_active == 0) then {_target_2 = "";};
    if (Enemy_dead == 1) then {_enemy_3 = "";};
   hintsilent formatText ["TARGETS REMAINING,\n %1,\n %2,\ %3", _target_1, _target_2, _enemy_3];

Once again i strongly suggest you choose string values for those public variables. Rids you of unnecessary checks.

Share this post


Link to post
Share on other sites

yeah i do want to but just a bit afraid of doing it as ive just spent 13 days straight fixing my errors and dont want to create any more

this is how i done them

for my 2 targets its nothing in my main init.sqf just

if (isServer) then
{
[color="#FF0000"]if (isnil "Target1_active") then {Target1_active = 0};
if (isnil "Target2_active") then {Target2_active = 0};[/color]
waituntil {!isnil "bis_fnc_init"};

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                                                   //
//                      ----------      Setup SUPPLY dUMP    ----------                                              //
//                                                                                                                   //
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 
[color="#FF0000"]  Target1_active = 1; publicvariable "Target1_active";[/color]
       _distances = [100,200,300,400] call BIS_fnc_selectRandom;
       _target1positions = [getMarkerPos "E_Patrol", _distances, random 359, false, [0, 0]] call SHK_pos;	
       _target1 = createVehicle ["GUE_WarfareBVehicleServicePoint", _target1positions, [], 0, "NONE"];
		[color="#FF0000"]_target1 addeventhandler ["killed", { Target1_active = 0;publicvariable "Target1_active"; [sgt,nil,rgroupChat,"supply Dump has been destroyed"] call RE;}];[/color]
           _Target1 setVehicleInit "_Target1 addEventHandler [""HandleDamage"",{(_this select 4) == ""PipeBomb""}]" ;format ["%1 = this; this setVehicleVarName ""%1""",_target1];
           processInitCommands;			
sleep .5;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                                                   //
//                      ----------      Setup HQ    ----------                                                       //
//                                                                                                                   //
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 
[color="#FF0000"] Target2_active = 1; publicvariable "Target2_active";[/color]
_distances = [100,200,300,400] call BIS_fnc_selectRandom;
      _target2positions = [getMarkerPos "E_Patrol", _distances, random 359, false, [0, 0]] call SHK_pos;	
      _target2 = createVehicle ["BTR90_HQ_unfolded", _target2positions, [], 0, "NONE"];
               [color="#FF0000"]_target2 addeventhandler ["killed", { Target2_active = 0;publicvariable "Target2_active"; [sgt,nil,rgroupChat,"HQ has been destroyed"] call RE;}];[/color]
               _Target2 setVehicleInit "_Target2 addEventHandler [""HandleDamage"",{(_this select 4) == ""PipeBomb""}]" ;format ["%1 = this; this setVehicleVarName ""%1""",_target2];
               processInitCommands;
sleep .5;


and for my enemy dead one

if (isServer) then
{
if (isnil "Enemy_Dead") then {Enemy_Dead = 0};
  waituntil {!isnil "bis_fnc_init"};

[color="#FF0000"]    if (isnil "Enemy_Dead") then {Enemy_Dead = 0};

  Enemy_Dead = 0;publicvariable "Enemy_Dead";[/color]

     _dt = createTrigger ["EmptyDetector", getMarkerPos "REIN"];
     _dt setTriggerArea [600, 600, 0, false];
     _dt setTriggerActivation ["EAST", "NOT PRESENT", false];
[color="#FF0000"]      _dt setTriggerStatements ["this","Enemy_Dead = 1; publicvariable 'Enemy_Dead';", ""];[/color]

};


would you be able to adjust it for me sorry for the hassle

---------- Post added at 23:56 ---------- Previous post was at 23:55 ----------

The problem with addAction is that it's local. So you can't really have it run global scripts with feedback hints for everyone easily. Usually what you'd do is just have the addAction set and publicize a variable and have a trigger or publicvariableeventhandler actually run the script after that.

lol that lost me

---------- Post added at 00:01 ---------- Previous post was at 23:56 ----------

sorry man just remembered you posted it earlier ill just post my new code with what you said to do for u to look over see if i stuffed up

---------- Post added at 00:04 ---------- Previous post was at 00:01 ----------

so new target 1 & 2

if (isServer) then
{
[color="#FF0000"]if (isnil "Target1_active") then {Target1_active = "Supply Dump";};
if (isnil "Target2_active") then {Target2_active = "HQ";};
publicvariable "Target1_active";
publicvariable "Target2_active";[/color]
waituntil {!isnil "bis_fnc_init"};

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                                                   //
//                      ----------      Setup SUPPLY dUMP    ----------                                              //
//                                                                                                                   //
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 
       _distances = [100,200,300,400] call BIS_fnc_selectRandom;
       _target1positions = [getMarkerPos "E_Patrol", _distances, random 359, false, [0, 0]] call SHK_pos;	
       _target1 = createVehicle ["GUE_WarfareBVehicleServicePoint", _target1positions, [], 0, "NONE"];
		[color="#FF0000"]_target1 addeventhandler ["killed", { Target1_active = " ";publicvariable "Target1_active"; [sgt,nil,rgroupChat,"supply Dump has been destroyed"] call RE;}];[/color]
           _Target1 setVehicleInit "_Target1 addEventHandler [""HandleDamage"",{(_this select 4) == ""PipeBomb""}]" ;format ["%1 = this; this setVehicleVarName ""%1""",_target1];
           processInitCommands;			
sleep .5;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                                                   //
//                      ----------      Setup HQ    ----------                                                       //
//                                                                                                                   //
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 
_distances = [100,200,300,400] call BIS_fnc_selectRandom;
      _target2positions = [getMarkerPos "E_Patrol", _distances, random 359, false, [0, 0]] call SHK_pos;	
      _target2 = createVehicle ["BTR90_HQ_unfolded", _target2positions, [], 0, "NONE"];
              [color="#FF0000"] _target2 addeventhandler ["killed", { Target2_active = " ";publicvariable "Target2_active"; [sgt,nil,rgroupChat,"HQ has been destroyed"] call RE;}];[/color]
               _Target2 setVehicleInit "_Target2 addEventHandler [""HandleDamage"",{(_this select 4) == ""PipeBomb""}]" ;format ["%1 = this; this setVehicleVarName ""%1""",_target2];
               processInitCommands;
sleep .5;

};


new enemy dead


if (isServer) then
{

[color="#FF0000"] if (isnil "Enemy_Dead") then {Enemy_Dead = "Eliminate all Russian Units";};
publicvariable "Enemy_Dead";[/color]

waituntil {!isnil "bis_fnc_init"};


     _dt = createTrigger ["EmptyDetector", getMarkerPos "REIN"];
     _dt setTriggerArea [600, 600, 0, false];
     _dt setTriggerActivation ["EAST", "NOT PRESENT", false];
[color="#FF0000"]      _dt setTriggerStatements ["this","Enemy_Dead = " "; publicvariable 'Enemy_Dead';", ""];[/color]

};

is that right

---------- Post added at 00:05 ---------- Previous post was at 00:04 ----------

so what do i change this to

waitUntil{(Target1_active ==0) && (Target2_active ==0) && (Enemy_Dead ==1)};

---------- Post added at 00:07 ---------- Previous post was at 00:05 ----------

to this

waitUntil{(Target1_active =="Supply Dump") && (Target2_active =="HQ") && (Enemy_Dead =="Eliminate all Russian Units")};

---------- Post added at 00:11 ---------- Previous post was at 00:07 ----------

im actually getting an error on this line

_dt setTriggerStatements ["this","Enemy_Dead = " "; publicvariable 'Enemy_Dead';", ""];

Share this post


Link to post
Share on other sites

Just change them to true/false instead of random strings or numbers, that wait they are booleans and booleans are fun at parties.

Check your quotes. TriggerStatement has 3 arguments surrounded by double quotes: ["", "", ""];

You can't then have double quotes inside of them [""," "" ",""] since it'll break the syntax.

Instead you either need to use single quotes within the double quotes: ["", " ' ' ", ""] or double-up on the double quotes: ["", " "" "" ", ""];

Share this post


Link to post
Share on other sites

Sorry i don't have time to test neither to do more. I just read kylania's message and didn't get it (regarding booleans?).

init.sqf

broadcasted = 0;
if (isServer) then
{
if (isnil "Target1_active") then {Target1_active = "Supply Dump";};
if (isnil "Target2_active") then {Target2_active = "HQ";};
waituntil {!isnil "bis_fnc_init"};

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                                                   //
//                      ----------      Setup SUPPLY dUMP    ----------                                              //
//                                                                                                                   //
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 
publicvariable "Target1_active";
       _distances = [100,200,300,400] call BIS_fnc_selectRandom;
       _target1positions = [getMarkerPos "E_Patrol", _distances, random 359, false, [0, 0]] call SHK_pos;	
       _target1 = createVehicle ["GUE_WarfareBVehicleServicePoint", _target1positions, [], 0, "NONE"];
		_target1 addeventhandler ["killed", { Target1_active = "Supply Dump is destroyed";publicvariable "Target1_active"; [sgt,nil,rgroupChat,"supply Dump has been destroyed"] call RE;}];
           _Target1 setVehicleInit "_Target1 addEventHandler [""HandleDamage"",{(_this select 4) == ""PipeBomb""}]" ;format ["%1 = this; this setVehicleVarName ""%1""",_target1];
           processInitCommands;			
sleep .5;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                                                   //
//                      ----------      Setup HQ    ----------                                                       //
//                                                                                                                   //
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 
publicvariable "Target2_active";
_distances = [100,200,300,400] call BIS_fnc_selectRandom;
      _target2positions = [getMarkerPos "E_Patrol", _distances, random 359, false, [0, 0]] call SHK_pos;	
      _target2 = createVehicle ["BTR90_HQ_unfolded", _target2positions, [], 0, "NONE"];
               _target2 addeventhandler ["killed", { Target2_active = "HQ is destroyed";publicvariable "Target2_active"; [sgt,nil,rgroupChat,"HQ has been destroyed"] call RE;}];
               _Target2 setVehicleInit "_Target2 addEventHandler [""HandleDamage"",{(_this select 4) == ""PipeBomb""}]" ;format ["%1 = this; this setVehicleVarName ""%1""",_target2];
               processInitCommands;
sleep .5;



if (isnil "Enemy_Dead") then {Enemy_Dead = "Kill all enemies";};


publicvariable "Enemy_Dead";

_dt = createTrigger ["EmptyDetector", getMarkerPos "REIN"];
_dt setTriggerArea [600, 600, 0, false];
_dt setTriggerActivation ["EAST", "NOT PRESENT", false];
_dt setTriggerStatements ["this","Enemy_Dead = ""All enemies are dead""; publicvariable ""Enemy_Dead"";", ""];

};

In your player's init:

_nul = addAction ["Check remaining targets", "broadcast.sqf];

broadcast.sqf

broadcasted = 1;
publicVariable "broadcasted";
sleep 5;
broadcasted = 0;
publicVariable "broadcasted";

Now have a trigger, set to repeatedly.

In the condition box:

broadcasted == 1

In the On Act. box:

hintsilent format ["TARGETS REMAINING,\n %1,\n %2,\n %3", Target1_active, Target2_active, Enemy_dead];

Now, have you considered just setting tasks? Cause that really looks like what simple tasks might do, without any addAction involved.

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  

×