OPX//77
CreatorsServer exports

AddVehicle

Last updated on

Gives a character a vehicle: a row in the garage, owned by them.

local res = exports.opx_infinity:AddVehicle(target, record, options)

Scope write · must be awaited.

Parameters

  • target: number | string — a loaded player id, or a citizen id

  • record: string — a TweakDB vehicle record, Vehicle.v_sport2_quadra_type66

  • options?: table

    • garage?: string — where it is stored; default the vehicles module's DEFAULT_GARAGE
  • Through the vehicles module: a fresh plate, PER_CHARACTER holds (vehicle.limit), and opx:on:vehicles:registered is raised.

  • No key is cut: add GiveKeys.

Returns

Errors

  • vehicle.limit, vehicle.registering, vehicle.badRecord, export.badArgument, export.callerDenied
Example
CreateThread(function()
  local pending, why = Open77.exports.call('opx_infinity', 'AddVehicle', playerId, 'Vehicle.v_sport2_quadra_type66', { garage = 'city' })
  if not pending then return print('not sent: ' .. tostring(why)) end
  local res = pending:await()
  if not (res and res.ok) then return print('refused: ' .. tostring(res and res.error)) end
  print('new plate ' .. res.value.plate)
end)

On this page

No Headings