Devices/Player Items

Player Items

Laptops, computers and tablets as inventory items.

Devices pages

Laptops, computers and tablets are inventory items. Using a laptop or computer item shows a see-through device where the player looks; the mouse wheel turns it, Enter places it on a table, Esc or Backspace stops. The server takes the item only when it accepts the spot, and gives it back on every failed step.

The placer owns the device. With ox_target the device offers Settings (name, Only me, Me and these people, Everyone, the apps allowed on player devices, Move) and Pick up. Limits, homes and the tablet rules are on the Player items page of the panel; no-place zones are under Map and signal.

The panel's Player items page shows the item lines for the inventory that runs, with the item names from config/items.lua.

Item lines

Works on Qbox, QBCore and ESX. Add these to ox_inventory/data/items.lua:

ox_inventory/data/items.lua
['evolent_laptop'] = {
    label = 'Laptop',
    weight = 2200,
    stack = false,
    close = true,
    consume = 0,
    description = 'Put it on a table to use it.',
    client = {
        image = 'nui://evolent_devices/web/build/items/evolent_laptop.png',
        export = 'evolent_devices.placeItem',
    },
},

['evolent_pc'] = {
    label = 'Computer',
    weight = 9000,
    stack = false,
    close = true,
    consume = 0,
    description = 'Put it on a desk to use it.',
    client = {
        image = 'nui://evolent_devices/web/build/items/evolent_pc.png',
        export = 'evolent_devices.placeItem',
    },
},

['evolent_tablet'] = {
    label = 'Tablet',
    weight = 700,
    stack = false,
    close = true,
    consume = 0,
    description = 'Take it out to use the Evolent OS.',
    client = {
        image = 'nui://evolent_devices/web/build/items/evolent_tablet.png',
        export = 'evolent_devices.useTablet',
    },
},
  • stack = false: every item is one device with its own serial number. evolent_devices stamps it the moment the item is made (shop, /giveitem, the panel's Give an item, any script) through ox_inventory's createItem hook.
  • consume = 0: the item never goes when it is used. A laptop or computer leaves the inventory only once the server has taken the spot on the table, and comes back on every failed step.
  • If the inventory shows no picture, copy the files from web/build/items into ox_inventory/web/images and use image = 'evolent_laptop.png' and so on.
  • A shop can sell a tablet colour: { name = 'evolent_tablet', price = 1100, metadata = { colour = 'lime' } }. Colours: onyx (the default), silver, lime, midnight, graphite, white, red, blue, rose, gold.

ox_inventory reads its item list only when it starts.

Item rules

config/items.lua holds the starting values; the panel's Player items page wins over them.

OptionDescription
itemThe item name in the inventory.
serialPrefixEvery item gets a serial number like EVL-3F9A0C the first time it exists.
enabledPlayers can place it with the item.
placeWho may place it: { mode = 'everyone' } or { mode = 'rules', rules = { ... } }.
perPlayerMost placed devices of this kind one player may own, 0 = no limit.
where'anywhere' or 'homes' (only inside a home; homes need Qbox with qbx_properties). Admins' no-place zones always apply.
homeKeysOnlyInside a home only the owner or someone with keys may place it (Qbox with qbx_properties only).
tableMin, tableMaxMetres above the floor a table must be.
pickupWho may pick it up: 'owner', or 'manage' (the owner and people allowed to move it).
onRemoveWhen an admin removes it: 'return' gives it back to the owner, 'delete' deletes it.
startAccessWho may use a device a player just placed. { mode = 'everyone' } out of the box: anyone may walk up to it, the device password keeps people out.
startAppsApp ids already installed on a new device.

The tablet

The tablet is held in hands. use is who may use a tablet, apps the apps tablets show (order their order, entries one line per app id with on and its settings), and blocked the serial numbers that no longer work, for a lost or stolen tablet.

A tablet another script lends for its own app shows only that app and follows that script's rules instead of use. Switching the tablet item off stops lent tablets too. See Lending the tablet.