Jump to content

[HELP] vehicle.lock Client-side


Recommended Posts


Any way to get if a vehicle is locked on client-side, please?

I trying using this resource:

But it have an error.

It's using: vehicle.lock to check but it's a server-side function and it isn't working.
So i'm trying fix this, but with no success.
I tried use:

const player = mp.players.local;
const Vehicle = mp.vehicles.atHandle(idVehicle);

And try get the locked status of the vehicle, all with no success:

var test1 = Vehicle.getDoorLockStatus();
var test2 = Vehicle.getDoorsLockedForPlayer(player);
var test3 = Vehicle.isAlarmActivated();

All i got is undefined or null variables.

Finally i try using callRemote event, but without success too:
- client-side:

var test = mp.events.callRemote("checkVehLocked", Vehicle);

- server-side:

	"checkVehLocked" : (player, vehicle) => {
		console.log(`Player: ${player.name} checked the vehicle: ${vehicle.locked}`);
		return vehicle.locked;

The log is detecting the status correctly but the var test on client-side isn't getting the right value.
And maybe a problem the checkVehLocked event is firing constantly on the server while player is near some vehicle. It don't looks like a good idea, or im wrong?

I've to fix those lines on the resource:

if(this.config.LockHandbrakeProtection === true && Vehicle.locked === true)
            return false;

Because it isn't detecting the second condition: (Vehicle.locked === true)

Any tip how fix it, please?

Thank you!!!

Edited by joew
Link to comment
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
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...