Welcome to nanos GbR

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more!

This message will be removed once you have signed in.

Sign in to follow this  
Jones

Vehicle Locking / Disabling Hijacking

2 posts in this topic

Any suggestions on vehicle locking and disabling hijacking will be much appreciated.

The game mode I am creating revolves around player classes that balance mobility with firepower.  The higher firepower classes will be more dependent on a vehicle and the more mobile classes will have variations of parachute, grapple, wing suit and boost. The problem is I do not want the more mobile classes to be able to hijack vehicles from the lower mobility classes as this would become very unbalanced.

I am currently binding the player.networkId to the vehicle as vehicle.ownerId on vehicle creation so that I can check ownership. However there still remains the question as what to do with the player when they do NOT belong in the vehicle or seat.  I could just check to see if the player owns the vehicle on the enter vehicle event and move them out of the vehicle, but I did not see anything in the API docs that out kick a player from a vehicle.  Does a method exist for this? If not, what are some potential workarounds?

I have tried a couple dirty tricks like  moving the hijacker to seat 1 but ran into a problem with this when the player gets into seat 1 directly. This resulted in being stuck in the passenger seat. I also tried setting the hijacker to an out of bounds index but that resulted in the hijacker sitting on top of the vehicle with the ability to turn the wheels. I did not test this with two players, only one.

What is the behavior of vehicle.SetOccupant when another player is already in the seat? I do not have another test subject available to test this. If it kicks the existing player out then I suppose the easiest way to prevent hijacking would something along the lines of,

jcmp.events.Add('PlayerHijackVehicle', (driver, vehicle, hijacker) => {
    Vehicle.SetOccupant(0, driver);
});

 

Here are some things that would be helpful that I couldn't find turnkey solutions for in the API docs.  If anyone has some work around for these it would be appreciated if you shared them.

Get the number of functional seats in a vehicle. 

Kick a player from a vehicle.

Disable option to enter if the are no open seats.

Share this post


Link to post
Share on other sites

No built in methods exist currently, but they are coming.

As for seats, you can find them here.

To kick a player, set the occupant of that seat to null. Setting the occupant to null when someone tries to enter can effectively block someone from entering a vehicle. Try it out.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.