Skip to content

Exports, hooks and events ​

These are server exports. Call from trusted server resources; perform caller-specific authorization before granting free tickets, refunds or privileged actions. Transport money values are integer cents.

Export Purpose
Request(src, params) Create a passenger ride request
quote(params) Fare range for pickup/dropoff/class
cancelRide(id, reason), getRide(id), getActiveRide(src) Ride lifecycle/query
getMeter(vehicle), addExtra(vehicle, extraId) Vehicle meter/query
getLines(filter), getLine(id), getDepartures(stopId, limit) Published route/timetable queries
getBoard(terminalId), getDesk(src) Terminal/dispatch data
hasValidTicket(src, opts) Validate stored ticket eligibility
issueTicket(src, productId, opts), sellProduct(src, productId, opts) Issue or sell a product
refundTicket(src, ticketId) Refund a ticket
createBooking(def), getBookings(filter) Persist/query advance bookings
getRun(src), getAccessibility(src) Driver run/rider preference data
can(src, feature, opts), getSurge(pos) Access and surge queries
addRating(rideId, subject, stars, tags, comment, src), getRating(subject, target) Completed ride ratings
lua
local estimate, reason = exports.np_transport:quote({
  pickup = { x = 215.0, y = -810.0, z = 30.0 },
  dropoff = { x = -1034.0, y = -2733.0, z = 20.0 },
  class = 'cab'
})
if estimate then
  print(estimate.min, estimate.max) -- cents
end

Addons ​

Declare np_addon 'np_transport' in the addon manifest and register through the host lifecycle. Registries are registerNpcProfile, registerVehicleClass, registerMode, registerFareRule, registerTourNarration, registerFareProduct, and registerStopProvider (each takes id, definition). addHook(name, fn) registers a hook. Owner registrations are cleaned up when their resource stops; veto hooks return false, 'reason'.

Events and phone RPCs ​

Server lifecycle events include np_transport:ride:requested, np_transport:ride:accepted, np_transport:ride:pickedUp, np_transport:ride:finished, np_transport:ride:cancelled, np_transport:meter:started, np_transport:meter:charged and np_transport:ticket:sold.

Ride's np_phone RPCs use dotted names: ride.state, ride.quote, ride.request, ride.cancel, offer.list, offer.accept, offer.skip, and rate.submit. Pushes use ride.update, offer.update and rate.open. NUI callbacks use colon names and are bridged through server RPC validation. Use the resource's docs/IMPLEMENTATION.md for full surface payloads.