Jump to content
Sign in to follow this  
187Killa

End mission when score is reached

Recommended Posts

42 minutes ago, 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
 

Spoiler

private ["_ui", "_pointsA", "_pointsR"];

disableSerialization;
("UiLayer" call BIS_fnc_rscLayer) cutRsc ["DTASHUD","PLAIN"]; 
_ui = uiNamespace getVariable "DTASHUD";

_points = _ui displayCtrl 1001;
_pointsA = _ui displayCtrl 1101;
_pointsR = _ui displayCtrl 1102;

{_x ctrlShow true} foreach [_pointsA, _pointsR];


 



hudupdate.sqf
 

Spoiler

private ["_ui"];


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];


 

 

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
3 minutes ago, 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 

 

Spoiler

addMissionEventHandler ["entityKilled",{
  params ["_killed","_killer","_instigator"];
  if (!isPlayer _instigator) then { (side _instigator) addScoreSide 1};
 ;   <---added a bracket and subtracted a bracket but it keep poppin up as a error
}];

 

Share this post


Link to post
Share on other sites
22 minutes ago, pierremgi said:

copy/paste the last one.

init.sqf
 

Spoiler

0 fadeRadio 0;
enableRadio false;
enableSentences false;
showChat false;

execVM "fatigue.sqf";

pointsA = 0;
publicVariable "pointsA";
pointsR = 0;
publicVariable "pointsR";


pointlimit = ParamsArray Select 2;
disabledAI = ParamsArray Select 3;

enableSaving [false, false];
enableSentences false; //Disables auto spotting radio chatter

addMissionEventHandler ["eachFrame",{
  PointsA = scoreSide west;
  PointsR = scoreSide east;
   hintSilent format [scripts\hud\hud_update.sqf];   // replace by HUD (already on each frame so should be easy)
}];

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

addMissionEventHandler ["entityRespawned", {
  params ["_unit","_corpse"];
  _unit allowdamage false;

 
  _unit spawn {
    _unit = _this;
    sleep 3;
    _unit allowdamage true;
  };

  if (local _unit && _unit isKindOf "CAManBase") then {
    [_unit, [missionNamespace, name _unit]] call BIS_fnc_loadInventory;
    removeAllWeapons _corpse;
    removeBackpackGlobal _corpse;
    removeVest _corpse;
    removeAllAssignedItems _corpse;
    removeAllItems _corpse;
    removeGoggles _corpse;
    removeHeadgear _corpse;
    {deleteVehicle _x} forEach nearestObjects [(getPosATL _corpse),["WeaponHolderSimulated","groundWeaponHolder"],5];
  };
}];


if ( (!isServer) && (player != player) ) then
{
waitUntil {player == player};
waitUntil {time > 10};
};

if !(isnull player) then {
[] spawn {
            _colorWest = WEST call BIS_fnc_sideColor;
            _colorEast = EAST call BIS_fnc_sideColor;
            {_x set [3, 0.73]} forEach [_colorWest, _colorEast];
            if (side player == west) then {
            [getmarkerPos "orbitblufor","Team Death Match",10,30,250,1,
            [["\a3\ui_f\data\map\Markers\NATO\n_support.paa", _colorWest, markerPos "orbitblufor", 2, 1, 0, "Blufor", 0],   
            ["\a3\ui_f\data\map\Markers\NATO\n_support.paa", _colorEast, markerPos "orbitopfor", 2, 1, 0, "Opfor", 0]]]
            spawn BIS_fnc_establishingShot;

            };
            if (side player == east) then {
            [getmarkerPos "orbitopfor","Team Death Match",10,30,250,0,
            [["\a3\ui_f\data\map\Markers\NATO\n_support.paa", _colorWest, markerPos "orbitblufor", 2, 1, 0, "Blufor", 0],   
            ["\a3\ui_f\data\map\Markers\NATO\n_support.paa", _colorEast, markerPos "orbitopfor", 2, 1, 0, "Opfor", 0]]]
            spawn BIS_fnc_establishingShot;            
            };            
        };
        //Wait for UAV intro to stop playing before loading hud otherwise hud will not display. From Larrow / BIS forums.
         waitUntil {!isnil "BIS_fnc_establishingShot_playing" && {!BIS_fnc_establishingShot_playing}};
        //Load HUD (adapted from Dynamic Take And Secure Author:galzohar)
        [] call compile preprocessFileLineNumbers "scripts\hud\hud_create.sqf";
};

