Alert23 215 Posted May 21, 2019 Hi everyone, i have already wasted some time in this script.. trying to addeventhandler to every object in mission by its classname, i want to create an disappearing effect when a target is hit. adding eventhandler by naming the object works but i have to many objects on the map to add them all manually [] spawn { { if (typeOf _x == "Land_VR_Target_Dart_01_F") then { _x addEventHandler ["HitPart", { playSound "hitplate"; sleep 0.3; _x hideobject true; sleep 0.1; _x hideobject false; sleep 0.2; _x hideobject true; sleep 0.1; _x hideobject false; sleep 0.3; _x hideobject true; sleep 0.2; _x hideobject false; sleep 0.1; _x hideobject true; sleep 0.3; _x hideobject false; sleep 0.05; _x hideobject true; sleep 0.05; _x hideobject false; sleep 0.05; _x hideobject true; sleep 0.1; _x hideobject false; sleep 0.02; _x hideobject true; sleep 0.03; _x hideobject false; sleep 0.01; _x hideobject true; deletevehicle _x; }]; }; }; }; this dosent throw any error but also dosent work. what i do wrong? Share this post Link to post Share on other sites
POLPOX 779 Posted May 21, 2019 Few problems: The spawn takes no argument, so _x means nothing in the spawn You cannot use sleep inside an Event Handler, use spawn inside _x in HitPart Event Handler means nothing. I think you want (_this#0#0) 1 Share this post Link to post Share on other sites
Alert23 215 Posted May 21, 2019 21 minutes ago, POLPOX said: Few problems: The spawn takes no argument, so _x means nothing in the spawn You cannot use sleep inside an Event Handler, use spawn inside _x in HitPart Event Handler means nothing. I think you want (_this#0#0) thanks for your advise, maybe something like this i rly dont know what im doing 😃 if (typeOf _x == "Land_VR_Target_Dart_01_F") then { _x addEventHandler ["HitPart",{ (_this select 0) spawn { playSound "hitplate"; sleep 0.3; _x hideobject true; sleep 0.1; _x hideobject false; sleep 0.2; _x hideobject true; sleep 0.1; _x hideobject false; sleep 0.3; _x hideobject true; sleep 0.2; _x hideobject false; sleep 0.1; _x hideobject true; sleep 0.3; _x hideobject false; sleep 0.05; _x hideobject true; sleep 0.05; _x hideobject false; sleep 0.05; _x hideobject true; sleep 0.1; _x hideobject false; sleep 0.02; _x hideobject true; sleep 0.03; _x hideobject false; sleep 0.01; _x hideobject true; deletevehicle _x; }; }]; }; Share this post Link to post Share on other sites
Alert23 215 Posted May 22, 2019 15 hours ago, POLPOX said: Few problems: The spawn takes no argument, so _x means nothing in the spawn You cannot use sleep inside an Event Handler, use spawn inside _x in HitPart Event Handler means nothing. I think you want (_this#0#0) okay so according to what to said than is must be like this if im "right" ( im not =D ) {if (typeOf _x == "Land_VR_Target_Dart_01_F") then { _x addEventHandler ["HitPart",{ (_this select 0 select 0) spawn { params ["_target"]; playSound "hitplate"; sleep 0.3; _target hideobject true; sleep 0.1; _target hideobject false; sleep 0.2; _target hideobject true; sleep 0.1; _target hideobject false; sleep 0.3; _target hideobject true; sleep 0.2; _target hideobject false; sleep 0.1; _target hideobject true; sleep 0.3; _target hideobject false; sleep 0.05; _target hideobject true; sleep 0.05; _target hideobject false; sleep 0.05; _target hideobject true; sleep 0.1; _target hideobject false; sleep 0.02; _target hideobject true; sleep 0.03; _target hideobject false; sleep 0.01; _target hideobject true; deletevehicle _target; }; }]; }; }; but still not working. Share this post Link to post Share on other sites
sarogahtyp 1109 Posted May 22, 2019 what is _x in here?: {if (typeOf _x == "Land_VR_Target_Dart_01_F") then { _x addEventHandler ["HitPart",{ I don't see a definition of it or a loop which magic variable it is. Also check your .rpt file always ... Report File Location Share this post Link to post Share on other sites
Alert23 215 Posted May 22, 2019 rpt: Spoiler 11:02:42 soldier[B_soldier_AR_F]:Some of magazines weren't stored in soldier Vest or Uniform? 11:02:43 XEH: missionNamespace processed [false] 11:02:43 [49066,1756.41,0,"XEH: PreInit started. v3.11.2.190515"] 11:02:43 [CBA] (settings) INFO: Reading settings from settings file. 11:02:43 [CBA] (settings) INFO: Finished reading settings from settings file. 11:02:43 [49066,1756.47,0,"XEH: PreInit finished."] 11:02:43 [CBA] (settings) INFO: Checking mission settings file ... 11:02:43 Script 'cba_settings.sqf' not found 11:02:45 [CBA] (settings) INFO: Checking mission settings file ... 11:02:45 Script 'cba_settings.sqf' not found 11:02:45 Starting mission: 11:02:45 Mission file: shoot 11:02:45 Mission world: VR 11:02:45 Mission directory: C:\Users\xxmuc\Documents\Arma 3 - Other Profiles\Alert%20Fox\missions\shoot.VR\ 11:02:46 [49195,1759.99,0,"XEH: PreInit started. v3.11.2.190515"] 11:02:46 [CBA] (settings) INFO: Reading settings from settings file. 11:02:46 [CBA] (settings) INFO: Finished reading settings from settings file. 11:02:46 [49195,1760.08,0,"XEH: PreInit finished."] 11:02:46 soldier[B_soldier_AR_F]:Some of magazines weren't stored in soldier Vest or Uniform? 11:02:47 [49197,1760.33,0,"XEH: PostInit started. MISSIONINIT: missionName=shoot, missionVersion=53, worldName=VR, isMultiplayer=false, isServer=true, isDedicated=false, CBA_isHeadlessClient=false, hasInterface=true, didJIP=false"] 11:02:47 [49197,1760.33,0,"CBA_VERSIONING: cba=3.11.2.190515, "] 11:02:47 [49197,1760.33,0,"XEH: PostInit finished."] 11:02:47 Mission id: 932d8a04c5ca52b45904d1cd46603c7b575ac697 44 minutes ago, sarogahtyp said: what is _x in here?: {if (typeOf _x == "Land_VR_Target_Dart_01_F") then { _x addEventHandler ["HitPart",{ I don't see a definition of it or a loop which magic variable it is. Also check your .rpt file always ... Report File Location isent _x == "Land_VR_Target_Dart_01_F" defined? so like this: Land_VR_Target_Dart_01_F = _x _x addEventHandler ["HitPart",{ Share this post Link to post Share on other sites
sarogahtyp 1109 Posted May 22, 2019 this line: {if (typeOf _x == "Land_VR_Target_Dart_01_F") then checks if the classname of the OBJECT _x is Land_VR_Target_Dart_01_F and this line _x addEventHandler ["HitPart",{ applies an event handler to the OBJECT _x. But how knows your script which object is meant? _x has to be an existing object of your mission! EDIT: maybe your object(s) are simple objects then you could get it with this command: allSimpleObjects Example 1 there shows the usage. Also please check the syntax of each command which u try to use in the wiki. there are usage examples and it's always explained which parameters are needed and what the command does or returns. Especially in ur current script u r using wrong syntax for spawn. check it in the wiki! 1 Share this post Link to post Share on other sites