[Release][ESX] carlock

Does this work with addon and job vehicles?

As long as it is in your owned_vehicles table it’ll work (so it won’t work with job vehicles)

What do you mean ?

unfortunate, like 10 lock scripts but only 1 considers job vehicles

Well, you have to edit your esx_jobs resource

i own the car but seem to be getting this error in console and saying in game i dont own car.

EDIT - disregard, had to start it under es_extended and its working

What would I need to change in there to allow job vehicles to be locked?

You need to change your esx jobs resource

Is there a way to change the “lock” part to 4 so that you don’t break the window when you try to get into your own car?

Doesn’t work for some reason.

1 Like

Alright. I wasn’t clear. Everything is updated to the latest version and @mysql-async/lib/MySQL.lua is also there. I just don’t know why it doesn’t load.

The issue seems to be with your async, not the carlock script

Have you got the latest esx version ?

https://github.com/ji-a-kang/esx_vehiclelock_jiakang

I fixed esx_vehiclelock can’t lock emergency car, break a window!

thanks!

Can this be made to work so that police cars that are spawned in can be locked by the job police

2 Likes

Thank you for the great script sir.

For job vehicles:

ESX.RegisterServerCallback('carlock:isVehicleOwnerSociety', function(source, cb, plate)
	local xPlayer = ESX.GetPlayerFromId(source)
	local job = nil

	if xPlayer.job.name == 'legion' then
		job = 'legion'
	else
		job = 'unemployed'
	end

	MySQL.Async.fetchAll('SELECT owner FROM owned_vehicles WHERE owner = @owner AND plate = @plate', {
		['@owner'] = 'society:' .. job,
		['@plate'] = plate
	}, function(result)
		if result[1] then
			cb(result[1].owner == 'society:' .. job)
		else
			cb(false)
		end
	end)
end)

This works for every single job or just for one that you define there “legion”?

1 Like

Just add more if statements, for example:

if xPlayer.job.name == 'legion' then
		job = 'legion'
elseif xPlayer.job.name == 'paramedic'
		job = 'paramedic'
else
        job = 'unemployed'
end
1 Like