Skip to content

Project structure and modules

A plugin package may contain Lua modules and image assets in addition to its manifest and entry script.

text
example-plugin/
├─ manifest.json
├─ main.lua
├─ modules/
│  └─ settings.lua
└─ assets/
   └─ marker.png

Loading a module

Use the sandboxed require() with a package-relative module name:

lua
local settings = {}

function settings.load()
    return {
        enabled = samp.storage.get("enabled", true),
        color = samp.storage.get("color", "orange")
    }
end

return settings
lua
local settings = require("modules.settings")
local state = settings.load()

Modules are cached per plugin. They cannot resolve files outside the installed plugin version.

Paths

Package paths must:

  • be relative;
  • use /, including on Windows;
  • contain no empty, . or .. segment;
  • contain no backslash or NUL;
  • stay inside the package.

The package must not add a wrapper directory above manifest.json.

Assets

HUD images use package-relative paths such as assets/marker.png. Supported images are bounded by file dimensions, decoded memory, per-plugin cache count, and global texture memory. Load and reuse a small image instead of generating many variants.