MONO_CARKEYS Item ( LockPick - HotWire - Plate Change ) [17/10/2023]

mono_carkeyss

Hello community!

This is the first script I’m sharing on the forum. I’m not an expert in programming, I do it as a hobby. If you find any errors or see something strange in the code, let me know.

The script is basically a key system for vehicles that works with the key as an item using metadata.

Features

  • Turn on and off the vehicle engine using the corresponding assigned key to the vehicle (optional, Keys.Engine).

  • You can hold down the F key when exiting the vehicle to keep the engine running, if you have the vehicle keys. (Optional, Keys.OnExitCar)

  • Retrieve lost keys through an NPC that can be easily added in the Config.lua file.(In the config.lua file, you can edit the NPC to acquire the license plate. Keep in mind that if you set BuyNewPlate to true, the NPC will only sell license plates and not keys)

  • Administrators can create keys for the vehicle they are in, as well as for other players using their ID.

  • NPC-owned vehicles will be parked with their doors closed, and will be turned off if opened (This option is disabled by default since it is not 100% finished. It will block all kinds of vehicles, including those with NPCs inside. In the future, only vehicles without NPCs will be affected. Keys.CloseDoorsNPC).

  • Lockpicking system with skill check, allowing players to force entry into vehicles (includes a function in the Config.lua file to optionally add a dispatch system).

  • Includes a tool called “Wire Cutters” with skill check, allowing players to hotwire previously forced vehicles (optional).

  • The license plate item allows the player to customize both the color and the license plate of their vehicle. (This will change the license plate in the database)

  • Keybind to open/close the vehicle. (Default key is U, can be changed in the Config.lua file.)

  • Keybind to turn on/off the engine. (Default key is M, can be changed in the Config.lua file. Optional)

  • (New 17/5/2023) Now there is an attempt per vehicle to search for the key when you get into the vehicle. Button/command/export. (Configurable in Keys.FindKeys)

Commands Admins

  • /givekey [ID] - With this command, you can obtain a key for the vehicle you are currently in, or you can use the ID of a player who is in a vehicle to give them a key to that vehicle.
  • /delkey [ID] - With this command, you can delete the key for the vehicle you are currently in.
Config.lua

Ox Inventory Item

['carkeys'] = {
	label = 'Car Key',
	weight = 5,
	stack = true
},

['ganzua'] = {
	label = 'Lockpick',
	weight = 25,
	stack = true,
	client = {
		export = 'sy_carkeys.LockPick'
	}
},

['alicates'] = {
	label = 'Wire Cutters',
	weight = 50,
	stack = true,
	client = {
		export = 'sy_carkeys.HotWire'
	}
},
['plate'] = {
	label = 'Plate',
	weight = 500,
	stack = true,
},


carkey.png
carkeys

alicates.png
alicates

ganzua.png
ganzua

Documents

Preview

Download

Dependencies

15 Likes

nice job, thanks for sharing :heart_eyes:

1 Like

Thanks mate! :blush:

1 Like

chat do you have this script?

Best car key script! Good job!

1 Like

I don’t understand what you mean

is every npc car locked at start?

does this lock local cars from being robbed

You can use this event on the server side, this will cause all NPC vehicles to be locked with a 20% chance of finding one open.

AddEventHandler('entityCreated', function(entity)
    if not DoesEntityExist(entity) then
        return
    end
    local entityType = GetEntityType(entity)
    if entityType ~= 2 then
        return
    end
    if GetEntityPopulationType(entity) > 5 then
        return
    end
    if math.random() > 0.8 then
        return
    end
    SetVehicleDoorsLocked(entity, 2)
end)

I added this option in the last update

Hello, we have nothing to put on the client & server side of our VehiculeShop?

1 Like

Yes of course, read the ReadMe.

You can use

TriggerServerEvent(‘sy_carkeys:KeyOnBuy’, plate, model)

(the model is the name of the vehicle example, karin sultan ( sultan = model )

I added an option to be able to close the NPC vehicles when they spawn.

Okay, does this script saving vehicle lock when someone want to take it from garage?

No, when you take the vehicle out of the garage it will always be open.

can we fix it?

You would see save the state of the vehicle doors in your database when you deposit the vehicle. Or when you retire the vehicle from the garage that leaves with the doors closed.

Hey, good script ! But can you make it without ox pls

1 Like

You can do it… Or say for the Framework and as soon as I have time I’ll see if I can.

1 Like

I have an error. Is there a fix? Streamable

You have to use the U key when you have the car-key.

I’m working on a new update to add more features.