Jump to content

Sign in to follow this  
187Killa

End mission when score is reached

Recommended Posts

  On 10/2/2017 at 4:14 AM, pierremgi said:

Too much errors and black areas for HUD.

For example, you reset to zero pointsA and points B... at each call.

And died units are always civilian....

 

Replace all of that (both codes) and:

 

remove the tick on "allow score ai" in multiplayer settings (editor) to avoid double score.

in init.sqf:


 

addMissionEventHandler ["eachFrame",{
  PointsA = scoreSide west;
  PointsR = scoreSide east;
  hintSilent format ["west: %1, east: %2",pointsA,PointsR];   // replace by HUD (already on each frame so should be easy)
}];

addMissionEventHandler ["entityKilled",{
  params ["_killed","_killer","_instigator"];
  if (!isPlayer _instigator) then { (side _instigator) addScoreSide 1};
  };
}];

 

Now, do what you want inside the first event handler, instead of hint. (HUD here but which one?...)

 

when you say replace by hud in hint do you mean 

hintSilent format [call compile preprocessFileLineNumbers "scripts\hud\hud_create.sqf";]

hudcreate.sqf
 

  Reveal hidden contents



hudupdate.sqf
 

  Reveal hidden contents


 

 

Share this post


Link to post
Share on other sites

No,

you create your hud once! there is no need to recall that on each frame.

So , hud_create.sqf is called in int.sqf and it's OK for it.

 

Now, you want to refresh the data in HUD. That's the job of hudupdate.

You don't need to create a sqf for that. Just copy paste. This should look like:


 

addMissionEventHandler ["eachFrame",{
  PointsA = scoreSide west;
  PointsR = scoreSide east;
  disableSerialization;
  _ui = uiNamespace getVariable "DTASHUD";
  (_ui displayCtrl 1001) ctrlSetText format ["%1:%2",minutos,segundos];
  (_ui displayCtrl 1101) ctrlSetText format ["%1/%2",pointsA,pointlimit];
  (_ui displayCtrl 1102) ctrlSetText format ["%1/%2",pointsR,pointlimit];
}];

addMissionEventHandler ["entityKilled",{
  params ["_killed","_killer","_instigator"];
  if (!isPlayer _instigator && isServer) then { (side _instigator) addScoreSide 1};
 }];

 

... if minutos, segundos pointlimit make sense... I don't know how they work so far.

 

 

 

Share this post


Link to post
Share on other sites
  On 10/2/2017 at 5:10 AM, pierremgi said:

No,

you create your hud once! there is no need to recall that on each frame.

So , hud_create.sqf is called in int.sqf and it's OK for it.

 

Now, you want to refresh the data in HUD. That's the job of hudupdate.

You don't need to create a sqf for that. Just copy paste. This should look like:


 

addMissionEventHandler ["eachFrame",{
  PointsA = scoreSide west;
  PointsR = scoreSide east;
  disableSerialization;
  _ui = uiNamespace getVariable "DTASHUD";
  (_ui displayCtrl 1001) ctrlSetText format ["%1:%2",minutos,segundos];
  (_ui displayCtrl 1101) ctrlSetText format ["%1/%2",pointsA,pointlimit];
  (_ui displayCtrl 1102) ctrlSetText format ["%1/%2",pointsR,pointlimit];
}];

addMissionEventHandler ["entityKilled",{
  params ["_killed","_killer","_instigator"];
  if (!isPlayer _instigator && isServer) then { (side _instigator) addScoreSide 1};
 }];

 

 

 

 

okay i didnt know if i had to do what i been doing with the compile process numbers! Thank you also
this statement has a missing }

i add one where i thought but then it just gives the error on new line 

 

  Reveal hidden contents

 

Share this post


Link to post
Share on other sites
  On 10/2/2017 at 5:17 AM, pierremgi said:

copy/paste the last one.

init.sqf
 

  Reveal hidden contents

