Jump to content

Recommended Posts

Good guys,

I would like you to help me with this script:

It turns out that I made this script with the purpose that when a unit is eliminated depending on the side it is, it does an action, but I do not know what it would be doing wrong.

 

this script if it worked as it wanted in dedicated server:

FAM_DeadCivilianCount = 0;
publicVariable "FAM_DeadCivilianCount";


{
  if (side _x == Civilian && _x iskindof "Man") then {
      _x addEventHandler ["killed", 
      {
        ["Civil", ["Han Matado un Civil. Penzalización -2 Puntos!"]] remoteExecCall ["BIS_fnc_showNotification"];  
        FAM_DeadCivilianCount = FAM_DeadCivilianCount + 2;
        publicvariable "FAM_DeadCivilianCount";
        
       }];
	};
  } foreach allunits;
 

 

But when I combine it in this way for the other side:

 

FAM_DeadCivilianCount = 0;
FAM_DeadPlayerCount = 0;
FAM_DeadPEnemyCount = 0;

publicVariable "FAM_DeadCivilianCount";
publicVariable "FAM_DeadPlayerCount";
publicVariable "FAM_DeadPEnemyCount";

{
  if (side _x == Civilian && _x iskindof "Man") then {
    _x addEventHandler ["killed", 
    {
      ["Civil", ["Han Matado un Civil. Penzalización -2 Puntos!"]] remoteExecCall ["BIS_fnc_showNotification"];  
      FAM_DeadCivilianCount = FAM_DeadCivilianCount + 2;
      publicvariable "FAM_DeadCivilianCount";
      
    }];

  } else {
     if (side player == WEST && player iskindof "Man") then {
      player addEventHandler ["killed", 
      {
        ["JugadorDead", ["Miembro de equipo Muerto. Penzalización -1 Puntos!"]] remoteExecCall ["BIS_fnc_showNotification"];  
        FAM_DeadPlayerCount = FAM_DeadPlayerCount + 1;
        publicvariable "FAM_DeadPlayerCount";
   
      }];
    };
  } else {
     if (side _x == EAST && _x iskindof "Man") then {

      if (FAM_DeadPEnemyCount == 20) then {
      publicVariable "FAM_DeadPEnemyCount";
      objetivoTareaTres = objetivoTareaTres + 2;
      publicVariable "objetivoTareaTres";
      ["tareaTres", ["20 Enemigos Muertos. Reciben 2 Puntos!"]] remoteExecCall ["BIS_fnc_showNotification"];
      //hint str cash;
      
      };

      _x addEventHandler ["killed", 
      {
        ["JugadorDead", ["Miembro de equipo Muerto. Penzalización -1 Puntos!"]] remoteExecCall ["BIS_fnc_showNotification"];  
        FAM_DeadPEnemyCount = FAM_DeadPEnemyCount + 1;
        publicVariable "FAM_DeadPEnemyCount";
   
      }];
    };
  };
} foreach allunits;

 

It throws me an error and I would like to know how they help me in Server to work correctly.

 

thanks and regards.

Share this post


Link to post
Share on other sites
20 minutes ago, redburn said:

It throws me an error and I would like to know how they help me in Server to work correctly.

 

thanks and regards.

 

Hi redburn,

 

Try this out you had some brackets in the wrong places.

Spoiler

FAM_DeadCivilianCount = 0;
FAM_DeadPlayerCount = 0;
FAM_DeadPEnemyCount = 0;

publicVariable "FAM_DeadCivilianCount";
publicVariable "FAM_DeadPlayerCount";
publicVariable "FAM_DeadPEnemyCount";

