Exports and events
Server and client exports, events and before-hooks for other resources.
manniche_garage and can change before the release.Who may call
Server exports are limited by ServerConfig.ExportResources. An empty list lets every resource call. A call from manniche_garage itself always passes.
ServerConfig.ExportResources = { 'dealer', 'phone' }
A resource that is not on the list gets false, 'not_allowed', or an empty table from the list exports. Client exports have no allowlist.
Server exports
Call them as exports.manniche_garage:name(...). Failures return false, 'reason'.
| Export | What it does |
|---|---|
registerGarage(options) | Registers a garage that lives in memory only. Register it again on each start of your resource. Returns the public id '<resource>:<id>' |
updateGarage(id, changes) | Changes a garage your resource registered. Fields you leave out keep their value |
unregisterGarage(id) | Removes one of your garages. Parked vehicles stay in the database |
getAllGarages() | Array of { id, label, coords, radius, vehicleType, kind, job, minGrade, resource }, sorted by id |
storeVehicle(src, garageId) | Asks player src to park the vehicle they drive in the garage. Returns true when the request went out |
registerVehicleOutside(plate, netId) | Marks an owned vehicle that you spawned yourself as out and ties it to the entity. Reasons: invalid, no_vehicle, not_owned, bad_state, busy |
deleteOutsideVehicle(plate) | Removes the entity of an out vehicle and stores the vehicle again. Reasons: invalid, not_owned, bad_state, busy, failed |
getPlayerVehicles(src) | Array of { plate, model, vehicleType, state, garageId, garageLabel, nickname, blocked } |
getPrivateGarages(identifier) | Array of { id, garageId, label, role, storage, coords, interior } |
addPrivateMember(privateId, identifier, name?) | Adds a member. Reasons: not_allowed, invalid, not_found, members_full, already_member, busy |
removePrivateMember(privateId, identifier) | Removes a member. Refused with last_owner or member_has_vehicles |
openGarageFor(src, key, options) | Opens a temporary garage for one player, for a house or apartment script. The caller must be in ServerConfig.ExportResources and the player must stand near options.coords. Returns 'transient:<resource>:<key>' |
registerBeforeHook(name, handler) | Lets a resource refuse a change before it happens. See Before-hooks |
addHistory(plate, kind, data) | Writes a history entry for a plate. kind is owner, service, finance or note |
getHistory(plate, kind) | Returns up to 100 history entries for a plate, optionally for one kind |
setMileage(plate, km) | Sets the mileage in km. Returns true or false |
getMileage(plate) | Mileage in km, 0 if unknown |
getMileageByPlate(plate) | Same as getMileage |
getMileageByEntity(entity) | Mileage of a vehicle entity |
getUnit() | 'kilometers' or 'miles' (from ServerConfig.MileageUnit) |
ReloadInteriors() | Reloads interiors from the database |
InteriorTour(src, interiorId, returnTo) | Starts an interior tour for a player |
registerGarage options
| Option | Notes |
|---|---|
id | String, 1 to 40 characters: letters, digits, _ and - |
label | String, 1 to 80 characters |
coords | vector3/4 or { x, y, z, w? } |
radius | Default 3.0, from 0.5 to 50.0 |
spawns | 1 to 32 spawn points |
vehicleType | 'car', 'air' or 'sea'. Default 'car' |
job, minGrade | Makes it a job garage. minGrade default 0 |
returnToEntrance, openStore | Boolean, default false |
access | false, a table of identifiers, or a function(src) that returns true to allow |
blip | false or { sprite, colour, scale } |
interaction, ped | 'point' (default) or 'ped', with ped = { model, heading } |
marker | { draw, type, size, r, g, b, bob, rotate }. Default off |
local id = exports.manniche_garage:registerGarage({
id = 'harbour',
label = 'Harbour Garage',
coords = vec3(-1081.0, -1650.0, 4.5),
spawns = { vec4(-1075.0, -1655.0, 4.5, 120.0) },
})
Before-hooks
registerBeforeHook(name, handler) takes the names store, takeOut, transferGarage, transferPlayer and buy. The handler gets (src, data) and returns false, 'reason' to refuse. Anything else allows.
- It runs inside the locks of the call, so answer fast.
- There is one handler per resource and name. A new one replaces the old one.
- A handler that errors counts as allow, is logged as
hook_errorand prints a console line. - A resource that stops takes its handlers with it.
exports.manniche_garage:registerBeforeHook('takeOut', function(src, data)
if isBlocked(src) then return false, 'blocked' end
end)
Client exports
| Export | What it does |
|---|---|
openGarage(garageId) | Opens the garage menu. Returns false if the client does not know the garage. The server still checks distance, job and access |
storeVehicle(garageId) | Parks the vehicle the player drives. Returns false if there is no such garage or the player is not the driver |
showImpoundForm() | Opens the impound form, same as /iv |
showVplateForm() | Opens the plate dialog for /vplate |
showPrivateGaragesDashboard() | Opens the private garages list, same as /privategarages |
Events
Server events
Fired with (source, data) when a vehicle changes state. source is 0 when the server did it. They fire in addition to the functions in config/hooks.lua.
| Event | data |
|---|---|
manniche_garage:vehicleTakenOut | plate, garageId, netId |
manniche_garage:vehicleStored | plate, garageId |
manniche_garage:vehicleImpounded | plate, impoundId, recordId, auto |
manniche_garage:vehicleReleased | plate, impoundId or garageId, recordId, fee |
manniche_garage:vehicleTransferred | plate, kind, from, to, fee, price |
AddEventHandler('manniche_garage:vehicleTakenOut', function(src, data)
print(data.plate, data.garageId)
end)
Client events
| Event | Arguments | Use |
|---|---|---|
manniche_garage:vehicleKeys | vehicle, plate | Local event on take-out. Listen to give keys in your own keys script |
manniche_garage:vehicleKeysRemove | vehicle, plate | Local event after a vehicle was stored |
manniche_garage:interiorTour | privateId | Fired by the "Interior tour" button when ServerConfig.PrivateInteriorTour is true |
manniche_garage:notifyCustom | text, kind, title | Fired when Config.Notifications = 'custom' |
manniche_garage:textUiShow, manniche_garage:textUiHide | text, none | Fired when Config.TextUI = 'custom' |
AddEventHandler('manniche_garage:vehicleKeys', function(vehicle, plate)
exports.my_keys:giveKey(plate)
end)
manniche_garage:storeVehicle, manniche_garage:openTransient and manniche_garage:notify are sent by the server to its own clients. Do not trigger them yourself.