keeps saying im missing a } or {

EDIT--------------------
fixed the bracket issue but getting a generic error in expressions  west and east, but since they are listed in the init they should be do i need to make 
pointsA=scoreSide West;

publicvariable = A; etc...?

 

  Reveal hidden contents

 

Share this post


Link to post
Share on other sites

I never wrote that.

   hintSilent format [scripts\hud\hud_update.sqf];   // replace by HUD (already on each frame so should be easy)  ?????

So, read twice.

Share this post


Link to post
Share on other sites
  On 10/2/2017 at 7:19 AM, pierremgi said:

I never wrote that.

   hintSilent format [scripts\hud\hud_update.sqf];   // replace by HUD (already on each frame so should be easy)  ?????

So, read twice.

i figured it out. turns out i dont even need to do that i can leave my compileprocess.... and the hud still updates??? i dunno somehow it works and thats all that matters to me! Thank you so much for your time and effort! I have learned a great deal from you! Hoping pay it forward on here! thanks again!

  • Like 1

Share this post


Link to post
Share on other sites
  On 10/2/2017 at 7:19 AM, pierremgi said:

I never wrote that.

   hintSilent format [scripts\hud\hud_update.sqf];   // replace by HUD (already on each frame so should be easy)  ?????

So, read twice.

Ran into last problem.
a) my timer on hud will just reset back to inital time for some reason on dedicated server but works from local thats why i didnt notice till i put everything on dedicated to test for errors. its starts at 25:59 once its reaches 25:00 it goes back to 25:59

time.sqf
 

  Reveal hidden contents

Hud update.sqf

  Reveal hidden contents

 

Share this post


Link to post
Share on other sites

_hour = ????

 

just an example:


 

_time = 25 * 60;
while {_time >= 0 and !(mission_accomplished) } do {
   _time = _time - 1;   
   if (_time != -1) then {
     _str = [(_time)/3600+0.0001,"HH:MM:SS"] call BIS_fnc_timetostring;
     _str = _str select [3];
     format["Time left to complete mission: \n %1", _str] remoteExec ["hintSilent", 0];
   };
   uisleep 1;
};

 

 

Also:

I remarked you shift again on your HUD-update.sqf... I wrote you can copy/paste the code in init.sqf instead...

 

Anyway, just a remark:

(_ui displayCtrl 1001) ctrlSetText format ["%1:%2",_minute,_second];  can't work due to undefined local variables.

 

timer = 25 * 60;  // reference global variable on PC. DON'T publicVariable it (server only will do)

if (isServer) then {
[] spawn {
  while {timer >= 0 and !(mission_accomplished) } do {
   timer = timer - 1;   
   if (timer != -1) then {
     publicVariable "timer";
     _str = [timer/3600+0.0001,"HH:MM:SS"] call BIS_fnc_timetostring;
     _str = _str select [3];
     format["Time left to complete mission: \n %1", _str] remoteExec ["hintSilent", 0];
   };
   uisleep 1;
 };
};
}:


addMissionEventHandler ["eachFrame",{
  PointsA = scoreSide west;
  PointsR = scoreSide east;
  disableSerialization;
  _ui = uiNamespace getVariable "DTASHUD";
  (_ui displayCtrl 1001) ctrlSetText format ["%1",timer];
  (_ui displayCtrl 1101) ctrlSetText format ["%1/%2",pointsA,pointlimit];
  (_ui displayCtrl 1102) ctrlSetText format ["%1/%2",pointsR,pointlimit];
}];

addMissionEventHandler ["entityKilled",{
  params ["_killed","_killer","_instigator"];
  if (!isPlayer _instigator && isServer) then { (side _instigator) addScoreSide 1};
 }];

 

should work.

 

Share this post


Link to post
Share on other sites
  On 10/2/2017 at 3:53 PM, pierremgi said:

_hour = ????

 

just an example:


 

_time = 25 * 60;
while {_time >= 0 and !(mission_accomplished) } do {
   _time = _time - 1;   
   if (_time != -1) then {
     _str = [(_time)/3600+0.0001,"HH:MM:SS"] call BIS_fnc_timetostring;
     _str = _str select [3];
     format["Time left to complete mission: \n %1", _str] remoteExec ["hintSilent", 0];
   };
   uisleep 1;
};

 

Yea I have wrote like 3 different time scripts now. None of them are doing the job...

for some reason 
this part of init.sqf isnt working at all

  Reveal hidden contents

I have found a workaround for it though, if i remove everything below PointsR=scoreSide east; the hud will display and work but with them present the hud never shows up. 

the file that have the variables for the HUD are below.
engine.sqf
 

  Reveal hidden contents


init.sqf just in case I have messed something up in it
 

  Reveal hidden contents



 

Share this post


Link to post
Share on other sites

