Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×
Sign in to follow this  
187Killa

End mission when score is reached

Recommended Posts

5 hours ago, pierremgi said:

at least, side _x == playerSide  instead of 2 codes.

 

Then , for colors :

_color = [0,0,0];

call {

  if (side _x == west) exitWith {_color = [0,0,255,0]};

  if (side _x == east) exitWith {_color = [255,0,0]};

};

 drawIcon3D ["", _color, [visiblePosition _x select 0, visiblePosition _x select 1,(visiblePosition _x select 2)+2], 0.2, 0.2, 45, (format ["%2 - %1m",round (player distance _x), name _x]), 1, 0.03, "PuristaMedium"];

 

 

Well, I have some time, so here is a code for a toggling action menu enabling names on your side on/off. MP/ respawn compatible:

 

in initPlayerLocal.sqf

 


Action_Icon = 0;
Action_Menu ="<t color='#11ff11'>Names On</t>";

fn_Action = {
  _plyr = _this;
  _plyr addAction [Action_Menu, {
  _plyr = _this select 0;
    Action_Icon = (Action_Icon + 1) mod 2;
    Action_Menu = if (Action_Icon == 1) then [{"<t color='#ff1111'>Names Off</t>"},{"<t color='#11ff11'>Names On</t>"}];
    _plyr setUserActionText [(_this select 2),Action_Menu];
    },nil,0.8,false,true,"", "vehicle _target == vehicle _this"];
};

player call fn_Action;
player addEventHandler ["respawn", { (_this select 0) call fn_action}];


addMissionEventHandler ["draw3D",
{
  {
    if (Action_Icon == 1 && side _x == playerSide && _x != player) then {
       _color = [0,0,0,0];
      call {
        if (side _x == west) exitWith {_color = [0,0,255,1]};
        if (side _x == east) exitWith {_color = [255,0,0,1]};
      }; 
      drawIcon3D ["", _color, [visiblePosition _x select 0, visiblePosition _x select 1,(visiblePosition _x select 2)+2], 0.2, 0.2, 45, (format ["%2 - %1m",round (player distance _x), name _x]), 1, 0.03, "PuristaMedium"];
    }; 
  } forEach (allUnits select {effectiveCommander vehicle _x == _x})
}];

Tested.

I see what I did wrong. I thought since i had defined two separate .sqf files I didnt need to write the code that way. I thought since each side had its own init I just had to specify the side east or west inside the file! makes sense! i knew i was correct logically!!
thats works perfectly! 

I cant get your addmissioneventhandler  code you gave me for the "init" to work at all.

I removed the "remove weapons etc. script from playerrespawn.

 

init.sqf

Spoiler


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

execVM "fatigue.sqf";

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

minutos = paramsArray select 1;
pointlimit = ParamsArray Select 2;
disabledAI = ParamsArray Select 3;

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

addMissionEventHandler ["entityKilled", {
  _victim = _this select 0;
  if (local _victim && _victim isKindOf "CAManBase") then {
    [_victim, [missionNamespace, name _victim]] call BIS_fnc_saveInventory;
    _victim setVariable ["MGI_ammo1",_victim ammo (primaryWeapon _victim)];
    _victim setVariable ["MGI_ammo2",_victim ammo (handgunWeapon _victim)];
    _victim setVariable ["MGI_ammo3",_victim ammo (secondaryWeapon _victim)];
    _victim setVariable ["MGI_mags",magazinesAmmoFull _victim];
    _victim setVariable ["MGI_weapon",currentWeapon _victim];
  };
}];

