NX CreativeNX CreativeDocs
Scriptsnx_write

Installation

Resource-specific setup for nx_write. Dependencies, database tables, item registration, and the right-click Place button.

For server-wide prerequisites (artifacts, oxmysql, ox_lib), work through the generic install guide first. This page only lists what is specific to nx_write.

Dependencies

Framework detection is automatic: ESX, QBCore, or QBox. Start the framework resource before nx_write. In practice you will want both ox_inventory and ox_target: the resource is driven by an inventory item, and pickup of placed notes uses a target zone.

oxmysql
Required

Database driver for saved documents and placements.

ox_lib
Required

Callbacks, notifications, and locale utilities.

nx-3d
Required

Renders the writing surface onto the notepad prop and the placed page onto its prop.

ox_inventory
Optional

Provides the notepad and post-it items and the use / place flow. Required for the intended experience.

ox_target
Optional

Adds the "Pick up" interaction on placed notes.

Database

nx_write creates its tables on first start using an EnsureTable pattern, so no manual import is required. If you prefer to seed the schema by hand, import sql/create.sql into the database oxmysql points at:

mysql -u <user> -p <database> < sql/create.sql

The schema creates:

  • nx_write_documents. Saved document rows: owner, author, paper kind, title, content, and a preview image.
  • nx_write_placements. Notes placed in the world: kind, linked document, position, and a quaternion rotation.

[!tip] sql/create.sql uses CREATE TABLE IF NOT EXISTS and an idempotent migration step, so running it on an existing install is safe and leaves your data untouched.

server.cfg order

ensure oxmysql
ensure ox_lib
ensure nx-3d
# ensure your framework here (es_extended, qb-core, or qbx_core)
ensure ox_inventory
ensure ox_target
ensure nx_write

Items

nx_write does not register its items for you. Add the notepad and postit definitions below to [core_ox]/ox_inventory/data/items.lua, and copy notepad.png / postit.png from nx_write/inventory-images/ into ox_inventory/web/images/.

[!warning] The client block is what routes using the item to the writing session. Leave it out and using the item does nothing — the inventory just closes and no error is printed. If the notepad never appears in hand, a missing client.event is the first thing to check.

The buttons block adds the right-click Place action for saved notes, which calls the placeFromSlot export. Keep both blocks.

['notepad'] = {
    label = 'Notepad',
    weight = 1,
    stack = false,
    close = true,
    consume = 0,
    description = 'A spiral notepad. Use it to write or continue writing.',
    client = {
        event = 'nx_write:client:useItem',
        kind = 'notepad',
    },
    buttons = {
        {
            label = 'Place',
            action = function(slot)
                exports.nx_write:placeFromSlot(slot)
            end,
        },
    },
},

['postit'] = {
    label = 'Post-it Note',
    weight = 1,
    stack = true,
    close = true,
    consume = 0,
    description = 'A sticky note. Write a short message; place anywhere.',
    client = {
        event = 'nx_write:client:useItem',
        kind = 'postit',
    },
    buttons = {
        {
            label = 'Place',
            action = function(slot)
                exports.nx_write:placeFromSlot(slot)
            end,
        },
    },
},

A note must be saved at least once before it can be placed. Saving stamps the document id onto the slot; placing reads it from there.

Convars

Set this in server.cfg to override the locale without editing the config file:

setr nx_write:locale "fi"