Jump to content
Sign in to follow this  
DArmstrong

Can I restrict a vehicle to the AI driver?

Recommended Posts

Greetings editing gurus, thanks in advance for your help.

I have put a vehicle in my mission that is driven by an AI. When live players get in the vehicle to be taken to the next objective, they are given the choice in their actions to "move to driver". Since in this mission it is important that the AI drive, how can I restrict the live players to only be inCargo and not be able to take over driving from the AI? Thanks.

Share this post


Link to post
Share on other sites

Try this: put the following code in the init field of the vehicle

this addEventHandler ["GetIn", {_this select 0 lock true; num = _this select 0 addAction ["Get Out","getout.sqf"]}]; 
this addEventHandler ["GetOut", {_this select 0 lock false; _this select 0 removeAction num}]; 

then write a 'getout.sqf' file with the following code and put it (the file) on the mission folder:

//getout.sqf
player action ["eject", vehicle player];

This code lock the vehicle when the human player GetIn the vehicle and add the Get Out action (otherwise the player can't disembark from the vehicle!); when the player disembark the vehicle became unlocked ;)

It works for me :)

Edited by goliath86

Share this post


Link to post
Share on other sites

Thank you both very much. Both methods should work for this mission. The live players get on a bus to the next town and then get off there. I don't want the live players to be able to take over driving the bus. It is not in the mission to drive the bus, but I have found out that if you leave stuff like this open to the players it can wreck your mission. Thanks again.

Share this post


Link to post
Share on other sites

Thanks again for helping me out.

I tested both methods with mixed results.

I took what seemed like the easy way first.

vehicleName lockDriver true;

placed in the init field of the bus seems to do nothing. I got no errors and when the live players entered the bus we could still either enter as driver or switch to driver once on board.

I searched the command and found another post at DevHeaven that they had found this command didn't work either. It is listed on several sites command refs including the bis wiki. ? I don;t think I missed anything, it is a simple matter to put bus1 lockDriver true in the init of a vehicle.

I also tried bus1 lockDriver lock, and bus1 lockDriver false just for fun and nothing seemed to happen. Driver position was still available.

The sqf code from goliath86 worked. Now, I have an issue with this method because of the way it works with multiple players trying to get on the bus. In my misson there are two live players and a few AI that try to board the bus at a bus stop, and once the first one gets in, the bus becomes locked immediately. (As it should per this code) and the second player, or any other players including AI players can not get in.

Im going to play with making a script that runs after all players have entered.

I think you have pointed me in the right direction. Thanks again.

Share this post


Link to post
Share on other sites

I wish I could test this before posting, but ...

Normally when playing I only have the option to move to an already-occupied position if that position is held by an AI in my command. So, is it possible for the (AI) driver of the vehicle to be not under the command of the players? I could be completely off track here, so apologies if I'm making things up.

Share this post


Link to post
Share on other sites
I wish I could test this before posting, but ...

Normally when playing I only have the option to move to an already-occupied position if that position is held by an AI in my command. So, is it possible for the (AI) driver of the vehicle to be not under the command of the players? I could be completely off track here, so apologies if I'm making things up.

Thank you for helping me with this. The bus driver is not in the players group. He is just following his way points. The players are assignedAsCargo at their getin waypoint but this doesn't make them part of the same group. The driver doesn't come under your command. This is not a real show stopper for the mission, most players will follow their insturctions and just ride to the jump off point. I just wanted to eliminate the possibility of a live player taking over and perhaps missing something along the route. I am testing out a few things and will post here anything useful I may find. Thanks again.

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  

×