Heatseeker 0 Posted February 19, 2008 Like the tittle says.. I want to use a selectable casualty cap thru the description file. Respawn and JIP involved.. titleParam1 = "Abort on casualties"; valuesParam1[] = {1,2,3,4,5}; defValueParam1 = 2; textsParam1[] = {"11","22","44","88","110"}; 1. How should i check if the amount of friendly (blu4) dead units equals a value? ("11","22","44","88","110"). 2. How does Arma do it? (Arma already does this, it can be seen in the scoreboard). Q #2 has me rather curious, since the function is already part of the game using yet another script could be avoided . Share this post Link to post Share on other sites
sickboy 13 Posted February 19, 2008 First sight and thought, v1.09beta and upwards compatible: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">/*  Script by Sickboy (sb _at_ 6thSense.eu), idea by Heatseeker  Version: v0.2 */ private ["_exit"]; _exit = false; T_KillEnd = false; [] spawn {  waitUntil { T_KillEnd };  sleep 5;  forceEnd; }; if (isServer) then {  T_KillC = 0;  T_Killed = objNull;  T_fKilled = { T_KillC = T_KillC + 1; if (T_KillC >= param1) then { T_KillEnd = true; publicVariable "T_KillEnd" } };  "T_Killed" addPublicVariableEventHandler { (_this select 1) call T_fKilled };  if (player != player) then { _exit = true }; }; // No need to waitUntil player == player on a dedy server ^^ if (_exit) exitWith {}; waitUntil { player == player }; player addEventHandler ["Killed", { T_Killed = _this select 0; if (isServer) then { T_Killed call T_fKilled } else { publicVariable "T_Killed" } }]; Notes: [*] I used this method as opposed to arrays with strings or objects, or list all units on map and check with isPlayer etc. etc.  which we would check every few milliseconds for deaths etc, because I don't believe such system would be water tight and requires more processing on the server side. [*] Killed Eventhandlers only seem to work on the computer where the unit who was killed, was local. As such we're broadcasting the death of the player through the T_Killed variable. [*] We do an isServer check in the Killed EH to check if this was a serverClient (ingame server hosting), because we have to execute the T_fKilled function manually, because the publicEventHandler will note 'fire' because the variable was 'publicVariabled' on the server. (the eventhandler only 'fires' on computers who 'receive' the updated variable, not on the computer who 'sends' it) [*] The current setup is 'incompatible' with AI in player group. As their deaths will not count in this scripting example. Also TeamSwitch is not taken into account. [*] Inside the T_fKilled function, _this contains the player object that was killed, if you like you can do something with it. [*] Change T_ to any kind of prefix you use, e.g: HEAT_ [*] As opposed to OFP EHs, in ArmA a respawned unit still has the EHs it had before, so it is no longer required to re-add EHs after respawning. Share this post Link to post Share on other sites
Heatseeker 0 Posted February 19, 2008 You are... very damn fast . Quote[/b] ]I used this method as opposed to arrays with strings or objects, or list all units on map and check with isPlayer etc. etc. which we would check every few milliseconds for deaths etc, because I don't believe such system would be water tight and requires more processing on the server side. This is very surprising, your code is far from anything i expected from a possible reply, im going thru it trying to "get it". Thank you very much SB . Any input on #2? You must feel curious too . Share this post Link to post Share on other sites
sickboy 13 Posted February 19, 2008 You are... very damn fast .Quote[/b] ]I used this method as opposed to arrays with strings or objects, or list all units on map and check with isPlayer etc. etc.  which we would check every few milliseconds for deaths etc, because I don't believe such system would be water tight and requires more processing on the server side. This is very surprising, your code is far from anything i expected from a possible reply, im going thru it trying to "get it". Thank you very much SB . Any input on #2? You must feel curious too . Hey Buddy, NP :-) Glad to be of service to my sweet kittylover I've updated it a few seconds ago. It should now ensure forceEnd on all computers and added an _exit check to exit the script before the waitUntil { player == player }; incase the machine is a deddy server ;D Also fixed a missing end bracket: ]  at the end of the killed eh. Nr #2 is a good one, I believe the data is not accessible from within the scripting engine, ill think about it some more. Note: Don't forget to change the  valuesParam1[] = {1,2,3,4,5};  to  valuesParam1[] = {11,22,44,88,110};   Share this post Link to post Share on other sites
Heatseeker 0 Posted February 19, 2008 ForceEnd sounds like such a raw ending way, im calling a small cam work and use end# in the end instead . You only forgot to credit yourself in the script and give it a version number, it can be a very usefull resource to other ME's imo. Many thanks again . edit: Quote[/b] ]Note: Don't forget to change the valuesParam1[] = {1,2,3,4,5}; to valuesParam1[] = {11,22,44,88,110} Hmm... i probably would lol... Share this post Link to post Share on other sites
sickboy 13 Posted February 19, 2008 ForceEnd sounds like such a raw ending way, im calling a small cam work and use end# in the end instead . You only forgot to credit yourself in the script and give it a version number, it can be a very usefull resource to other ME's imo. Many thanks again . Hehe, you wanted an End, you got one Go right ahead mate, do with it as you please; it's yours Well, ill add Author and Version just for the sake of it Cheers Share this post Link to post Share on other sites
Heatseeker 0 Posted February 20, 2008 <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> /* Script by Sickboy (sb _at_ 6thSense.eu), idea by Heatseeker Version: v0.1 */ private ["_exit"]; _exit = false; T_KillEnd = false; [] spawn { waitUntil { T_KillEnd }; sleep 5; forceEnd; }; if (isServer) then { T_KillC = 0; T_Killed = objNull; T_fKilled = { T_KillC = T_KillC + 1; if (T_KillC >= param1) then { T_KillEnd = true; publicVariable "T_KillEnd" } }; "T_Killed" addPublicVariableEventHandler { (_this select 1) call T_fKilled }; if (player != player) then { _exit = true }; }; // No need to waitUntil player == player on a dedy server ^^ if (_exit) exitWith {}; waitUntil { player == player }; player addEventHandler ["Killed", { T_Killed = _this select 0; if (isServer) then { T_Killed call T_fKilled } else { publicVariable "T_Killed" } }]; Missing [] before spawn was showing me an error, i was also missing a ] in the last line . Dont mean to push but can you satisfy my curiosity on this? <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> "T_Killed" addPublicVariableEventHandler { (_this select 1) call T_fKilled }; addPublicVariableEventHandlerWhat ?? Share this post Link to post Share on other sites
sickboy 13 Posted February 20, 2008 ... Thanks for the fix for spawn. The missing ] was already added to the script code :PI haven't tested the script ingame, only theorized it, it's weird that execVM allows for  no input parameter, while spawn doesn't but hey, it's resolved this way addPublicVariableEventHandler ?? http://community.bistudio.com/wiki/addPublicVariableEventHandler Share this post Link to post Share on other sites
Heatseeker 0 Posted February 20, 2008 This will make a nice resource together with an example mission (init/description), you deserve a plate of whiskas and a bowl of milk . Share this post Link to post Share on other sites
sickboy 13 Posted February 20, 2008 This will make a nice resource together with an example mission (init/description), you deserve a plate of whiskas and a bowl of milk . Aww sweet I will incorporate the script into my Multiplayer BIKI Guide, I think it exploits the ArmA Functions and MP stuff well. If you wanna spread it incl demo mission etc, feel free Share this post Link to post Share on other sites