Jump to content
Sign in to follow this  
dragonsyr

I need help for syntax a script

Recommended Posts

i need help to make this C++ please

if is kind of air and has engine on and the distance between player from the unit1 is higher than 5 meters, then unit1 playMove "something" and if lower than 5 meters unit1 playMove "something_2" and/or if the player switch engines off, then unit1 playMove "something_3" and/or if player land more than 1 meter distance from unit1 then unit1 playMove "something_4"

same for kind of vehicle (no players) with stop , not landing offcourse.. :-)

i think that is easy for you :-)

thanks

Share this post


Link to post
Share on other sites

Edited:

if (isServer) exitWith {};

_aircraft = unit1;
_vehPlayer = vehicle player;
_heightPlayer = (getPosATL player) select 2;
_heightUnit = (getPosATL _aircraft) select 2;
_heightDiff = _heightUnit - _heightPlayer;

//--- conditions for player and unit1
if (_aircraft isKindOf 'air' && isEngineOn _vehPlayer) then {
   if (_heightDiff > 5) then {
       // if unit1 is an aircraft, player has engine on and their height differs move than 5m
       _aircraft playMove 'moveName';
   };
   if (_heightDiff < 5) then {
       // if unit1 is an aircraft, player has engine on and their height differs less than 5m
       _aircraft playMove 'moveName2';
   };
};

//--- EH for checking engine state
player addEventHandler ['engine', {
   _engState = _this select 1;

   //--- engine off ---> moveName3
   if (_engState == false) {
       _aircraft PlayMoveNow 'moveName3';

       sleep 1;
   }
}];

//--- landing > 1m away from unit1 ---> moveName4
if (_heightPlayer < 1 && (_vehPlayer distance _aircraft) > 1) then {
   _aircraft PlayMove 'moveName4';
}

I have tried to implement your logic as good as possible.

Since I am not sure what the scenario is, I wasn't able to make the script consistent with the gameplay. So you have to make sure it all runs when needed.

I haven't tested it myself and it is most likely not functioning, but I figured I could at least contribute :).

Edited by byrkoet

Share this post


Link to post
Share on other sites

thank you byrkoet.. test in a few hours and i post the results .......

Share this post


Link to post
Share on other sites

Ok.... i v made many tests with your code for how this working. No luck....

lets clear what i m trying to do,

i have a helipad named "pad" and one AI about 30 meters away, in a building.(the name of the AI is "helper").

one trigger 50X50 or 100X100 , init s = [] execVM "signal.sqf";

now , i want the trigger active only if the player is pilot and the speed is lower than a value, then the "helper" walk from his spot about 10 meters radius from the helipad , facing the player and playMove 'Acts_NavigatingChopper_Loop'. (note that during this, the helper must always facing the player (edit:i found this that works _helper dowatch vehicle player; ))

next , when the player position is in the middle of the helipad i want the helper playMove 'Acts_NavigatingChopper_Out'

next if player land the heli inside the helipad , then helper PlayMove 'AmovPercMstpSrasWrflDnon_Salute'

and when the player get out , then helper return to initial position (30 meters away, in the building)

if the player leaves the trigger without land then the helper playmove "Acts_AidlPercMstpSlowWrflDnon_pissing" and then return to initial position

maybe an addaction to the pilot for smoke spawn in the middle of the helipad(or if the helper can throw smoke with a command, or what about the helper uses light sources attached in hands when 'Acts_NavigatingChopper_Loop' in case of night (i dont know if this possible)) as more help for landings.

if this works, the result is an active air marshal.

Edited by dragonsyr

Share this post


Link to post
Share on other sites

It can be done a lot easier with the mission editor tools:

- Use triggers to make sure a certain playMove animation is executed.

- You can spawn the smokes with the same trigger using createVehicle - I believe.

PS I just noticed I used an Else-If-statement, but I believe those aren't supported. I have edited the opening post just in case you need a reference.

Share this post


Link to post
Share on other sites

no luck for every test i made...... i think this is not so easy after all......

and from the editor with triggers only it is not possible.

Edited by dragonsyr

Share this post


Link to post
Share on other sites

After many hours of reading and with your code as a reference, here is what i v made

_target = pad;
_marshal = helper;
_vehPlayer = vehicle player;
_heightPlayer = (getPosATL player) select 2;
_heightTarget = (getPosATL _target) select 2;
_heightDiff = _heightTarget - _heightPlayer;
_vehlist = ["B_Heli_Light_01_F","B_Heli_Light_01_armed_F","B_Heli_Attack_01_F","B_Heli_Transport_01_camo_F"];
_smokeType =  "SmokeShellPurple";  //smoke shell color you want to use
_minheight = 55;  // the height you have to be before you can actually see the helper
_HQ = [West,"HQ"];
_toHigh = format
   	[
   	"<t align='center'><t size='2.2' color='#ed3b00'>TO HIGH</t><br/><t size='1.2' color='#9ef680'>You need to be bellow</t><br/><t size='1.5' color='#ed3b00'>%1 meters</t><br/><t size='1.2' color='#9ef680'>in order to use Marshal.</t></t>",
   		_minheight
   	];  //text to display when not low enough to land
hint "init complete"; //debuging
if (!isServer && isNull player) then {isJIP=true;} else {isJIP=false;};
       // Wait until player is initialized
if (!isDedicated) then
{
	waitUntil {!isNull player && isPlayer player};
	waituntil {vehicle Player  != Player};
};

_vehRole = assignedVehicleRole player select 0; // working now
//--- conditions for player and helper

if ((getPos player) select 2 > _minheight) exitWith {hint parseText _toHigh}; // i need a loop for height check .as it is, the player must leave the trigger and enter again <50 meters
//if ( another landing in progress) ) exitWith {hint "Marshal is not currently available. Wait your turn."}; // i need to figure out how  this will work
if ((getPos player) select 2 < _minheight) then {
 if (typeof _vehplayer in _vehlist && (_vehRole == "driver")) then {
   if (_vehplayer distance _target > 5) then {
	_marshal dowatch _vehplayer;
       _marshal playmoveNow 'Acts_NavigatingChopper_Loop';
	hint "Move closer , slow speed"; //debuging
	sleep 3;
	_smoke = _smokeType createVehicle [getPos _target select 0, getPos _target select 1,5];
	_HQ sideChat " A Smoke has been dropped at landing site.";
	waituntil {((_vehplayer distance _target) < 5);};
       _marshal playMove 'Acts_NavigatingChopper_Out';
	hint "You can land now"; //debuging

	};
} else { hint "no conditions meet";}; //debuging

};

this is the first step of that i need . its not finished because a have some problems as you can see

first i need one loop for the detection of _minheight = 55; ..... many tests with while {true} do , waituntil commands with no luck. as it is line 28, when you are to high then you need to get out of the trigger area and trigger again bellow the minheight value......

second part i want if the pilot land the heli out of the pad , then helper playmove "....." (the command for land ???)

and if engine off then the helper do something else.

and if get out or eject, i need the script stops . but if the player get in again as driver and is in the trigger ,then the script run again

also... it is possible to lock the _target when i m on landing prossedure, so no other player pilot can use the pad same time??

Edited by dragonsyr

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×