The first script was a working example for nice timer (not your code). Depending on where your write it. But, frankly, it works if you spawn it.

 

Anyway, difficult to patch so many corrections in all your scripts.

For all your personal scripts:

- engine.sqf: erase it and just run my code. You don't have to publicVariable score Sides

- hud_update.sqf erase it // it's on each framed if you follow my code!

- init.sqf. It seems I wrote one for you.

 

You have too many errors, because you have no clue of what to do but you are trying always something different.

  For example, your local variables aren't defined inside your EHs, mine work..

 

At this time, I suggest you this init.sqf, coming with initplayerlocal.sqf already written in previous page.

You can forget some of your scripts (see my comments in the following init.sqf:
 

  Reveal hidden contents

 

 


 

Share this post


Link to post
Share on other sites
  On 10/2/2017 at 9:07 PM, pierremgi said:

The first script was a working example for nice timer (not your code). Depending on where your write it. But, frankly, it works if you spawn it.

 

Anyway, difficult to patch so many corrections in all your scripts.

For all your personal scripts:

- engine.sqf: erase it and just run my code. You don't have to publicVariable score Sides

- hud_update.sqf erase it // it's on each framed if you follow my code!

- init.sqf. It seems I wrote one for you.

 

You have too many errors, because you have no clue of what to do but you are trying always something different.

  For example, your local variables aren't defined inside your EHs, mine work..

 

At this time, I suggest you this init.sqf, coming with initplayerlocal.sqf already written in previous page.

You can forget some of your scripts (see my comments in the following init.sqf:
 

  Reveal hidden contents

 

 


 

Man That works perfectly. Hud works only thing I dont like and wish to change is the timer on my hud it shows 1560 seconds instead of MM:SS what would I change in your script to change the format of that like the hint of time left on mission.

Share this post


Link to post
Share on other sites

Just replace the line:

(_ui displayCtrl 1001) ctrlSetText format ["%1:%2",timer];

by:

(_ui displayCtrl 1001) ctrlSetText format ["%1:%2",_str];

 

Should work as _str is defined just before.

 


 

  • Like 1

Share this post


Link to post
Share on other sites
  On 10/2/2017 at 11:50 PM, pierremgi said:

Just replace the line:

(_ui displayCtrl 1001) ctrlSetText format ["%1:%2",timer];

by:

(_ui displayCtrl 1001) ctrlSetText format ["%1:%2",_str];

 

Should work as _str is defined just before.

 


 

you commented on my "safezone" said that is eats up a lot of cpu, well I tried using a trigger 
condition: this
act: player allowDamage false;
hint "spawn protection";

decact: player allowDamage True;

It worked but on the deact sometimes the damage never got turned back to 1 so people would be invincible at times. I then tried two triggers one for the safezone damage 0  and then once they left safezone the other trigger was used to turn damage to 1. The scripted in safezone works 100%. I was just wondering if you had a better idea or if it was better to use the two triggers instead of the script for performance.

Share this post


Link to post
Share on other sites

Make the trigger local. You must script it for that (no way with editor)

 

_trg = createTrigger ["EmptyDetector", getMarkerPos "mk1",false]; // or position you want

_trg setTriggerArea [5, 5, 0, false];  // area you want

_trg setTriggerActivation ["NONE", "PRESENT", true];

_trg setTriggerStatements ["player inArea thisTrigger", "player allowDamage false", "player allowDamage true"];

 

Must be on each clients , so in initPlayerLocal

or init.sqf (on dedicated add if (hasInterface) then {.....}; )

 

Not tested. should work. If not there is an alternate workaround, more heavy.

Share this post


Link to post
Share on other sites
  On 10/3/2017 at 5:33 PM, pierremgi said:

Make the trigger local. You must script it for that (no way with editor)

 

_trg = createTrigger ["EmptyDetector", getMarkerPos "mk1",false]; // or position you want

_trg setTriggerArea [5, 5, 0, false];  // area you want

_trg setTriggerActivation ["NONE", "PRESENT", true];

_trg setTriggerStatements ["player inArea thisTrigger", "player allowDamage false", "player allowDamage true"];

 

Must be on each clients , so in initPlayerLocal

or init.sqf (on dedicated add if (hasInterface) then {.....}; )

 

Not tested. should work. If not there is an alternate workaround, more heavy.

okay, was just wondering thanks!

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  

×