redburn 聽聽 20 Posted October 24, 2018 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
cb65 聽聽 86 Posted October 24, 2018 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; 聽 1 Share this post Link to post Share on other sites
redburn 聽聽 20 Posted October 24, 2018 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
pierremgi 聽聽 4944 Posted October 25, 2018 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. 2 Share this post Link to post Share on other sites
redburn 聽聽 20 Posted October 25, 2018 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
Grumpy Old Man 聽聽 3551 Posted October 25, 2018 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 聽 聽 1 Share this post Link to post Share on other sites
redburn 聽聽 20 Posted October 25, 2018 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