AKerOn
Member-
Content Count
2 -
Joined
-
Last visited
-
Medals
Community Reputation
10 GoodAbout AKerOn
-
Rank
Newbie
-
Hi, i am trying to make a script to start a dogfigth when i m in a plane. An enemy plane will be generated nearby the player, filled in with a RUS_PILOT, and will engage the player. I also wanted that the enemy could spawn in US plane like f35... but the problem is that when i am in the plane if the enemy plane i wanna spawn is a F35 , it will be green on the radar and i cannot lock it. How toavoid this problem? Plus i wanted this script to be compatible with multiplayer mission, so with what should i remplace the player variable i use?? Action called to start the dogfight if( vehicle player != player) then{ hint format ["je suis dans un %1", typeOf(vehicle player)]; if( (vehicle player) isKindOf "Air" ) then{ StartPos setPos (getPos player); TargetPos setPos (getPos player); [startPos,"Ka52Black"/*typeOf(vehicle player)*/,"RU_Soldier_Pilot", TargetPos, 150, 0, 1,"Combat",Dummy, 10] exec "CreateEnemyFighter.sqs"; } else { hint "T'as déja vu un avion avec cette gueulle toi??!" }; } else { hint "Montes dans un avion avant connard!" }; Script called to spawn the enemy ?!(local server):exit; _StartPos = _this select 0; _Airtyp= _this select 1; _Pilottyp = _this select 2; _Target = _this select 3; _Height = _this select 4; _Gunner = _this select 5; _skill = _this select 6; _behaviour = _this select 7; _Leader = _this select 8; _count = _this select 9; _counter = 0; #Start _counter = _counter +1; _Typ = createVehicle [_Airtyp,[(getPos _StartPos select 0)+ random 100,(getPos _StartPos select 1)+ random 100,_Height + random 50], [], 0, "FLY"]; _Typ FlyInHeight _Height; _Typ SetSpeedMode "full"; _Typ setDir getdir _StartPos; _pilot = _Pilottyp createUnit [[(getPos _StartPos select 0),(getPos _StartPos select 1), 2000], _Leader, "Pilot1=this"]; Pilot1 moveInDriver _Typ; Pilot1 setSkill _Skill; Pilot1 setBehaviour "_behaviour"; Pilot1 doTarget getPos _Target; //Pilot1 doMove getPos _Target; hint format["Enemy group %1\nplayer group %2", group Pilot1, group player]; ? _gunner == 0 : goto "Next" _gunner = _Pilottyp createUnit [[(getPos _StartPos select 0),(getPos _StartPos select 1), 2000], _Leader, "Gunner1=this"]; Gunner1 moveInGunner _Typ; Gunner1 setSkill _Skill; Gunner1 setBehaviour "_behaviour"; #Next ? _counter >= _count : exit; ~0.5 goto "Start" Thanks!!
-
generate sleep in eventhandler execution
AKerOn posted a topic in ARMA 2 & OA : BI TOOLS - TROUBLESHOOTING
Hi, i am creating a script which is used to spawn a group of unit on a previously created marker. My goal is to manage in the best way how units are deleted when they are killed to prevent useless treatment. The script is called with an action added to the player action list. A random number is used to choose the marker with a switch on it. Then units are created and event handler "killed" a added on each units. _rNumber=random 1; _index=round _rNumber; switch(_index) do { case 0 : { hint("OK GrpM"); _Leader = Grp1 createUnit ["RU_Soldier_Pilot", getMarkerPos "GrpM", [], 0, "FORM"]; _Unit2= Grp1 createUnit ["RU_Secretary1", getMarkerPos "GrpM", [], 0, "FORM"]; //_Unit3="RU_Secretary1" createUnit [getMarkerPos "GrpM", Grp1, "", 0.1, "Corporal"]; //_Unit4="RU_Secretary1" createUnit [getMarkerPos "GrpM", Grp1, "", 0.1, "Corporal"]; //_Unit5="RU_Secretary1" createUnit [getMarkerPos "GrpM", Grp1, "", 0.1, "Corporal"]; //_Unit6="RU_Secretary1" createUnit [getMarkerPos "GrpM", Grp1, "", 0.1, "Corporal"]; //_Unit7="RU_Secretary1" createUnit [getMarkerPos "GrpM", Grp1, "", 0.1, "Corporal"]; { _x addEventHandler ["killed" , { hint format["%1 a tué %2", (_this select 1), (_this select 0)]; sleep 20; (_this select 0) removeAllEventHandlers "killed"; deleteVehicle (_this select 0); } ]; } foreach units Grp1; }; case 1 : { hint("OK GrpM2"); _Leader = Grp1 createUnit ["RU_Soldier_Pilot", getMarkerPos "GrpM2", [], 0, "FORM"]; _Unit2= Grp1 createUnit ["RU_Secretary1", getMarkerPos "GrpM2", [], 0, "FORM"]; //_Unit3="RU_Secretary1" createUnit [getMarkerPos "GrpM2", Grp1, "", 0.1, "Corporal"]; //_Unit4="RU_Secretary1" createUnit [getMarkerPos "GrpM2", Grp1, "", 0.1, "Corporal"]; //_Unit5="RU_Secretary1" createUnit [getMarkerPos "GrpM2", Grp1, "", 0.1, "Corporal"]; //_Unit6="RU_Secretary1" createUnit [getMarkerPos "GrpM2", Grp1, "", 0.1, "Corporal"]; //_Unit7="RU_Secretary1" createUnit [getMarkerPos "GrpM2", Grp1, "", 0.1, "Corporal"]; { _x addEventHandler ["killed" , { hint format["%1 a tué %2", (_this select 1), (_this select 0)]; sleep 20; (_this select 0) removeAllEventHandlers "killed"; deleteVehicle (_this select 0); } ]; } foreach units Grp1; }; }; It seems that the sleep called in the eventhandler "killed" is not executed, the insctruction seems to be passed as the unit is deleted directly after i killed it. I didn't find anything about eventhandler context which is not interruptible, but it seem's to be the problem for me. Can somebody tell me if i am wrong or if this is not the good way to delete units. Thanks