_null = [] execVM "scripts\motor.sqf";
_null = [] execVM "scripts\tiempo.sqf";
_null = [] execVM "scripts\icono.sqf";

[
        20, // seconds to delete dead bodies (0 means don't delete)
        120, // seconds to delete dead vehicles (0 means don't delete)
        60, // seconds to delete dropped weapons (0 means don't delete)
        240, // seconds to deleted planted explosives (0 means don't delete)
        120 // seconds to delete dropped smokes/chemlights (0 means don't delete)
    ] execVM "repetitive_cleanup.sqf";


null = [] execVM "scripts\jump.sqf";


if (isServer) then {

   GameFinished = false;

   while {!(GameFinished)} do {
       if ( (scoreSide west >= (paramsArray select 2)) || (scoreSide east >= (paramsArray select 2)) ) then {
           if ( scoreSide west > scoreSide east ) then {
               //west won, show end1 with closing shot, called on all west players via BIS_fnc_MP
               [["end1",true,true],"BIS_fnc_endMission", west, false] call BIS_fnc_MP;
               //east failed, show end2 with closing shot, called on all east players via BIS_fnc_MP
               [["end2",true,true],"BIS_fnc_endMission", east, false] call BIS_fnc_MP;
           }else{
               //east won, show end1 with closing shot, called on all east players via BIS_fnc_MP
               [["end1",true,true],"BIS_fnc_endMission", east, false] call BIS_fnc_MP;
               //west failed, show end2 with closing shot, called on all west players via BIS_fnc_MP
               [["end2",true,true],"BIS_fnc_endMission", west, false] call BIS_fnc_MP;
           };

           GameFinished = true;
       };

       sleep 1;
   };
}
 

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...?

 

Spoiler

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

 

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
5 minutes ago, 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
7 hours ago, 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
 

Spoiler

if(not isServer) exitWith{};
_hour = ;
_minute = 25;
_second = 59;
_runtime = 0;
mission_accomplished = false;

while {((_hour > 0) or (_minute > 0) or (_second > 0)) and !(mission_accomplished)} do {

if (_second == 0 AND (_minute > 0 OR _hour > 0)) then {
	_second = 59;
	if (_minute > 0) then {
		_minute = _minute - 1;
	} else {
		if (_hour > 0) then {
			_hour = _hour - 1;
			_minute = 59;
		};
	};
} else {
	_second = _second - 1;
};
"Time_left" setMarkerText format["Timeleft to Complete Mission = %1 : %2 : %3",_hour, _minute,_second];
sleep 1;
_runtime = _runtime + 1;
};

Hud update.sqf

Spoiler

addMissionEventHandler ["eachFrame",{
  PointsA = scoreSide west;
  PointsR = scoreSide east;
  disableSerialization;
  _ui = uiNamespace getVariable "DTASHUD";
  (_ui displayCtrl 1001) ctrlSetText format ["%1:%2",_minute,_second];
  (_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};
 }];
 

 

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
1 hour ago, 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

Spoiler

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

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
 

Spoiler

if (isServer) then {
        
    bluforflag setFlagSide west;
    opforflag setFlagSide east;

    pointsA = 0;
    publicVariable "pointsA";
    pointsR = 0;
    publicVariable "pointsR";

    
    minutos = ParamsArray Select 1;
    publicVariable "minutos";
    segundos = 1;
    publicVariable "segundos";

    pointlimit = ParamsArray Select 2;
    publicVariable "pointlimit";

};        

