OFPEC Forum
Editors Depot - Mission Editing and Scripting => Arma2 - Editing/Scripting Multiplayer => Topic started by: sharkattack on 14 Jul 2009, 19:26:42
-
hi lads ..
i have a beta mission in the beta forums in which im trying to add an event handler to detect unsupressed gunfire . can get it to work by itself but if i add another event handler based script .. im buggered
had no problem with each EH in seperate trials but as soon as i mixed them only one or the other would work ..
anyone tell me what im doing wrong ..
first EH thanks to (spooner)
gamelogic to count number of cranes destroyed at port
{ _x addEventHandler ["KILLED", { _this execVM "cranes.sqf" }] } forEach nearestObjects [this, ["Land_A_Crane_02b"], 500]
cranes.sqf (thanks spooner) works a treat alone
if (isNil "ecraneCounter") then { ecraneCounter = 0 };
ecraneCounter = ecraneCounter + 1;
// <-- Do stuff every time.
if (ecraneCounter == 5) then
{
seven=true;
publicvariable "seven";
};
ecranecounter=false in init sqf
#2
trigger to detect unsilenced gunfire ( from arma) but works when tested alone
{_x addEventHandler ["fired",{if (!((_this select 2) in ["bizon_silenced","M4A1_HWS_GL_SD_Camo","M4A1_AIM_SD_camo","M9SD","G36_C_SD_eotech","PipeBombMuzzle"]) && !gunfire) then {gunfire=true; _this execVM "elekalert.sqf";}}];} forEach thislist;
elekalert.sqf
{_x setUnitPos "MIDDLE"} forEach list westport;{_x setBehaviour "AWARE"} forEach list westport;
sleep 3;
hint "Contact ... Enemy alerted to gunfire around the port of Elektrozavodsk ";
gunfire =false in init sqf ..
hope you can make some sort of sense from my questions .. :P
as always any help would be real nice :good:
-
if (isNil "ecraneCounter") then { ecraneCounter = 0 };
...
ecranecounter=false in init sqf
Hmm, I might be wrong but it looks like the line containing isNil "ecraneCounter" is never executed because you're assigning a value to ecraneCounter in the init.sqf (if a variable is set to _any_ value it's not nil anymore).
Correction: the line will be executed, but ecraneCounter won't be set to zero. So you end up adding one to "false".
-
Yes, I gave him the original script but didn't tell him to set the value to false initially.
-
sorry for for my incompitance ... wished id stuck in at school now ... mind you it was all ceefax pages and defender ... (those of a certain age will know what i mean)
anyway it works perfectly now :good:
many thanks spooner and worldeater
nice one lads