{
    if (side _x == civilian && _x isKindOf "Man") then {
        _x addEventHandler ["killed", 
        {
            ["Civil", ["Han Matado un Civil. Penzalización -2 Puntos!"]] remoteExecCall ["BIS_fnc_showNotification"];  
            FAM_DeadCivilianCount = FAM_DeadCivilianCount + 2;
            publicVariable "FAM_DeadCivilianCount";
      
        }];
    } else {
        if (side player == WEST && player isKindOf "Man") then {
            player addEventHandler ["killed", 
            {
                ["JugadorDead", ["Miembro de equipo Muerto. Penzalización -1 Puntos!"]] remoteExecCall ["BIS_fnc_showNotification"];  
                FAM_DeadPlayerCount = FAM_DeadPlayerCount + 1;
                publicVariable "FAM_DeadPlayerCount";
            }];
        } else {
            if (side _x == EAST && _x isKindOf "Man") then {
                if (FAM_DeadPEnemyCount == 20) then {
                    publicVariable "FAM_DeadPEnemyCount";
                    objetivoTareaTres = objetivoTareaTres + 2;
                    publicVariable "objetivoTareaTres";
                    ["tareaTres", ["20 Enemigos Muertos. Reciben 2 Puntos!"]] remoteExecCall ["BIS_fnc_showNotification"];
                    //hint str cash;
                };
                _x addEventHandler ["killed", {
                    ["JugadorDead", ["Miembro de equipo Muerto. Penzalización -1 Puntos!"]] remoteExecCall ["BIS_fnc_showNotification"];  
                    FAM_DeadPEnemyCount = FAM_DeadPEnemyCount + 1;
                    publicVariable "FAM_DeadPEnemyCount";
                }];
            };
        };
    };
} forEach allUnits;

 

  • Like 1

Share this post


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

 

Hi redburn,

 

Try this out you had some brackets in the wrong places.

  Reveal hidden contents

FAM_DeadCivilianCount = 0;
FAM_DeadPlayerCount = 0;
FAM_DeadPEnemyCount = 0;

publicVariable "FAM_DeadCivilianCount";
publicVariable "FAM_DeadPlayerCount";
publicVariable "FAM_DeadPEnemyCount";

{
    if (side _x == civilian && _x isKindOf "Man") then {
        _x addEventHandler ["killed", 
        {
            ["Civil", ["Han Matado un Civil. Penzalización -2 Puntos!"]] remoteExecCall ["BIS_fnc_showNotification"];  
            FAM_DeadCivilianCount = FAM_DeadCivilianCount + 2;
            publicVariable "FAM_DeadCivilianCount";
      
        }];
    } else {
        if (side player == WEST && player isKindOf "Man") then {
            player addEventHandler ["killed", 
            {
                ["JugadorDead", ["Miembro de equipo Muerto. Penzalización -1 Puntos!"]] remoteExecCall ["BIS_fnc_showNotification"];  
                FAM_DeadPlayerCount = FAM_DeadPlayerCount + 1;
                publicVariable "FAM_DeadPlayerCount";
            }];
        } else {
            if (side _x == EAST && _x isKindOf "Man") then {
                if (FAM_DeadPEnemyCount == 20) then {
                    publicVariable "FAM_DeadPEnemyCount";
                    objetivoTareaTres = objetivoTareaTres + 2;
                    publicVariable "objetivoTareaTres";
                    ["tareaTres", ["20 Enemigos Muertos. Reciben 2 Puntos!"]] remoteExecCall ["BIS_fnc_showNotification"];
                    //hint str cash;
                };
                _x addEventHandler ["killed", {
                    ["JugadorDead", ["Miembro de equipo Muerto. Penzalización -1 Puntos!"]] remoteExecCall ["BIS_fnc_showNotification"];  
                    FAM_DeadPEnemyCount = FAM_DeadPEnemyCount + 1;
                    publicVariable "FAM_DeadPEnemyCount";
                }];
            };
        };
    };
} forEach allUnits;

 

 

thanks for your help! I managed to update the script so far, doing it this way too, if I'm wrong or you think I have to optimize the code just tell me.

 

FAM_DeadCivilianCount = 0;
FAM_DeadPlayerCount = 0;
FAM_DeadPEnemyCount = 0;

publicVariable "FAM_DeadCivilianCount";
publicVariable "FAM_DeadPlayerCount";
publicVariable "FAM_DeadPEnemyCount";