while {true} do {
    call compile preprocessFileLineNumbers "scripts\hud\hud_update.sqf";


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

Spoiler

0 fadeRadio 0;
enableRadio false;
enableSentences false;
showChat false;

hint format ["Welcome %1, Use Action Key to Open Virtual Aresenal",name player];
execVM "fatigue.sqf";

pointsA = 0;
publicVariable "pointsA";
pointsR = 0;
publicVariable "pointsR";


pointlimit = ParamsArray Select 2;
disabledAI = ParamsArray Select 3;

enableSaving [false, false];
enableSentences false; //Disables auto spotting radio chatter

addMissionEventHandler ["eachFrame",{
  PointsA = scoreSide west;
  PointsR = scoreSide east;
    disableSerialization;

  _ui = uiNamespace getVariable "DTASHUD";

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

  (_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};
}];

addMissionEventHandler ["entityRespawned", {
  params ["_unit","_corpse"];
  _unit allowdamage false;
  call {
    if (side _unit == east) exitWith { pointsA = pointsA +1; publicVariable "pointsA" };
    if (side _unit == west) exitWith { pointsR = pointsR +1; publicVariable "pointsB" };
  };
  call compile preprocessFileLineNumbers "scripts\hud\hud_create.sqf";

  _unit spawn {
    _unit = _this;
    sleep 3;
    _unit allowdamage true;
  };

  if (local _unit && _unit isKindOf "CAManBase") then {
    [_unit, [missionNamespace, name _unit]] call BIS_fnc_loadInventory;
    removeAllWeapons _corpse;
    removeBackpackGlobal _corpse;
    removeVest _corpse;
    removeAllAssignedItems _corpse;
    removeAllItems _corpse;
    removeGoggles _corpse;
    removeHeadgear _corpse;
    {deleteVehicle _x} forEach nearestObjects [(getPosATL _corpse),["WeaponHolderSimulated","groundWeaponHolder"],5];
  };
}];


if ( (!isServer) && (player != player) ) then
{
waitUntil {player == player};
waitUntil {time > 10};
};

if !(isnull player) then {
[] spawn {
            _colorWest = WEST call BIS_fnc_sideColor;
            _colorEast = EAST call BIS_fnc_sideColor;
            {_x set [3, 0.73]} forEach [_colorWest, _colorEast];
            if (side player == west) then {
            [getmarkerPos "orbitblufor","Team Death Match",10,30,250,1,
            [["\a3\ui_f\data\map\Markers\NATO\n_support.paa", _colorWest, markerPos "orbitblufor", 2, 1, 0, "Blufor", 0],   
            ["\a3\ui_f\data\map\Markers\NATO\n_support.paa", _colorEast, markerPos "orbitopfor", 2, 1, 0, "Opfor", 0]]]
            spawn BIS_fnc_establishingShot;

            };
            if (side player == east) then {
            [getmarkerPos "orbitopfor","Team Death Match",10,30,250,0,
            [["\a3\ui_f\data\map\Markers\NATO\n_support.paa", _colorWest, markerPos "orbitblufor", 2, 1, 0, "Blufor", 0],   
            ["\a3\ui_f\data\map\Markers\NATO\n_support.paa", _colorEast, markerPos "orbitopfor", 2, 1, 0, "Opfor", 0]]]
            spawn BIS_fnc_establishingShot;            
            };            
        };
        //Wait for UAV intro to stop playing before loading hud otherwise hud will not display. From Larrow / BIS forums.
         waitUntil {!isnil "BIS_fnc_establishingShot_playing" && {!BIS_fnc_establishingShot_playing}};
        //Load HUD (adapted from Dynamic Take And Secure Author:galzohar)
        [] call compile preprocessFileLineNumbers "scripts\hud\hud_create.sqf";
};

_null = [] execVM "scripts\motor.sqf";
_null = [] execVM "scripts\tiempo.sqf";
_null = [] execVM "scripts\icono.sqf";

[
        20, // seconds to delete dead bodies (0 means don't delete)
        120, // seconds to delete dead vehicles (0 means don't delete)
        60, // seconds to delete dropped weapons (0 means don't delete)
        240, // seconds to deleted planted explosives (0 means don't delete)
        120 // seconds to delete dropped smokes/chemlights (0 means don't delete)
    ] execVM "repetitive_cleanup.sqf";


null = [] execVM "scripts\jump.sqf";

0 = [] spawn { 
    while{true} do { 
        { 
             if(side _x == WEST && _x distance (getMarkerPos "safezoneblue") < 5) then {_x allowDamage false} else {_x allowDamage true}; 
        } forEach allUnits + vehicles; 
        sleep 1; 
        { 
            if(side _x == EAST && _x distance (getMarkerPos "safezonered") < 5) then {_x allowDamage false} else {_x allowDamage true}; 
        } forEach allUnits + vehicles;
    }; 
};

if (isServer) then {

   GameFinished = false;

   while {!(GameFinished)} do {
       if ( (scoreSide west >= (paramsArray select 2)) || (scoreSide east >= (paramsArray select 2)) ) then {
           if ( scoreSide west > scoreSide east ) then {
               //west won, show end1 with closing shot, called on all west players via BIS_fnc_MP
               [["end1",true,true],"BIS_fnc_endMission", west, false] call BIS_fnc_MP;
               //east failed, show end2 with closing shot, called on all east players via BIS_fnc_MP
               [["end2",true,true],"BIS_fnc_endMission", east, false] call BIS_fnc_MP;
           }else{
               //east won, show end1 with closing shot, called on all east players via BIS_fnc_MP
               [["end1",true,true],"BIS_fnc_endMission", east, false] call BIS_fnc_MP;
               //west failed, show end2 with closing shot, called on all west players via BIS_fnc_MP
               [["end2",true,true],"BIS_fnc_endMission", west, false] call BIS_fnc_MP;
           };

           GameFinished = true;
       };

       sleep 1;
   };
};



 

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:
 

Spoiler



0 fadeRadio 0;
enableRadio false;
enableSentences false;
showChat false;

hint format ["Welcome %1, Use Action Key to Open Virtual Aresenal",name player];
execVM "fatigue.sqf";

pointlimit = 50;  // value to make it work as i don't understand your paramsarray
//  disabledAI = ParamsArray Select 3;  certainly wrong!
timer = 25 * 60; // added

enableSaving [false, false];
enableSentences false; //Disables auto spotting radio chatter

call compile preprocessFileLineNumbers "scripts\hud\hud_create.sqf"; // once! but I'm not sure this sqf is fine

if (isServer) then {
  [] spawn {
    while {timer >= 0 } do {
    timer = timer - 1;    
    if (timer != -1) then {
      publicVariable "timer";
    };
    uisleep 1;
    };
  };
};

addMissionEventHandler ["eachFrame",{
  PointsA = scoreSide west;
  PointsR = scoreSide east;
  _str = [timer/3600+0.0001,"HH:MM:SS"] call BIS_fnc_timetostring;  // for test as i don't know if your HUD works
  _str = _str select [3];  // for test as i don't know if your HUD works
  hintSilent format ["Time left to complete mission: \n %1\nwest: %2\neast: %3", _str,pointsA,pointsR];   // for test as i don't know if your HUD works
    disableSerialization;
  _ui = uiNamespace getVariable "DTASHUD"; // here you are referring to a variable set in description.ext. I hope so!
  (_ui displayCtrl 1001) ctrlSetText format ["%1:%2",timer]; // work with defined variables!
  (_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};
}];

addMissionEventHandler ["entityRespawned", {
  params ["_unit","_corpse"];
  _unit allowdamage false;
  _unit spawn {
    _unit = _this;
    sleep 3;
    _unit allowdamage true;
  };

  if (local _unit && _unit isKindOf "CAManBase") then {
    [_unit, [missionNamespace, name _unit]] call BIS_fnc_loadInventory;
    removeAllWeapons _corpse;
    removeBackpackGlobal _corpse;
    removeVest _corpse;
    removeAllAssignedItems _corpse;
    removeAllItems _corpse;
    removeGoggles _corpse;
    removeHeadgear _corpse;
    {deleteVehicle _x} forEach nearestObjects [(getPosATL _corpse),["WeaponHolderSimulated","groundWeaponHolder"],5];
  };
}];


if ( (!isServer) && (player != player) ) then {
waitUntil {player == player};
waitUntil {time > 10};
};
// ____________________________following code not tested____________________
if !(isnull player) then {
[] spawn {
            _colorWest = WEST call BIS_fnc_sideColor;
            _colorEast = EAST call BIS_fnc_sideColor;
            {_x set [3, 0.73]} forEach [_colorWest, _colorEast];
            if (side player == west) then {
            [getmarkerPos "orbitblufor","Team Death Match",10,30,250,1,
            [["\a3\ui_f\data\map\Markers\NATO\n_support.paa", _colorWest, markerPos "orbitblufor", 2, 1, 0, "Blufor", 0],   
            ["\a3\ui_f\data\map\Markers\NATO\n_support.paa", _colorEast, markerPos "orbitopfor", 2, 1, 0, "Opfor", 0]]]
            spawn BIS_fnc_establishingShot;

            };
            if (side player == east) then {
            [getmarkerPos "orbitopfor","Team Death Match",10,30,250,0,
            [["\a3\ui_f\data\map\Markers\NATO\n_support.paa", _colorWest, markerPos "orbitblufor", 2, 1, 0, "Blufor", 0],   
            ["\a3\ui_f\data\map\Markers\NATO\n_support.paa", _colorEast, markerPos "orbitopfor", 2, 1, 0, "Opfor", 0]]]
            spawn BIS_fnc_establishingShot;            
            };            
        };
        //Wait for UAV intro to stop playing before loading hud otherwise hud will not display. From Larrow / BIS forums.
         waitUntil {!isnil "BIS_fnc_establishingShot_playing" && {!BIS_fnc_establishingShot_playing}};
        //Load HUD (adapted from Dynamic Take And Secure Author:galzohar)
        [] call compile preprocessFileLineNumbers "scripts\hud\hud_create.sqf";
};

// _null = [] execVM "scripts\motor.sqf"; // remove
// _null = [] execVM "scripts\tiempo.sqf"; // remove
_null = [] execVM "scripts\icono.sqf"; // not sure what is it

[
        20, 
        120, 
        60, 
        240, 
        120 
    ] execVM "repetitive_cleanup.sqf"; // not sure it works with your sqf

_null = [] execVM "scripts\jump.sqf"; // can't say what is it. needs that scripts sub-folder exists


//___________________________________________________
//  useless script but CPU load for all the mission !
0 = [] spawn {
    while{true} do {
        {
             if(side _x == WEST && _x distance (getMarkerPos "safezoneblue") < 5) then {_x allowDamage false} else {_x allowDamage true};
        } forEach allUnits + vehicles;
        sleep 1;
        {
            if(side _x == EAST && _x distance (getMarkerPos "safezonered") < 5) then {_x allowDamage false} else {_x allowDamage true};
        } forEach allUnits + vehicles;
    };
};
//_________________________________________________________
// should not work paramsArray????

if (isServer) then {

   GameFinished = false;

   while {!(GameFinished)} do {
       if ( (scoreSide west >= (paramsArray select 2)) || (scoreSide east >= (paramsArray select 2)) ) then {
           if ( scoreSide west > scoreSide east ) then {
               //west won, show end1 with closing shot, called on all west players via BIS_fnc_MP
               [["end1",true,true],"BIS_fnc_endMission", west, false] call BIS_fnc_MP;
               //east failed, show end2 with closing shot, called on all east players via BIS_fnc_MP
               [["end2",true,true],"BIS_fnc_endMission", east, false] call BIS_fnc_MP;
           }else{
               //east won, show end1 with closing shot, called on all east players via BIS_fnc_MP
               [["end1",true,true],"BIS_fnc_endMission", east, false] call BIS_fnc_MP;
               //west failed, show end2 with closing shot, called on all west players via BIS_fnc_MP
               [["end2",true,true],"BIS_fnc_endMission", west, false] call BIS_fnc_MP;
           };

           GameFinished = true;
       };

       sleep 1;
   };
};


 

 

 


 

Share this post


Link to post
Share on other sites
2 hours ago, 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:
 

  Hide contents

 



0 fadeRadio 0;
enableRadio false;
enableSentences false;
showChat false;

hint format ["Welcome %1, Use Action Key to Open Virtual Aresenal",name player];
execVM "fatigue.sqf";

pointlimit = 50;  // value to make it work as i don't understand your paramsarray
//  disabledAI = ParamsArray Select 3;  certainly wrong!
timer = 25 * 60; // added

enableSaving [false, false];
enableSentences false; //Disables auto spotting radio chatter

call compile preprocessFileLineNumbers "scripts\hud\hud_create.sqf"; // once! but I'm not sure this sqf is fine

if (isServer) then {
  [] spawn {
    while {timer >= 0 } do {
    timer = timer - 1;    
    if (timer != -1) then {
      publicVariable "timer";
    };
    uisleep 1;
    };
  };
};

addMissionEventHandler ["eachFrame",{
  PointsA = scoreSide west;
  PointsR = scoreSide east;
  _str = [timer/3600+0.0001,"HH:MM:SS"] call BIS_fnc_timetostring;  // for test as i don't know if your HUD works
  _str = _str select [3];  // for test as i don't know if your HUD works
  hintSilent format ["Time left to complete mission: \n %1\nwest: %2\neast: %3", _str,pointsA,pointsR];   // for test as i don't know if your HUD works
    disableSerialization;
  _ui = uiNamespace getVariable "DTASHUD"; // here you are referring to a variable set in description.ext. I hope so!
  (_ui displayCtrl 1001) ctrlSetText format ["%1:%2",timer]; // work with defined variables!
  (_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};
}];

addMissionEventHandler ["entityRespawned", {
  params ["_unit","_corpse"];
  _unit allowdamage false;
  _unit spawn {
    _unit = _this;
    sleep 3;
    _unit allowdamage true;
  };

  if (local _unit && _unit isKindOf "CAManBase") then {
    [_unit, [missionNamespace, name _unit]] call BIS_fnc_loadInventory;
    removeAllWeapons _corpse;
    removeBackpackGlobal _corpse;
    removeVest _corpse;
    removeAllAssignedItems _corpse;
    removeAllItems _corpse;
    removeGoggles _corpse;
    removeHeadgear _corpse;
    {deleteVehicle _x} forEach nearestObjects [(getPosATL _corpse),["WeaponHolderSimulated","groundWeaponHolder"],5];
  };
}];


if ( (!isServer) && (player != player) ) then {
waitUntil {player == player};
waitUntil {time > 10};
};
// ____________________________following code not tested____________________
if !(isnull player) then {
[] spawn {
            _colorWest = WEST call BIS_fnc_sideColor;
            _colorEast = EAST call BIS_fnc_sideColor;
            {_x set [3, 0.73]} forEach [_colorWest, _colorEast];
            if (side player == west) then {
            [getmarkerPos "orbitblufor","Team Death Match",10,30,250,1,
            [["\a3\ui_f\data\map\Markers\NATO\n_support.paa", _colorWest, markerPos "orbitblufor", 2, 1, 0, "Blufor", 0],   
            ["\a3\ui_f\data\map\Markers\NATO\n_support.paa", _colorEast, markerPos "orbitopfor", 2, 1, 0, "Opfor", 0]]]
            spawn BIS_fnc_establishingShot;

            };
            if (side player == east) then {
            [getmarkerPos "orbitopfor","Team Death Match",10,30,250,0,
            [["\a3\ui_f\data\map\Markers\NATO\n_support.paa", _colorWest, markerPos "orbitblufor", 2, 1, 0, "Blufor", 0],   
            ["\a3\ui_f\data\map\Markers\NATO\n_support.paa", _colorEast, markerPos "orbitopfor", 2, 1, 0, "Opfor", 0]]]
            spawn BIS_fnc_establishingShot;            
            };            
        };
        //Wait for UAV intro to stop playing before loading hud otherwise hud will not display. From Larrow / BIS forums.
         waitUntil {!isnil "BIS_fnc_establishingShot_playing" && {!BIS_fnc_establishingShot_playing}};
        //Load HUD (adapted from Dynamic Take And Secure Author:galzohar)
        [] call compile preprocessFileLineNumbers "scripts\hud\hud_create.sqf";
};

// _null = [] execVM "scripts\motor.sqf"; // remove
// _null = [] execVM "scripts\tiempo.sqf"; // remove
_null = [] execVM "scripts\icono.sqf"; // not sure what is it

[
        20, 
        120, 
        60, 
        240, 
        120 
    ] execVM "repetitive_cleanup.sqf"; // not sure it works with your sqf

_null = [] execVM "scripts\jump.sqf"; // can't say what is it. needs that scripts sub-folder exists


//___________________________________________________
//  useless script but CPU load for all the mission !
0 = [] spawn {
    while{true} do {
        {
             if(side _x == WEST && _x distance (getMarkerPos "safezoneblue") < 5) then {_x allowDamage false} else {_x allowDamage true};
        } forEach allUnits + vehicles;
        sleep 1;
        {
            if(side _x == EAST && _x distance (getMarkerPos "safezonered") < 5) then {_x allowDamage false} else {_x allowDamage true};
        } forEach allUnits + vehicles;
    };
};
//_________________________________________________________
// should not work paramsArray????

if (isServer) then {

   GameFinished = false;

   while {!(GameFinished)} do {
       if ( (scoreSide west >= (paramsArray select 2)) || (scoreSide east >= (paramsArray select 2)) ) then {
           if ( scoreSide west > scoreSide east ) then {
               //west won, show end1 with closing shot, called on all west players via BIS_fnc_MP
               [["end1",true,true],"BIS_fnc_endMission", west, false] call BIS_fnc_MP;
               //east failed, show end2 with closing shot, called on all east players via BIS_fnc_MP
               [["end2",true,true],"BIS_fnc_endMission", east, false] call BIS_fnc_MP;
           }else{
               //east won, show end1 with closing shot, called on all east players via BIS_fnc_MP
               [["end1",true,true],"BIS_fnc_endMission", east, false] call BIS_fnc_MP;
               //west failed, show end2 with closing shot, called on all west players via BIS_fnc_MP
               [["end2",true,true],"BIS_fnc_endMission", west, false] call BIS_fnc_MP;
           };

           GameFinished = true;
       };

       sleep 1;
   };
};

 

 

 

 

 

 


 

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
16 hours ago, 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
18 minutes ago, 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  

×