Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×
Sign in to follow this  
Matosh

vehicle restriction

Recommended Posts

Im not sure, how can i add more isKindOf vehicle types (air or helicopter or plane,car or landvehicle) for single unit with multiple seats (driver,gunner,commander) so when i have in game a player who is restricted to enter multiple vehicle types, executed by single script then having to execute multiple ones with different v types and seats. Also im not sure how can i add multiple units for single vehicle type but multiple seats.

[] spawn {
while {(typeOf player == "US_Soldier_Officer_EP1")} do {
	waitUntil {vehicle player isKindOf "tank"};
	_Tank = (vehicle player);
	waitUntil {(player == gunner _Tank) || !(player in _Tank)};
	if (player == gunner _Tank) then {
		player action ["eject",vehicle player];
	};
};
}:

Edited by matosinec

Share this post


Link to post
Share on other sites

for the vehicle list you can employ an array of vehicles....

_vehlist = ["HMMWV_M998_crows_M2_DES_EP1","HMMWV_Ambulance","CH_47F_EP1","CH_47F_BAF","UH60M_MEV_EP1","BAF_Merlin_HC3_D"];

[] spawn {
  {
while {(typeOf player == "US_Soldier_Officer_EP1")} do
             {
	waitUntil {vehicle player isKindOf _x};
	_Tank = (vehicle player);
	waitUntil {(player == _Tank) || !(player in _Tank)};
	if (player == crew _Tank) then   // or if (player in (crew _tank)) then
                     {
		player action ["eject",vehicle player];
              };
      };
   } foreach _vehlist;
}:

NOT tested...

as for all positions - havent tried it but something along the lines of may work

	if (player == crew _Tank) then   // or if (player in (crew _tank)) then 

Share this post


Link to post
Share on other sites

I tested it, and i couldnt get it to work.

Share this post


Link to post
Share on other sites

try this first... make sure this part is working then mess with the position of the vehicle.

_vehlist = ["HMMWV_M998_crows_M2_DES_EP1","HMMWV_Ambulance","CH_47F_EP1","CH_47F_BAF","UH60M_MEV_EP1","BAF_Merlin_HC3_D"];

[] spawn {
while {(typeOf player == "US_Soldier_Officer_EP1")} do {
       {      
               _Tank = vehicle player;
	waitUntil {_Tank isKindOf _x};
	waitUntil {(player == gunner _Tank) || !(player in _Tank)};
	if (player == gunner _Tank) then {
		player action ["eject",_Tank];
	         };
           } foreach _vehlist;
};
}:

again not tested

Share this post


Link to post
Share on other sites

Still not working, maybe im doing something wrong. Where is suppose to be _vehlist ?

Share this post


Link to post
Share on other sites

sorry been on hols - havent had chance to do this til now. - not sure how cpu expensive this is though. tested and working!

[] spawn {
_vehlist = ["HMMWV_M998_crows_M2_DES_EP1","HMMWV_Ambulance","C H_47F_EP1","CH_47F_BAF","UH60M_MEV_EP1","BAF_Merli n_HC3_D"];

while {true} do 		
{ 	
      waituntil {count playableUnits >= 1};
_vehchoice = vehicle player;
	{	
waitUntil {(gunner _vehchoice == player)};
//	   if (gunner _vehchoice == player) then 
//			  {
	 	if (_vehchoice iskindof _x) then          
	 		{									 
                           if (typeOf player == "US_Soldier_Officer_EP1") then
					{ 						
						player action ["eject", _vehchoice];
						sleep 0.5;
						waituntil {vehicle player == player};	
						hint format ["you cannot access the gun of %1 vehicles", _x];
					};
			};
//			   };
	} foreach _vehlist;
		sleep 0.5;
  }; //while	
};//spawn

should look at using getin eventhandlers to access the script rather than the while loop. havent had chance to test it myself yet.

Share this post


Link to post
Share on other sites

No problem, but again cant get it to work, i got 3 files in mission folder (just for testing),mission.sqm, init.sqf and this script, in init.sqf i got execVM "officerestriction.sqf";.

Share this post


Link to post
Share on other sites

I copied your file into missions folder and previewed it, still nothing, .rpt is clean,ive got correct vehicle and soldier type, im getting no script errors.

Edited by matosinec

Share this post


Link to post
Share on other sites

have you tried the gunner position on the crows? its the position that will boot you out.

make sure you have no mods running and no beta either (although tested with that and does work);

have you copied the file across and tested that directly - no editing? not sure what else i can say - the one you have now run - send a link so i can test that.

anyone else reading this - can this test the above link and see if it works? cheers

Share this post


Link to post
Share on other sites

If your testing in single player I'm not sure waituntil {count playableUnits >= 1}; will work. If I remove it from the script it does work.

Also watch for spaces in the _vehlist for some reason when copying and pasting it inserts them from time to time and they're also present in the DL script.

Share this post


Link to post
Share on other sites

I was testing it in editor, it works fine now. Last thing: how to add more then one seat (driver or commander or both)?

Edited by matosinec

Share this post