{

  if (side _x == Civilian && _x iskindof "Man") then {
    _x addEventHandler ["killed", 
    {
      ["Civil", ["Han Matado un Civil. Penzalización -2 Puntos!"]] remoteExecCall ["BIS_fnc_showNotification"];  
      FAM_DeadCivilianCount = FAM_DeadCivilianCount + 2;
      publicvariable "FAM_DeadCivilianCount";
      //FAM_DeadCivilianCount call FAM_fnc_deadCivilians;

    }];
  };

  if (side _x == EAST && _x iskindof "Man") then {
    _x addEventHandler ["killed", 
    {
        FAM_DeadPEnemyCount = FAM_DeadPEnemyCount + 1;
        publicVariable "FAM_DeadPEnemyCount";
   
      }];
    };

    if (side player == WEST && player iskindof "Man") then {
      player addEventHandler ["killed", 
      {
        ["JugadorDead", ["Miembro de equipo Muerto. Penzalización -1 Puntos!"]] remoteExecCall ["BIS_fnc_showNotification"];  
        FAM_DeadPlayerCount = FAM_DeadPlayerCount + 1;
        publicvariable "FAM_DeadPlayerCount";
   
      }];
    };    

} foreach allunits;  


[] spawn {
  if (FAM_DeadPEnemyCount == 20) then {
    publicVariable "FAM_DeadPEnemyCount";
    objetivoTareaTres = objetivoTareaTres + 2;
    publicVariable "objetivoTareaTres";
    ["tareaTres", ["20 Enemigos Muertos. Reciben 2 Puntos!"]] remoteExecCall ["BIS_fnc_showNotification"];
      
  };
};

 

thanks and regards.

Share this post


Link to post
Share on other sites

Your approach is not right. For example, if a civilian is killed, you have a 2 pt penalization, no matter the killing side. ... And it's difficult to understand your logic with if (side player == WEST && player iskindof "Man") then ...  (I never saw a player not a "man"... except a script for a dog somewhere).

 

It seems you need a custom score.

It's easy to do.

- You're right in initialization of your variable and publicVariable them, but do it from initServer.sqf. If in init.sqf, any JIP will reset your variables!

 

- use a single mission event hanlder (MEH) in init.sqf (here you need to run it on each local PC connecting):

addMissionEventHandler ["EntityKilled", {

  params ["_killed", "_killer", "_instigator"];

   if (isNull _instigator) then {_instigator = UAVControl vehicle _killer select 0}; // UAV/UGV player operated road kill

   if (isNull _instigator) then {_instigator = _killer}; // player driven vehicle road kill

   hint format ["Killed By %1", name _instigator];  // or what ever code here

  }];

 

- you need to catch the side of the killed unit (as you know a dead is civilian). Two ways:

   * write for the side of the group. Example:

      side group _killed == west

      ... as a dead doesn't leave his group instantaneously), but 100% reliable? I don't know. (a dead falls to nullGrp when other units are aware of the kill)

   * or grab the side of your unit by Bis_fnc_Objectside . Not reliable if you changed the side of a unit (refers to the type of the object)

 

- As you did, don't forget to publicVariable your scores each time they change!

 

Now, you should write all cases and intended scores.

  • Like 2

Share this post


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

Your approach is not right. For example, if a civilian is killed, you have a 2 pt penalization, no matter the killing side. ... And it's difficult to understand your logic with if (side player == WEST && player iskindof "Man") then ...  (I never saw a player not a "man"... except a script for a dog somewhere).

 

It seems you need a custom score.

It's easy to do.

- You're right in initialization of your variable and publicVariable them, but do it from initServer.sqf. If in init.sqf, any JIP will reset your variables!

 

- use a single mission event hanlder (MEH) in init.sqf (here you need to run it on each local PC connecting):

addMissionEventHandler ["EntityKilled", {

  params ["_killed", "_killer", "_instigator"];

   if (isNull _instigator) then {_instigator = UAVControl vehicle _killer select 0}; // UAV/UGV player operated road kill

   if (isNull _instigator) then {_instigator = _killer}; // player driven vehicle road kill

   hint format ["Killed By %1", name _instigator];  // or what ever code here

  }];

 

