A server without the Glitch Studios extras#
Config.Integrations = {
presets = false,
photos = false,
addons = false,
lights = false,
keybar = false,
airhorn = false,
vehicleNames = 'qbx_core',
}
Config.LegacyPayCallbacks = {}
Config.NoExtrasModels = {}
Config.PhotoCdn = ''
Config.Money = { locale = 'en-US', symbol = '$' }
Config.Log = function(source, event, title, message)
print(('[mechanic] %s: %s'):format(title, message))
end
Customer order screen#
Client side, with the customer sitting in the car:
local ok = exports['glitch-mechanicMenu']:OpenOrder({
tabs = { 'paint', 'body', 'wheels', 'lights', 'perf' },
shop = "Benny's",
event = 'my-shop:client:order',
data = { shop = 'bennys' },
hide = { 'driftTyres', 'windowTint' },
addons = {
{ key = 'car_stereo', label = 'Car stereo', icon = 'ti-music', on = false, price = 1500 },
},
})
AddEventHandler('my-shop:client:order', function(build, hex, data)
-- build: the changed ox_lib properties, plus addon_<key> for add-on rows
-- hex: colour hex values for palette paints
TriggerServerEvent('my-shop:server:placeOrder', build, data.shop)
end)
The menu puts the car back when it closes, whether the order was sent or not. Pass build = lastBuild to show the customer's previous picks again.
An add-on row can also be a choose-one list stepped with arrows. The build then gets addon_<key> set to the chosen value ('' for stock):
{ key = 'exhaust_kit', label = 'Exhaust', kind = 'cycle', options = {
{ value = 'sport', label = 'Sport', price = 1000 },
{ value = 'race', label = 'Race', price = 2500 },
} }
Marking parts no mechanic can fit#
locks names a client export that the menu calls with (build, hex, data) after each change. It must return at once, because it runs inside this resource and cannot wait for the server.
exports('OrderLocks', function(build, hex, data)
if build.modEngine and build.modEngine >= 3 then
return { list = { { key = 'modEngine', label = 'Engine level 4', need = 'Mechanic: Performance level 6' } }, note = 'Ask a senior mechanic' }
end
return { list = {} }
end)
-- in OpenOrder:
locks = { resource = 'my-shop', export = 'OrderLocks' },
Paid job workshop#
Client:
exports['glitch-mechanicMenu']:OpenLimited({
vehicle = veh, -- optional, defaults to the car you are driving
title = 'Police Workshop',
allow = { 'paint', 'paintExtra', 'extras', 'livery', 'tint' },
prices = { paint = 250, paintExtra = 150, extras = 100, livery = 200, tint = 100 },
share = 100,
payer = 'the police account',
payCallback = 'my-job:server:workshopPay',
})
Server:
lib.callback.register('my-job:server:workshopPay', function(source, parts, method, plate)
local bill = exports['glitch-mechanicMenu']:GetSessionBill(source) or parts
-- take the money for every part in bill; return false, 'reason' if that fails
exports['glitch-mechanicMenu']:ConfirmSessionPaid(source)
return true, 'Paid'
end)
Without payCallback, Done keeps the changes and Undo all puts the car back. Nothing in workshop mode is written to player_vehicles.
Authorising sessions from the server#
With Config.RequireSessionGrant = true, your server grants each session before the client opens the menu. The grant covers one session of that mode on that car for 30 seconds:
-- server
lib.callback.register('my-job:server:canOpenWorkshop', function(source, netId)
-- your own job or location checks here
return exports['glitch-mechanicMenu']:AllowSession(source, netId, 'paid', { 'paint', 'tint' })
end)
-- client
local netId = NetworkGetNetworkIdFromEntity(veh)
if lib.callback.await('my-job:server:canOpenWorkshop', false, netId) then
exports['glitch-mechanicMenu']:OpenLimited({ vehicle = veh, allow = { 'paint', 'tint' }, prices = { paint = 250, tint = 100 }, payCallback = 'my-job:server:workshopPay' })
end
The mode is 'order' for OpenOrder, 'paid' for OpenLimited with a payCallback and 'limited' without one. The allow list must fit inside the parts you granted.
Opening the admin menu from another resource#
TriggerClientEvent('glitch-mechanicMenu:open', src)
The player can look around, but saving and presets still need the ACE.