Link to post
Share on other sites

remove line - waitUntil {(gunner _vehchoice == player)};

add in its place..

[color="#FF0000"]if (commander _vehchoice == player) then 
		  { [/color] 

if (_vehchoice iskindof _x) then          
	 		{									 
                           if (typeOf player == "US_Soldier_Officer_EP1") then
					{ 

						player action ["ENGINEOFF", _vehchoice];
						player action ["eject", _vehchoice];
						sleep 0.5;
						_vehchoice engineOn false;
						waituntil {vehicle player == player};	
						hint format ["you cannot access the gun of %1 vehicles", _x];
					};
			};

                         [color="#FF0000"] };[/color]


Share this post


Link to post
Share on other sites

I do not know whether you understand me, but i meant like this "if (driver + gunner _vehchoice == player) then" i know that this is not correct. So if you enter as driver or gunner you get kicked out of the vehicle.

Share this post


Link to post
Share on other sites

you can try...

if ((commander _vehchoice == player) or (driver_vehchoice == player) or (gunner_vehchoice == player))then

remove the one you dont want - remember, the more checks you need to do the longer it takes for the script to run.

so you could choose the one you do want and try...(not tested) instead

if (!commander _vehchoice == player) 

Share this post


Link to post
Share on other sites

Will it be ok if I add another or more typeof player ?

//	   if ((!driver _vehchoice == player) or (!gunner _vehchoice == player)) then 
//			  {
	 	if (_vehchoice iskindof _x) then          
	 		{									 
                           if (typeOf player == "US_Soldier_Officer_EP1") then
					{ 

						player action ["ENGINEOFF", _vehchoice];
						player action ["eject", _vehchoice];
						sleep 0.5;
						_vehchoice engineOn false;
						waituntil {vehicle player == player};	
						hint format ["You are not allowed to enter %1", _x];
					};
                            [color="#FF0000"]if (typeOf player == "US_Soldier_EP1") then
					{ 

						player action ["ENGINEOFF", _vehchoice];
						player action ["eject", _vehchoice];
						sleep 0.5;
						_vehchoice engineOn false;
						waituntil {vehicle player == player};	
						hint format ["You are not allowed to enter %1", _x];
					};[/color]
			};

Edited by matosinec

Share this post


Link to post
Share on other sites

you can try - not tested so you will have to mess around with it.

_soldier = ["US_Soldier_EP1","US_Soldier_Officer_EP1"];


if (typeof player in _soldier) then...

or

if ((typeOf player == "US_Soldier_Officer_EP1") or (typeOf player == "US_Soldier_EP1")) then

Share this post


Link to post
Share on other sites

It works, but I do not know why when you enter a vehicle as passenger you get kicked out, but in script is set to driver or gunner?

Share this post


Link to post
Share on other sites

post your script -

i think if you have used.. !driver vehicle = player - which will then mean your script carries on and thus kicks out the player.

ill have to check

Share this post


Link to post
Share on other sites
[] spawn {
_vehlist = ["AAV","LAV25"];
_soldier = ["US_Soldier_EP1","US_Soldier_Officer_EP1"];

while {true} do 		
{ 	
   waituntil {count playableUnits >= 1};
_vehchoice = vehicle player;
	{	
//	   if ((!driver _vehchoice == player) or (!gunner _vehchoice == player)) then 
//			  {
	 	if (_vehchoice iskindof _x) then          
	 		{									 
                           if (typeof player in _soldier) then
					{ 

						player action ["ENGINEOFF", _vehchoice];
						player action ["eject", _vehchoice];
						sleep 0.5;
						_vehchoice engineOn false;
						waituntil {vehicle player == player};	
						hint format ["You are not allowed to enter %1", _x];
					};
			};
//			   };
	} foreach _vehlist;
		sleep 0.5;
  }; //while	
};//spawn

Share this post


Link to post
Share on other sites

Maybe you can do something like this instead.... I re-arranged a few things!

[] spawn {
_vehlist = ["AAV","LAV25"];
_soldier = ["US_Soldier_EP1","US_Soldier_Officer_EP1"];

while {true} do { 	
waituntil {count playableUnits >= 1};
waituntil {vehicle player != player};
_vehchoice = typeof vehicle player;
if (_vehchoice in _vehlist and typeof player in _soldier) then {
	player action ["ENGINEOFF", _vehchoice];
	player action ["eject", _vehchoice];
	sleep 0.5;
	_vehchoice engineOn false;
	hint format ["You are not allowed to enter %1", _x];
};
       sleep 1;
};

Edited by twirly

Share this post


Link to post
Share on other sites

Isnt this gonna kick you out from all vehicle seats?

Share this post


Link to post
Share on other sites

looking at the sript you are using matosinec - you have no command over positioning - you have commented out "//" the necessary lines which means yours will kick anyone of the vehicle matching the correct soldier type.

try removing the !driver and replace just with driver, and uncomment the lines

Share this post


Link to post
Share on other sites

When i uncomment those lines script doesnt work anymore.

Share this post


Link to post
Share on other sites
Sign in to follow this  

×