- you need to catch the side of the killed unit (as you know a dead is civilian). Two ways:

   * write for the side of the group. Example:

      side group _killed == west

      ... as a dead doesn't leave his group instantaneously), but 100% reliable? I don't know. (a dead falls to nullGrp when other units are aware of the kill)

   * or grab the side of your unit by Bis_fnc_Objectside . Not reliable if you changed the side of a unit (refers to the type of the object)

 

- As you did, don't forget to publicVariable your scores each time they change!

 

Now, you should write all cases and intended scores.

32/5000

I could do this in the init.sqf?

//init.sqf

if (!local isServer) exitWith {onPlayerConnected "updates.sqf"};

In updates.sqf

 

//updates.sqf

publicVariable "publicTime";
publicVariable "penaTiempo";
publicVariable "objetivoPrimario";
publicVariable "objetivoSecundario";
publicVariable "objetivoTarea";
publicVariable "bonoBandera";
publicVariable "civilesFinal";
publicVariable "vehEnemigoFinal";
publicVariable "PuntajeFinal";

//Misiones
publicVariable "objetivoPrimarioOne";
publicVariable "objetivoPrimarioDos";

//Objetivo Secundario
publicVariable "objetivoSecundario";

//Tareas 
publicVariable "objetivoTareaUno";
publicVariable "objetivoTareaDos";
publicVariable "objetivoTareaTres";

//Vehículos neutralizados
publicVariable "vehAliadoFinalUno";
publicVariable "vehAliadoFinalDos";
publicVariable "vehAliadoFinalTres";

//Otros
publicVariable "FAM_granDamage";
publicVariable "FAM_ambushEnemy";
publicVariable "FAM_libres";

publicVariable "FAM_DeadCivilianCount";
publicVariable "FAM_DeadPlayerCount";
publicVariable "FAM_DeadPEnemyCount";

 

I could be doing it right?

 

Share this post


Link to post
Share on other sites
48 minutes ago, redburn said:

32/5000

I could do this in the init.sqf?


//init.sqf

if (!local isServer) exitWith {onPlayerConnected "updates.sqf"};

In updates.sqf

 


//updates.sqf

publicVariable "publicTime";
publicVariable "penaTiempo";
publicVariable "objetivoPrimario";
publicVariable "objetivoSecundario";
publicVariable "objetivoTarea";
publicVariable "bonoBandera";
publicVariable "civilesFinal";
publicVariable "vehEnemigoFinal";
publicVariable "PuntajeFinal";

//Misiones
publicVariable "objetivoPrimarioOne";
publicVariable "objetivoPrimarioDos";

//Objetivo Secundario
publicVariable "objetivoSecundario";

//Tareas 
publicVariable "objetivoTareaUno";
publicVariable "objetivoTareaDos";
publicVariable "objetivoTareaTres";

//Vehículos neutralizados
publicVariable "vehAliadoFinalUno";
publicVariable "vehAliadoFinalDos";
publicVariable "vehAliadoFinalTres";

//Otros
publicVariable "FAM_granDamage";
publicVariable "FAM_ambushEnemy";
publicVariable "FAM_libres";

publicVariable "FAM_DeadCivilianCount";
publicVariable "FAM_DeadPlayerCount";
publicVariable "FAM_DeadPEnemyCount";

 

I could be doing it right?

 

 

Do you know what publicVariable does? Doesn't seem like it, or rather you seem confused about its usage (in this case).

 

Does every client need to have access to all those variables? The more you cut down on network traffic, the better.

If you simply want to handle civilian/friendly kills for every side you can do it exclusively on the server, no need to broadcast any variable at all.

 

Cheers

 

 

  • Like 1

Share this post


Link to post
Share on other sites
5 hours ago, Grumpy Old Man said:

 

Do you know what publicVariable does? Doesn't seem like it, or rather you seem confused about its usage (in this case).

 

Does every client need to have access to all those variables? The more you cut down on network traffic, the better.

If you simply want to handle civilian/friendly kills for every side you can do it exclusively on the server, no need to broadcast any variable at all.

 

Cheers

 

 

I'm sorry to say that as I mentioned in previous posts I'm still new and I'm beginning to understand how each variable works, among other things, that's why I ask questions in that way, because if it costs me a little, I do not give up. Thanks for the book before

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

×