# Functions

## **Client**

### **Vehicke Keys Menu**

```lua
--  all player vehicles
Vehicles.VehickeKeysMenu()

--  Specific plate, 
Vehicles.VehickeKeysMenu('MONO 420', function()
  print('On Close menu or Set/remove key player')
end)
```

### **Item Car Keys Client**

* action = 'delete' or 'add' | string
* plate = vehicle plate | string

```lua
  Vehicles.ItemCarKeysClient(action, plate)
```

## **Server**

### **Give Item Key**&#x20;

* source = player source | number
* action = 'delete' or 'add' | string
* plate = vehicle plate | string

```lua
  Vehicles.ItemCarKeys(source, action, plate)
  -- or ox_inventory export 
  -- add
  exports.ox_inventory:AddItem(source, 'carkey', 1, { plate = plate })
  --remove 
  -- via ox_inventory export 
  exports.ox_inventory:RemoveItem(source, 'carkey', 1, { plate = plate })
```

### **Create Vehicle**&#x20;

```lua
Vehicles.CreateVehicle(VehicleData, CallBack)

local CreateVehicleData = {
    -- if vehicle temporary | date format 'YYYYMMDD HH:MM'     example '20240422 03:00'   - or false
    temporary = ?, 
     -- string or false, nil ...
    job = ?,
    -- Set vehicle Owner? if Temporary date set true
    setOwner = ?,  
    -- player identifier
    owner = ?,    
    -- same to owner  
    identifier = ?, 

    coords = vector4(1.0, 1.0, 1.0, 1.0),  -- Coords spawn table or vector 4

    -- Vehicle Data
    -- can set your custom props here or use lib.GetVehicleProps() table...
    vehicle = {                            
        model = 'sulta',                  
        plate = Vehicles.GeneratePlate(), 
        fuelLevel = 100,                  
        color1 = [0,0,0],
        color2 = [0,0,0],               
        
    },


Vehicles.CreateVehicle(CreateVehicleData, function(data, action)
   print(json.encode(data, { indent = true} ))
end)
}
```

### **Get Vehicle**

```lua
local Vehicle = Vehicles.GetVehicle(entity) 

Vehicle.SetMetadata(key, value)
-- Example
-- Vehicle.SetMetadata('stolen', { stolenBy = 'Mono Garage'})

Vehicle.DeleteMetadata(key) 
-- Example
-- Vehicle.DeleteMetadata('stolen')

Vehicle.GetMetadata(key)     
-- Example
-- by key Vehicle.GetMetadata('stolen')  or  Vehicles.GetMetadata() return all
-- local metadata = Vehicle.GetMetadata('stolen')
-- print(metadata.stolenBy)   
--- or client/server State 
-- local metadata = Entity(data.entity).state.metadata
-- print(metadata.stolenBy)  

Vehicle.AddKey(source) 
Vehicle.RemoveKey(source)
Vehicle.SaveProps(props)

-- To use in garage script
Vehicle.StoreVehicle(parking, props, license)
Vehicle.RetryVehicle(coords)
Vehicle.ImpoundVehicle(parking, price, note, date)
Vehicle.RetryImpound(ToGarage, coords)

-- Set Fake Plate to vehicle
Vehicle.SetFakePlate('FAKETAXI')
-- To remove 
Vehicle.SetFakePlate(false)

-- Delete DataBase vehicle
Vehicle.DeleteVehicleDB()
```

### **Get Vehicle By Plate**

* retunr Vehicles.GetVehicle()

```lua
 local Vehicles.GetVehicleByPlate(plate)
```

### **Get Vehicle Id**

* retunrvehicle from database

```lua
local vehicle = Vehicles.GetVehicleId(id) 
```

### **Get Vehicles from Identifier**

```lua
local AllVechiles = Vehicles.GetAllVehicles(identifier)
```

### **Set Vehicle Owner** *Server*

```lua
Vehicles.SetVehicleOwner({
    job = ?,
    owner = ?,
    parking = ?,
    plate = ?,
    type = ?,
    vehicle = ?,
})
```

### **Set CarOwner** *Server*

```lua
Vehicles.SetCarOwner(src)
```

### **Vehicles.DelAllVehicles()** *Server*

```lua
Vehicles.DelAllVehicles() 
```

### **Vehicles.SaveAllVehicles()** *Server*&#x20;

* true/false to delete vehicles

```lua
Vehicles.SaveAllVehicles(delete)
```

### **Vehicles.PlateExist()** *Server*&#x20;

* return boolean

```lua
Vehicles.PlateExist(plate) 
```

### **## Vehicles.GeneratePlate()** *Server*&#x20;

* &#x20;return plate string

```lua
Vehicles.GeneratePlate()
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mono-scripts.gitbook.io/mono-docs/mono-documents/mvehicle/functions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