addMissionEventHandler ["entityRespawned", {
  _unit = _this select 0;
  _corpse = _this select 1;
  if (local _unit && _victim isKindOf "CAManBase") then {
    [_unit, [missionNamespace, name _unit]] call BIS_fnc_loadInventory;
    {_unit removeMagazine _x} forEach magazines _unit;
    _unit setAmmo [primaryWeapon _unit, 0];
    _unit setAmmo [handGunWeapon _unit, 0];
    _unit setAmmo [secondaryWeapon _unit, 0];
    {
      if (((_unit getVariable "MGI_mags") select _foreachindex select 3) <= 0) then {
        _unit addMagazine [_x select 0,_x select 1]
      }
    } forEach (_unit getVariable "MGI_mags");
    _unit setAmmo [primaryWeapon _unit,_unit getVariable "MGI_ammo1"];
    _unit setAmmo [handGunWeapon _unit,_unit getVariable  "MGI_ammo2"];
    _unit setAmmo [secondaryWeapon _unit,_unit getVariable "MGI_ammo3"];
    _unit selectWeapon (_unit getVariable "MGI_weapon");
    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;
   };
};


execVM "scripts\NRE_earplugs.sqf";


onplayerrespawn

Spoiler

params ["_newGuy","_oldGuy"];
_newGuy allowdamage false;
call {
  if (side _newGuy == east) exitWith { pointsA = pointsA +1; publicVariable "pointsA" };
  if (side _newGuy == west) exitWith { pointsR = pointsR +1; publicVariable "pointsB" };
};
call compile preprocessFileLineNumbers "scripts\hud\hud_create.sqf"; // not sure you need that!


[_newGuy,_oldGuy] spawn {
  params ["_newGuy","_oldGuy"];
  sleep 3;
  _newGuy allowdamage true;
 _newGuy setUnitLoadout (_oldGuy getVariable ["Saved_Loadout",[]]);
 _newGuy addaction [("<t color=""#FF4444"">" + "Open Virtual Arsenal" + "</t>"), {["Open", true] spawn BIS_fnc_arsenal}, "", 0, false, false];
};



 

Share this post


Link to post
Share on other sites
1 hour ago, 187Killa said:

I cant get your addmissioneventhandler  code you gave me for the "init" to work at all.

 

 

I let an error in copy/paste (a _victim instead of _unit somewhere, same error in your entityRespawned EH , line 3 of the code inside). Corrected in my former post. works now.

Share this post


Link to post
Share on other sites
7 hours ago, pierremgi said:

 

I let an error in copy/paste (a _victim instead of _unit somewhere, same error in your entityRespawned EH , line 3 of the code inside). Corrected in my former post. works now.

i went back to the page and looked at it. Did you hit save because I check the code and nothing was different from the original. I copied and pasted anyway just to make sure I was correct and still nothing. 

but basically just switch _unit for a_victim in the script and it should be good to go?

EDIT: Im not getting any errors. The guy spawns with the previous loadout he had but ammo isnt replenished. So its halfway working now!

 

Share this post


Link to post
Share on other sites
32 minutes ago, 187Killa said:

i went back to the page and looked at it. Did you hit save because I check the code and nothing was different from the original. I copied and pasted anyway just to make sure I was correct and still nothing. 

but basically just switch _unit for a_victim in the script and it should be good to go?

EDIT: Im not getting any errors. The guy spawns with the previous loadout he had but ammo isnt replenished. So its halfway working now!

 

 

Seriously? You can't make a difference between:

if (local _unit && _unit isKindOf "CAManBase") then {...     // working

and

if (local _unit && _victim isKindOf "CAManBase") then {...   // wrong

even if I wrote the third line inside of entityRespawned EH code?

 

I can't imagine what you have done after that. 2 EHs? One EH + onPlayerRespawn.sqf doing the same thing, one right, one wrong?...

 

I will not change anything more because I let you all working codes for

- respawning with the loadout "at the death", with the same ammos as "at the death"

- an addaction on player to display names or not.

- the way to make publicVariable working.

 

Share this post


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

 

Seriously? You can't make a difference between:

if (local _unit && _unit isKindOf "CAManBase") then {...     // working

and

if (local _unit && _victim isKindOf "CAManBase") then {...   // wrong

even if I wrote the third line inside of entityRespawned EH code?

 

I can't imagine what you have done after that. 2 EHs? One EH + onPlayerRespawn.sqf doing the same thing, one right, one wrong?...

 

I will not change anything more because I let you all working codes for

- respawning with the loadout "at the death", with the same ammos as "at the death"

- an addaction on player to display names or not.

- the way to make publicVariable working.

 

my eyes skipped right on unit/victim isKindOf! 
and what EH am i suppose to have in the onplayerrespawn.sqf. you just told me to delete the _remove weapons etc code. and to only put the EH's in my Init which made sense. 
this is what my respawn.sqf looks like 
 

Spoiler

params ["_newGuy","_oldGuy"];
_newGuy allowdamage false;
call {
  if (side _newGuy == east) exitWith { pointsA = pointsA +1; publicVariable "pointsA" };
  if (side _newGuy == west) exitWith { pointsR = pointsR +1; publicVariable "pointsB" };
};
call compile preprocessFileLineNumbers "scripts\hud\hud_create.sqf"; // not sure you need that!


[_newGuy,_oldGuy] spawn {
  params ["_newGuy","_oldGuy"];
  sleep 3;
  _newGuy allowdamage true;

 _newGuy addaction [("<t color=""#FF4444"">" + "Open Virtual Arsenal" + "</t>"), {["Open", true] spawn BIS_fnc_arsenal}, "", 0, false, false];
};

 

Share this post


Link to post
Share on other sites
12 minutes ago, 187Killa said:


and what EH am i suppose to have in the onplayerrespawn.sqf. you just told me to delete the _remove weapons etc code. 
 

I wrote:

I can't imagine what you have done after that. 2 EHs? One EH + onPlayerRespawn.sqf doing the same thing, one right, one wrong?...

just to say, that if you still have errors after that, this could be due to a wrong useless remaining code somewhere.

But, your onplayerRespawn.sqf seems OK, like this.

Share this post


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

I wrote:

I can't imagine what you have done after that. 2 EHs? One EH + onPlayerRespawn.sqf doing the same thing, one right, one wrong?...

just to say, that if you still have errors after that, this could be due to a wrong useless remaining code somewhere.

But, your onplayerRespawn.sqf seems OK, like this.

We had a miscommunication I thought you had Corrected the Entire script but you corrected the first EH and not the seconds well I changed the Second EH to the same as the first EH _victim iskindof from _unit.

and do i need to change all the _unit to vicitm? 

second EH

Spoiler

addMissionEventHandler ["entityRespawned", {
  _victim = _this select 0;
  _corpse = _this select 1;
  if (local _victim && _victim isKindOf "CAManBase") then {
    [_victim, [missionNamespace, name _victim]] call BIS_fnc_loadInventory;
    {_victim removeMagazine _x} forEach magazines _victim;
    _victim setAmmo [primaryWeapon _victim, 0];
    _victim setAmmo [handGunWeapon _victim, 0];
    _victim setAmmo [secondaryWeapon _victim, 0];
    {
      if (((_victim getVariable "MGI_mags") select _foreachindex select 3) <= 0) then {
        _victim addMagazine [_x select 0,_x select 1]
      }
    } forEach (_victim getVariable "MGI_mags");
    _victim setAmmo [primaryWeapon _victim,_victim getVariable "MGI_ammo1"];
    _victim setAmmo [handGunWeapon _victim,_victim getVariable  "MGI_ammo2"];
    _victim setAmmo [secondaryWeapon _victim,_victim getVariable "MGI_ammo3"];
    _victim selectWeapon (_victim getVariable "MGI_weapon");
    removeAllWeapons _corpse;
    removeBackpackGlobal _corpse;
    removeVest _corpse;
    removeAllAssignedItems _corpse;
    removeAllItems _corpse;
    removeGoggles _corpse;
    removeHeadgear _corpse;
    {deleteVehicle _x} forEach nearestObjects [(getPosATL _corpse),["WeaponHolderSimulated","groundWeaponHolder"],5];
  };
}];
 

 

Share this post


Link to post
Share on other sites

What?! :shrug: Checked twice, I never wrote something like that!

You just had to change one word! I can't change anything on your post. So, copy mine!

 

For your comprehension, instead of trying anything anywhere, just be logic:

params ["_blabla","_hello"]; is same as:

_blabla = _this select 0;

_hello = _this select 1;

 

then the code following this declaration works for _blabla and _hello . So, in your bit of code , right above, _unit doesn't mean any thing.

 

These variables are local and they work for the scope (the context) where they have been declared (EH , spawn code, sqf)

Example:

[_myObject , 123] spawn { params ["_holyGraal" , "_dist"]; if (player distance _holyGraal < _dist) then {...}  };

has chance to work (_holyGraal refers to the object and _dist to the passed 123.

 

[_myObject , 123] spawn {  if (player distance _holyGraal < _dist) then {...}  };

will never work.

 

So, no matter the name of the local variable, just be consistent with the scope. Each EH, sqf, spawn can have their different local variables names for the same object (here player for instance).

 

Share this post


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

What?! :shrug: Checked twice, I never wrote something like that!

You just had to change one word! I can't change anything on your post. So, copy mine!

 

For your comprehension, instead of trying anything anywhere, just be logic:

params ["_blabla","_hello"]; is same as:

_blabla = _this select 0;

_hello = _this select 1;

 

then the code following this declaration works for _blabla and _hello . So, in your bit of code , right above, _unit doesn't mean any thing.

 

These variables are local and they work for the scope (the context) where they have been declared (EH , spawn code, sqf)

Example:

[_myObject , 123] spawn { params ["_holyGraal" , "_dist"]; if (player distance _holyGraal < _dist) then {...}  };

has chance to work (_holyGraal refers to the object and _dist to the passed 123.

 

[_myObject , 123] spawn {  if (player distance _holyGraal < _dist) then {...}  };

will never work.

 

So, no matter the name of the local variable, just be consistent with the scope. Each EH, sqf, spawn can have their different local variables names for the same object (here player for instance).

 

I did some trial and error and in the second EH respawned

if i dont change all the _unit to _victims the script dont work at all
after i change all the _unit to _vicitms script works just doesnt replenish ammo.. 

Im sure you getting flustered with me so we will let it be! I appreciate all the help you have given and teaching me a few things.

Share this post


Link to post
Share on other sites

proceed script by script, EH by EH.

Apply the logic. check your variables as said above. (_unit  _victim  _victims ... stay consistent!) On EH respawn (or sqf respawn) first param is the respawned unit, second one is the killed (corpse). See here.

You can continue to send your code (full). No problem. There is no reason to fail.

 

Replenishing ammo: sure it was not the intended behavior in my script.

If you want to "resplenish" that means save inventory at the right time (naked at start? or when exactly?)

then just load inventory with no line of code for ammos.

 

Share this post


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

proceed script by script, EH by EH.

Apply the logic. check your variables as said above. (_unit  _victim  _victims ... stay consistent!) On EH respawn (or sqf respawn) first param is the respawned unit, second one is the killed (corpse). See here.

You can continue to send your code (full). No problem. There is no reason to fail.

 

Replenishing ammo: sure it was not the intended behavior in my script.

If you want to "resplenish" that means save inventory at the right time (naked at start? or when exactly?)

then just load inventory with no line of code for ammos.

 

I have applied the logic. I replace the iskindof from unit to victim only like you very first mentioned. Va action wouldnt even work so you be running around without a weapon the entire time.

in second EH switching ever _unit to _victim. everything worked just fine except ammo was kept at whatever you died with instead of replenishing the amount you had. 
 

only EH's I have in this script (because I didnt know how to use them properly prior to you showing me) is the show names script you had made for me its in playerlocal file and then this one. so my params should be unit or victim theoretically and logically it should be working but it just wont!! 

and before this EH i had a (save player loadout) on respawn.sqf it would spawn whatever you had selected from VA but ammo wouldnt be added back. so player selected 7 mags used 4 of them before being killed he wold only spawn back with 3 mags plus whatever bullet count was left in the mag loaded into the gun. its not a huge problem but if i could fix it i would.  

Share this post


Link to post
Share on other sites

Please, send your code. It's incomprehensive right now. second EH?  I'm lost.

One full code by one full code. Everything works for me by the way. tested.

Share this post


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

Please, send your code. It's incomprehensive right now. second EH?  I'm lost.

One full code by one full code. Everything works for me by the way. tested.

init.sqf  (second EH I was refering to the second EH in your code the respawned) if I changed every _unit to _victim under the Respawned section EH it would work
 

Spoiler


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

execVM "fatigue.sqf";

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

minutos = paramsArray select 1;
pointlimit = ParamsArray Select 2;
disabledAI = ParamsArray Select 3;

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

addMissionEventHandler ["entityKilled", {
  _victim = _this select 0;
  if (local _victim && _victim isKindOf "CAManBase") then {
    [_victim, [missionNamespace, name _victim]] call BIS_fnc_saveInventory;
    _victim setVariable ["MGI_ammo1",_victim ammo (primaryWeapon _victim)];
    _victim setVariable ["MGI_ammo2",_victim ammo (handgunWeapon _victim)];
    _victim setVariable ["MGI_ammo3",_victim ammo (secondaryWeapon _victim)];
    _victim setVariable ["MGI_mags",magazinesAmmoFull _victim];
    _victim setVariable ["MGI_weapon",currentWeapon _victim];
  };
}];

addMissionEventHandler ["entityRespawned", {
  _unit = _this select 0;
  _corpse = _this select 1;
  if (local _victim && _victim isKindOf "CAManBase") then {
    [_unit, [missionNamespace, name _unit]] call BIS_fnc_loadInventory;
    {_unit removeMagazine _x} forEach magazines _unit;
    _unit setAmmo [primaryWeapon _unit, 0];
    _unit setAmmo [handGunWeapon _unit, 0];
    _unit setAmmo [secondaryWeapon _unit, 0];
    {
      if (((_unit getVariable "MGI_mags") select _foreachindex select 3) <= 0) then {
        _unit addMagazine [_x select 0,_x select 1]
      }
    } forEach (_unit getVariable "MGI_mags");
    _unit setAmmo [primaryWeapon _unit,_unit getVariable "MGI_ammo1"];
    _unit setAmmo [handGunWeapon _unit,_unit getVariable  "MGI_ammo2"];
    _unit setAmmo [secondaryWeapon _unit,_unit getVariable "MGI_ammo3"];
    _unit selectWeapon (_unit getVariable "MGI_weapon");
    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;
   };
};


execVM "scripts\NRE_earplugs.sqf";

playerespawn.sqf
 

Spoiler

params ["_newGuy","_oldGuy"];
_newGuy allowdamage false;
call {
  if (side _newGuy == east) exitWith { pointsA = pointsA +1; publicVariable "pointsA" };
  if (side _newGuy == west) exitWith { pointsR = pointsR +1; publicVariable "pointsB" };
};
call compile preprocessFileLineNumbers "scripts\hud\hud_create.sqf"; // not sure you need that!


[_newGuy,_oldGuy] spawn {
  params ["_newGuy","_oldGuy"];
  sleep 3;
  _newGuy allowdamage true;
 _newGuy addaction [("<t color=""#FF4444"">" + "Open Virtual Arsenal" + "</t>"), {["Open", true] spawn BIS_fnc_arsenal}, "", 0, false, false];
};

playerlocal
 

Spoiler

[] execVM "killfeed\killfeed.sqf";


player addaction [("<t color=""#FF4444"">" + "Open Virtual Arsenal" + "</t>"), {["Open", true] call BIS_fnc_arsenal}, "", 0, false, false];

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


Action_Icon = 0;
Action_Menu ="<t color='#11ff11'>Show Friendly</t>";

fn_Action = {
  _plyr = _this;
  _plyr addAction [Action_Menu, {
  _plyr = _this select 0;
    Action_Icon = (Action_Icon + 1) mod 2;
    Action_Menu = if (Action_Icon == 1) then [{"<t color='#ff1111'>Names Off</t>"},{"<t color='#11ff11'>Names On</t>"}];
    _plyr setUserActionText [(_this select 2),Action_Menu];
    },nil,0.8,false,true,"", "vehicle _target == vehicle _this"];
};

player call fn_Action;
player addEventHandler ["respawn", { (_this select 0) call fn_action}];


addMissionEventHandler ["draw3D",
{
  {
    if (Action_Icon == 1 && side _x == playerSide && _x != player) then {
       _color = [0,0,0,0];
      call {
        if (side _x == west) exitWith {_color = [0,0,255,1]};
        if (side _x == east) exitWith {_color = [255,0,0,1]};
      }; 
      drawIcon3D ["", _color, [visiblePosition _x select 0, visiblePosition _x select 1,(visiblePosition _x select 2)+2], 0.2, 0.2, 45, (format ["%2 - %1m",round (player distance _x), name _x]), 1, 0.03, "PuristaMedium"];
    }; 
  } forEach (allUnits select {effectiveCommander vehicle _x == _x})
}];
 

repetitivecleanup
 

Spoiler

/*
    
    AUTHOR: aeroson
    NAME: repetitive_cleanup.sqf
    VERSION: 1.7
    
    DESCRIPTION:
    Can delete everything that is not really needed 
    dead bodies, dropped items, smokes, chemlights, explosives, empty groups
    Works even on Altis, it eats only items which are 100m from all units
    
    USAGE:
    in server's init
    [
        5, // seconds to delete dead bodies (0 means don't delete) 
        0, // seconds to delete dead vehicles (0 means don't delete)
        0, // seconds to delete dropped weapons (0 means don't delete)
        0, // seconds to deleted planted explosives (0 means don't delete)
        0 // seconds to delete dropped smokes/chemlights (0 means don't delete)
    ] execVM 'repetitive_cleanup.sqf';    
    
    will delete dead bodies after 60 seconds (1 minute)
    will delete dead vehicles after 5*60 seconds (5 minutes)
    will delete weapons after 2*60 seconds (2 minutes)
    will delete planted explosives after 10*60 seconds (10 minutes)
    will not delete any smokes/chemlights since its disabled (set to 0)
        
*/

if (!isServer) exitWith {}; // isn't server         

#define PUSH(A,B) A set [count (A),B];
#define REM(A,B) A=A-;

private ["_ttdBodies","_ttdVehicles","_ttdWeapons","_ttdPlanted","_ttdSmokes","_delete","_unit"];


_ttdBodies=[_this,0,0,[0]] call BIS_fnc_param;
_ttdVehicles=[_this,1,0,[0]] call BIS_fnc_param;
_ttdWeapons=[_this,2,0,[0]] call BIS_fnc_param;
_ttdPlanted=[_this,3,0,[0]] call BIS_fnc_param;
_ttdSmokes=[_this,4,0,[0]] call BIS_fnc_param;

if (_ttdWeapons<=0 && _ttdPlanted<=0 && _ttdSmokes<=0 && _ttdBodies<=0 && _ttdVehicles<=0) exitWith {};


_objects=[];
_items=[];

_delete = {
    _object = _this select 0;
    _time = _this select 1;
    if(_objects find _object == -1) then {
        PUSH(_objects,_object)
        PUSH(_items,_time+time)
    };    
};


while{true} do {

    sleep 10;
        
    if (_ttdBodies>0) then {
        {
            if(!isPlayer _x) then {      
                [_x, _ttdBodies] call _delete;
            }; 
        } forEach allDeadMen;
    };    
    
    if (_ttdVehicles>0) then {        
        {
            if(!isPlayer _x) then {      
                [_x, _ttdVehicles] call _delete;
            }; 
        } forEach (allDead - allDeadMen);
    };


    {    
        _unit = _x;
        
        if (_ttdWeapons>0) then {
            {
                {      
                    [_x, _ttdWeapons] call _delete;            
                } forEach (getpos _unit nearObjects [_x, 100]);
            } forEach ["WeaponHolder","GroundWeaponHolder","WeaponHolderSimulated"];
        };
        
        if (_ttdPlanted>0) then {
            {
                { 
                    [_x, _ttdPlanted] call _delete;  
                } forEach (getpos _unit nearObjects [_x, 100]);
            } forEach ["TimeBombCore"];
        };
        
        if (_ttdSmokes>0) then {
            {
                {      
                    [_x, _ttdSmokes] call _delete; 
                } forEach (getpos _unit nearObjects [_x, 100]);
            } forEach ["SmokeShell"];
        };
    
    } forEach allUnits;
    
    {
        if ((count units _x)==0) then {
            deleteGroup _x;
        };
    } forEach allGroups;
        

    {        
        if(isNull(_x)) then {
            _objects set[_forEachIndex, 0];
            _items set[_forEachIndex, 0];
        } else {
            if(_items select _forEachIndex < time) then {
                deleteVehicle _x;
                _objects set[_forEachIndex, 0];
                _items set[_forEachIndex, 0];                 
            };
        };    
    } forEach _objects;
    
    REM(_objects,0)
    REM(_items,0)
                
};

 playerkilled.sqf

Spoiler

player setVariable["Saved_Loadout",getUnitLoadout player];

 

Share this post


Link to post
Share on other sites

playerLocal ?   should be   initPlayerLocal.sqf at mission root of course. You can't change the name of event scripts.  so,  works for me SP/MP compatible

Furthermore, as you wants to reload (replenish) the mags, instead of saving loadout at death (entityKilled) , i'm saving when player closes arsenal.

I modified the addAction for that. You can delete some lines like entitykilled MEH code after that. I'll do for you;


New initPlayerLocal.sqf:
 

Spoiler

 


[] execVM "killfeed\killfeed.sqf";

MGI_fn_Arsenal = {
  _this addaction [("<t color=""#FF4444"">" + "Open Virtual Arsenal" + "</t>"), {
    ["Open", true] call BIS_fnc_arsenal;
    (_this select 0) spawn {
      waitUntil {!isnull (uiNamespace getVariable ["RscDisplayArsenal", displayNull])};
      waitUntil {isNull (uiNamespace getVariable ["RscDisplayArsenal", displayNull])};
      [_this, [missionNamespace, name _this]] call BIS_fnc_saveInventory
    }
  },nil,0.8,false,true,"", "vehicle _target == vehicle _this"];
};

Action_Icon = 0;
Action_Menu ="<t color='#11ff11'>Show Friendly</t>";

MGI_FriendIcons = {
  _plyr = _this;
  _plyr addAction [Action_Menu, {
  _plyr = _this select 0;
    Action_Icon = (Action_Icon + 1) mod 2;
    Action_Menu = if (Action_Icon == 1) then [{"<t color='#ff1111'>Hide Friendly</t>"},{"<t color='#11ff11'>Show Friendly</t>"}];
    _plyr setUserActionText [(_this select 2),Action_Menu];
    },nil,0.9,false,true,"", "vehicle _target == vehicle _this"];
};

[player, [missionNamespace, name player]] call BIS_fnc_saveInventory;
player call MGI_fn_Arsenal;
player call MGI_friendIcons;
player addEventHandler ["respawn", {
  (_this select 0) call MGI_fn_Arsenal;
  (_this select 0) call MGI_friendIcons;
}];

addMissionEventHandler ["draw3D",
{
  {
    if (Action_Icon == 1 && side _x == playerSide && _x != player) then {
       _color = [0,0,0,0];
      call {
        if (side _x == west) exitWith {_color = [0,0,255,1]};
        if (side _x == east) exitWith {_color = [255,0,0,1]};
      }; 
      drawIcon3D ["", _color, [visiblePosition _x select 0, visiblePosition _x select 1,(visiblePosition _x select 2)+2], 0.2, 0.2, 45, (format ["%2 - %1m",round (player distance _x), name _x]), 1, 0.03, "PuristaMedium"];
    }; 
  } forEach (allUnits select {effectiveCommander vehicle _x == _x})
}];

 

 

 

playerRespawn.sqf should be onPlayerRespawn.sqf >> then, works for me . But two things:

- needs a condition to avoid action duplication when player is pointing at corpse (one action on alive and one action on corpse)

- can be embedded in MEH entityRespawn in init.sqf . So, just delete it and take the new init.sqf

 

Then, no more onPlayerRespawn.sqf ( codemerged in init.sqf)

No more onplayerKilled.sqf (all is embedded in the EH. now

 

init.sqf

You didn't understand or I didn't explain very well:

  _unit = _this select 0;
  _corpse = _this select 1;
  if (local _victim && _victim isKindOf "CAManBase") then {  // can't work . You first "chose" to define _unit and _corpse, so _victim is not defined.

I replaced the onPlayerRespawn.sqf (as said above) by more lines in MEH "entityRespawn" (same way)

 

 

Here is the new init.sqf:

Spoiler

 


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

execVM "fatigue.sqf";

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

minutos = paramsArray select 1;
pointlimit = ParamsArray Select 2;
disabledAI = ParamsArray Select 3;

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

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


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

 

 

RMK: Not checked your specific code... I don't have all the sqf.

 

Did you test your repetitive cleanup?

I missed your #define variables. I ran it with some light modifications. But if it works...

 

 

 

 

 

 

 

 

 

Share this post


Link to post
Share on other sites
1 hour ago, pierremgi said:

playerLocal ?   should be   initPlayerLocal.sqf at mission root of course. You can't change the name of event scripts.  so,  works for me SP/MP compatible

Furthermore, as you wants to reload (replenish) the mags, instead of saving loadout at death (entityKilled) , i'm saving when player closes arsenal.

I modified the addAction for that. You can delete some lines like entitykilled MEH code after that. I'll do for you;


New initPlayerLocal.sqf:
 

  Reveal hidden contents

 



[] execVM "killfeed\killfeed.sqf";

MGI_fn_Arsenal = {
  _this addaction [("<t color=""#FF4444"">" + "Open Virtual Arsenal" + "</t>"), {
    ["Open", true] call BIS_fnc_arsenal;
    (_this select 0) spawn {
      waitUntil {!isnull (uiNamespace getVariable ["RscDisplayArsenal", displayNull])};
      waitUntil {isNull (uiNamespace getVariable ["RscDisplayArsenal", displayNull])};
      [_this, [missionNamespace, name _this]] call BIS_fnc_saveInventory
    }
  },nil,0.8,false,true,"", "vehicle _target == vehicle _this"];
};

Action_Icon = 0;
Action_Menu ="<t color='#11ff11'>Show Friendly</t>";

MGI_FriendIcons = {
  _plyr = _this;
  _plyr addAction [Action_Menu, {
  _plyr = _this select 0;
    Action_Icon = (Action_Icon + 1) mod 2;
    Action_Menu = if (Action_Icon == 1) then [{"<t color='#ff1111'>Hide Friendly</t>"},{"<t color='#11ff11'>Show Friendly</t>"}];
    _plyr setUserActionText [(_this select 2),Action_Menu];
    },nil,0.9,false,true,"", "vehicle _target == vehicle _this"];
};

[player, [missionNamespace, name player]] call BIS_fnc_saveInventory;
player call MGI_fn_Arsenal;
player call MGI_friendIcons;
player addEventHandler ["respawn", {
  (_this select 0) call MGI_fn_Arsenal;
  (_this select 0) call MGI_friendIcons;
}];

addMissionEventHandler ["draw3D",
{
  {
    if (Action_Icon == 1 && side _x == playerSide && _x != player) then {
       _color = [0,0,0,0];
      call {
        if (side _x == west) exitWith {_color = [0,0,255,1]};
        if (side _x == east) exitWith {_color = [255,0,0,1]};
      }; 
      drawIcon3D ["", _color, [visiblePosition _x select 0, visiblePosition _x select 1,(visiblePosition _x select 2)+2], 0.2, 0.2, 45, (format ["%2 - %1m",round (player distance _x), name _x]), 1, 0.03, "PuristaMedium"];
    }; 
  } forEach (allUnits select {effectiveCommander vehicle _x == _x})
}];

 

 

 

 

playerRespawn.sqf should be onPlayerRespawn.sqf >> then, works for me . But two things:

- needs a condition to avoid action duplication when player is pointing at corpse (one action on alive and one action on corpse)

- can be embedded in MEH entityRespawn in init.sqf . So, just delete it and take the new init.sqf

 

init.sqf

You didn't understand or I didn't explain very well:

  _unit = _this select 0;
  _corpse = _this select 1;
  if (local _victim && _victim isKindOf "CAManBase") then {  // can't work . You first "chose" to define _unit and _corpse, so _victim is not defined.

 

I replaced the onPlayerRespawn.sqf (as said aboce) by more lines in MEH "entityRespawn" (same way)

 

 

Here is the new init.sqf:

  Reveal hidden contents

 



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

execVM "fatigue.sqf";

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

minutos = paramsArray select 1;
pointlimit = ParamsArray Select 2;
disabledAI = ParamsArray Select 3;

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

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


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

 

 

RMK: Not checked your specific code... I don't have all the sqf.

 

Then, no more onPlayerRespawn.sqf ( codemerged in init.sqf)

 

Did you test your repetitive cleanup?

I missed your #define variables. I ran it with some light modifications. But if it works...

 

 

 

 

 

 

 

 

 

Those files names are like you said "init" "initplayerlocal etc.. for the sake of just posting the code i short handed them. 

And I gotcha! Thats kinda what I was wondering if "victim" would work for me or if "victim" needs to be like newGuy oldGuy! that explains alot now lol Im gonna run through the code and ill get back in touch!

my repetitive script does work, in fact everything works 100% so far that I had done on my own the only thing i hadnt got to work was the EH we been going back and fourth on! ill let you know shortly how its going!

---------------------------------------EDIT------------------------------------------------------------
Everything works like a charm now!
have one slight error though not sure why
"game timer" works perfectly on local server dedicated server it doesnt ever start counting down
and I have the game ending when timer reaches 0 it ends the only thing is how do I have the game check both sides number of kills to decide who wins and who loses..

time = end3
I know how to use the BIS_fnc_MP but not sure the commands to tell or how to script ill give it a shot and tell me what it is
init.sqf  "gamefinished"

Spoiler

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;

 

//game ends by time pick winner (help here)------------------------------------------------

 

        }else{

_minutes= "Times up";

If ((minutes  < servertimeleft) and pointsA > pointsR) Then {_minutes = "west";

       //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{

 

If ((minutes  < servertimeleft) and pointsR > pointsA) Then {_minutes = "east";

//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;
and in the init.sqf i would have minutes = paramsaray select 1 (labeled in description correctly)

game time displays on the hud it works on local server / single player but dedicated server it doesnt work. 
trigger is used when time runs out
description / init.sqf /engine.sqf

Spoiler

descrip:
class minutes
    {
        title = "Max time";
        values[] = {8, 9, 10, 11, 12, 13, 14, 15,20};
        texts[] = {"8","9","10","11","12","13","14","15","20"};
        default = 20;
    };

 

 

Init.sqf

 

minutos = paramsArray select 1;

execVM =engine.sqf 

 

engine.sqf  

 

if (isServer) then {
        
    bluforflag setFlagSide west;    // camera know which side is which for uav intro
    opforflag setFlagSide east;     // camera know which side is which for uav intro

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

    A = 0;
    publicVariable "A";
    B = 0;
    publicVariable "B";

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

    pointlimit = ParamsArray Select 2;
    publicVariable "pointlimit";

};        

while {true} do {
    call compile preprocessFileLineNumbers "scripts\hud\hud_update.sqf";            
        
            
    if (isServer) then {    

        //Bases
        if (A == 1) then {
            pointsA = pointsA +1;
        };
        if (A == 2) then {
            pointsR = pointsR +1;    
        };

        if (B == 1) then {
            pointsA = pointsA +1;
        };
        if (B == 2) then {
            pointsR = pointsR +1;
        };
    };
            
    publicVariable "pointsA";
    publicVariable "pointsR";
    sleep 10;
    };

---------------- works local but not on dedicated server. and from learning what I have from you Im assumming this could be implemented into init.sqf which im pretty sure we already implemented the points in there now but how do I get the time to work on dedicated server?

 


 

Share this post


Link to post
Share on other sites

First of all, variables must be declared somewhere.

global ones like serverTimeLeft or gameFinished (I guess because it's not known commands) are available on all scripts of the PC (server fro exemple if the code is running on server.

Local ones like _minutes are available on their scope (already mentioned, inside EHs, inside addAction, inside spawned scripts , or even loops...) Very localized.

So, 1st evident mistake: you wrote _minutes and minutes. That's different. (even minutos in init.sqf...)

_minutes = "Times up";   ??? what for?

_minutes = "west";  a string? different from west (a side)

Anyway, I don't know from where come your variables gamefinished ???

 

I can't be sure because some sqf are running from init.sqf but check the variables. If defined in another sqf, they must be global (without underscore)

if they can stay locally (for a little local purpose), let them local (with _underscore)

if they must be synchronized on all PC, publicVariable them (as pointsA, pointsB...)

 

Pay attention also for the type of them:  "string" different from value different from [array] different from side different from object different from {code}....

 

Consider also this function for server: Bis_fnc_endMissionServer ; Far better. No need to remoteExec and you have your cases at once (or customize them).

Good reading.

 

Share this post


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

First of all, variables must be declared somewhere.

global ones like serverTimeLeft or gameFinished (I guess because it's not known commands) are available on all scripts of the PC (server fro exemple if the code is running on server.

Local ones like _minutes are available on their scope (already mentioned, inside EHs, inside addAction, inside spawned scripts , or even loops...) Very localized.

So, 1st evident mistake: you wrote _minutes and minutes. That's different. (even minutos in init.sqf...)

_minutes = "Times up";   ??? what for?

_minutes = "west";  a string? different from west (a side)

Anyway, I don't know from where come your variables gamefinished ???

 

I can't be sure because some sqf are running from init.sqf but check the variables. If defined in another sqf, they must be global (without underscore)

if they can stay locally (for a little local purpose), let them local (with _underscore)

if they must be synchronized on all PC, publicVariable them (as pointsA, pointsB...)

 

Pay attention also for the type of them:  "string" different from value different from [array] different from side different from object different from {code}....

 

Consider also this function for server: Bis_fnc_endMissionServer ; Far better. No need to remoteExec and you have your cases at once (or customize them).

Good reading.

 

okay and i switched them to english so you'd understand what they said in case you didnt. I know minutes, minutos all have to be the same wording!

and i made them public variables in the engine.sqf and executed in the init sqf. so if im understanding you correctly to make them global (which would make them work on dedicated server) i just need to define them without a _ 

_minutes ="times up" I was wondering if that was how i would define the variable in init.sqf or if it would be something different such as 
time > estimatedtimeleft; 
 

Share this post


Link to post
Share on other sites
1 hour ago, pierremgi said:

First of all, variables must be declared somewhere.

global ones like serverTimeLeft or gameFinished (I guess because it's not known commands) are available on all scripts of the PC (server fro exemple if the code is running on server.

Local ones like _minutes are available on their scope (already mentioned, inside EHs, inside addAction, inside spawned scripts , or even loops...) Very localized.

So, 1st evident mistake: you wrote _minutes and minutes. That's different. (even minutos in init.sqf...)

_minutes = "Times up";   ??? what for?

_minutes = "west";  a string? different from west (a side)

Anyway, I don't know from where come your variables gamefinished ???

 

I can't be sure because some sqf are running from init.sqf but check the variables. If defined in another sqf, they must be global (without underscore)

if they can stay locally (for a little local purpose), let them local (with _underscore)

if they must be synchronized on all PC, publicVariable them (as pointsA, pointsB...)

 

Pay attention also for the type of them:  "string" different from value different from [array] different from side different from object different from {code}....

 

Consider also this function for server: Bis_fnc_endMissionServer ; Far better. No need to remoteExec and you have your cases at once (or customize them).

Good reading.

 

I have successfully did the timer but i dont know how to make the game check which side had the most kills and declare that side a winner.
also I cant use my descrip. paramarray select 1 it wont recognize the time parameters put but its okay I can use 25 mins time as the standard!

 

init.sqf

Spoiler

minutos = 1500;//When mission should end in time.
if (isServer) then {
[] spawn 
{
    ELAPSED_TIME  = 0;
    START_TIME = diag_tickTime;
    while {ELAPSED_TIME < minutos} do 
{
    ELAPSED_TIME = diag_tickTime - START_TIME;
    publicVariable "ELAPSED_TIME";
    sleep 1;
    };
};
};


if!(isDedicated) then
{
[] spawn 
{
    while{ELAPSED_TIME < minutos } do
    {
    _time = minutos - ELAPSED_TIME;
    _finish_time_minutes = floor(_time / 60);
    _finish_time_seconds = floor(_time) - (60 * _finish_time_minutes);
    if(_finish_time_seconds < 10) then
    {
    _finish_time_seconds = format ["0%1", _finish_time_seconds];
        };
    if(_finish_time_minutes < 10) then
        {
    _finish_time_minutes = format ["0%1", _finish_time_minutes];
        };
    _formatted_time = format ["%1:%2", _finish_time_minutes, _finish_time_seconds];

    hintSilent format ["Time left:\n%1", _formatted_time];
        sleep 1;
    };
};
};
 


 

Share this post


Link to post
Share on other sites

On server, use addSideScore instead of an addition pointsA = pointsA +1

try to use scoreSide (for init values) and addScoreSide very easy as the side is already a parameter

then

"SideScore" call BIS_fnc_endMissionServer

stay on server for all the stuff (must be on server). if (isServer) then {...code here...};

 

More than that, If you want to hint some score, you can use getPlayerScores

Not tested.

 

Did you write some mission parameter (as shown in lobby, upper right corner)?

You could choose the timer duration

You need to write something in description.ext, like:

 

class Params {

        class MGI_timer {
          title = "Timer duration";
          values[] = {15, 20, 30, 60};
          texts[] = {"15 min.","20 min.","30 min.","60 min."};
          default = 30;
       };

};

 

and in init.sqf:

timer = 60* ("MGI_timer" call BIS_fnc_getParamValue);

 

 

Share this post


Link to post
Share on other sites
4 hours ago, pierremgi said:

On server, use addSideScore instead of an addition pointsA = pointsA +1

try to use scoreSide (for init values) and addScoreSide very easy as the side is already a parameter

then

"SideScore" call BIS_fnc_endMissionServer

stay on server for all the stuff (must be on server). if (isServer) then {...code here...};

 

More than that, If you want to hint some score, you can use getPlayerScores

Not tested.

 

Did you write some mission parameter (as shown in lobby, upper right corner)?

You could choose the timer duration

You need to write something in description.ext, like:

 

class Params {

        class MGI_timer {
          title = "Timer duration";
          values[] = {15, 20, 30, 60};
          texts[] = {"15 min.","20 min.","30 min.","60 min."};
          default = 30;
       };

};

 

and in init.sqf:

timer = 60* ("MGI_timer" call BIS_fnc_getParamValue);

 

 

yea i have the param set up in description but no matter what i choose in paramaters in the top right corner it never works only way to adjust time is to edit the description file but  all my other params work. so maybe i need to try your timer= 60 method although "classname = 1,2,3..etc params work for my other options. But im not to worried about it as for mission time can be a standard thing. I was trying to make a hub and got stuck...

1) after making your layout in gui editor.... and clicking safe zone.... and saving it where does it save too or how do i go about getting all the info for a Rsccut i make. not having much luck googling it

2) how do you apply script to it like lets say i want the match time in the top center as well as the score for each side.... after you make the rsccut how exactly do you script it in? i have a sample mission beside me and his hud i just dont see how  it is linked to read the different things he has it doing. 

Share this post


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

okay and one thing I didnt do addscore because im a little confused after searching it people confused the hell outta me so many different ways of going about this.
could you give like a example script of it this is what ive gotten so far
 

unitkilled = _this select 0;
_killed = _this select 1;

if(isServer) then {unitkilled = { { if(side_x isEqualToWEST) then { _x addScore 1; }; }forEach allPlayers; }; if(side _x isEqualTo EAST) then { _x addEventhandler ["killed", unitkilled]; }; }forEach allUnits; };

would just place that in init.sqf and would be good?


 

Share this post


Link to post
Share on other sites

test in MP server (doesn't work in SP) :

 

addMissionEventHandler ["eachFrame",{
 format ["west: %1, east: %2",scoreSide west, scoreSide east] remoteExec ["hintsilent",0]
}];

 

As you can see scoreSide is automatically incremented by 1, each time a player shoot at enemy. Furthermore if you tick "allow Ai score" in multiplayer settings, all playable units(non player)  can add score for its side.

 

1 you need to know what you want exactly for scoring (you can easily addScoreSide for all AIs)

2 you can compare the side scores when you want

 

 

Share this post


Link to post
Share on other sites
10 hours ago, pierremgi said:

test in MP server (doesn't work in SP) :

 

addMissionEventHandler ["eachFrame",{
 format ["west: %1, east: %2",scoreSide west, scoreSide east] remoteExec ["hintsilent",0]
}];

 

As you can see scoreSide is automatically incremented by 1, each time a player shoot at enemy. Furthermore if you tick "allow Ai score" in multiplayer settings, all playable units(non player)  can add score for its side.

 

1 you need to know what you want exactly for scoring (you can easily addScoreSide for all AIs)

2 you can compare the side scores when you want

 

 

Okay im still stuck. The script I did should work. However for my "hud" with each score and server time to work I need to tie in "pointsA" "pointsR, minutes, pointlimit and im not sure how to do that everything i have tried hasnt worked.

init.sqf

Spoiler

if (isServer) then {
{
_x addMPeventhandler ["MPKilled", {[_this select 0, _this select 1] call "scripts\motor.sqf";}];
} forEach _units;
};
  call compile preprocessFileLineNumbers "scripts\hud\hud_create.sqf";

motor.sqf

Spoiler

fnc_killed = {

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


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

    pointlimit = ParamsArray Select 2;
    publicVariable "pointlimit"

_unit = _this select 0;
_killer = _this select 1;

_unitside = side _unit;
_killerside = side _killer;


if !(_killerside == _unitside) then {

    if (_killerside == WEST) then {
         PointsA = PointsA + 1;
         hint format["%1 kills", pointsA];
    };

    if (_killerside == EAST) then {
         PointsR = PointsR + 1;
         hint format["%1 kills", pointsR];
    };

   };
};

call compile preprocessFileLineNumbers "scripts\hud\hud_update.sqf";


my hud uses motor.sqf to update it so pointsA,pointsR,minutos,segundos,pointlimit all need to be in there and right now im not getting a error code but my hud is just blank 

Original motor.sqf

Spoiler

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

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

    A = 0;
    publicVariable "A";
    B = 0;
    publicVariable "B";

    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";            
        
            
    if (isServer) then {    

        //Bases
        if (A == 1) then {
            pointsA = pointsA +1;
        };
        if (A == 2) then {
            pointsR = pointsR +1;    
        };

        if (B == 1) then {
            pointsA = pointsA +1;
        };
        if (B == 2) then {
            pointsR = pointsR +1;
        };
    };
            
    publicVariable "pointsA";
    publicVariable "pointsR";
    sleep 10;
    };
 

 

Share this post


Link to post
Share on other sites

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 && isServer) then { (side _instigator) addScoreSide 1};
}];

 

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

 

Share this post


Link to post
Share on other sites
Sign in to follow this  

×