πŸ’»
alt:V Athena Docs v3.0.0
  • Info
    • Introduction
    • Patreon & Support
    • Athena Discord
    • FAQ
  • Installation
    • Common Issues
    • Windows
    • Linux (Ubuntu 20.04+)
    • Debugging
    • Updating
  • Info
    • Admin
    • Configuration
    • Console
    • Database
    • Hotkeys
    • Identifier
  • Plugins
    • Load Plugins
    • Create Plugins
    • Mods
    • Clothing
  • Controllers
    • What is a Controller?
    • Blip Controller
    • Interaction Controller
    • Marker Controller
    • Object Controller
    • Ped Controller
    • Text Label Controller
    • World Notification Controller
  • Systems
    • Interiors
    • Inventory & Items
    • Inventory Rules
    • Jobs
    • Time
    • Weather
  • Menus
    • Menu Types
    • Action Menus
    • Input Menu
    • Wheel Menu
  • Player
    • Admin-Commands
    • Animations
    • Attach Objects
    • Credits
    • Currency
    • Commands
    • Error Screen
    • Message
    • Meta
    • Notifications
    • Particle
    • Progress Bar
    • Save
    • Shard
    • Sound
    • Spinners
    • Task Timeline
  • Custom WebViews
    • Introduction
    • Your First Page
    • CSS Framework
  • Misc
    • Custom Sounds
    • Custom Streamers
    • Custom Icons
    • Adding Locale / Translations
    • Adding Vehicle Rules
    • Adding Whitelist
    • Adding Wheel Menus
    • Adding Parking Garages
Powered by GitBook
On this page
  • Structure
  • Naming
  • Dependencies
  • Registering a Server Plugin
  • Learn from Example
Edit on GitHub
  1. Plugins

Create Plugins

Learn to Create Plugins

Plugins in the Athena Framework are made in a specific way. Meaning, that following this general structure will help you create robust plugins without touching the core of the framework.

It is important that when a plugin is created that is does not adjust the core of the Athena Framework. This ensures that compatability is future-proof and additional updates to the plugin can be made without over complicating it.

Structure

All plugins should be placed inside the src/core/plugins folder.

The folder structure is very specific.

It consists of several folders inside your main folder.

  • server

    • This should all be server-side code

  • client

    • This should all be client-side code

  • shared

    • This should be shared between server, client, and webview

  • webview

    • This is a WebView Page you want to inject

    • DOES NOT SUPPORT IMAGES, SOUNDS, ETC. THEY BELONG IN THE src-webviews/public folder

src/core/plugins/core-example
  |───dependencies.json
  β”œβ”€β”€β”€client
  β”‚   β”‚   index.ts
  |   β”‚
  β”‚   └───src  
  β”‚       β”‚   file1.ts
  β”‚       β”‚   file2.ts
  β”‚       β”‚   file3.ts
  |
  β”œβ”€β”€β”€server
  β”‚   β”‚   index.ts
  β”‚   β”‚
  β”‚   └───src
  β”‚       β”‚   file1.ts
  β”‚       β”‚   file2.ts
  β”‚       β”‚   file3.ts
  β”‚
  β”œβ”€β”€β”€shared
  β”‚   β”‚   file1.ts
  β”‚   β”‚   file2.ts
  β”‚   β”‚   file3.ts
  β”‚
  └───webview
      β”‚   Example.vue
      β”‚   tsconfig.json
      β”‚
      β”œβ”€β”€β”€components
      β”‚       Component1.vue
      β”‚       Component2.vue
      β”‚       Component3.vue

Naming

Rules for Files and Folder(s)

  • Plugins should use kebab-case for folder names.

    • ie. door-plugin

  • File names should be camelCase.

    • ie. mainDoorController.ts

  • Plugins should use their respective folders for imports

    • Server: src/core/plugins/example-plugin/server

      • The main import file for the plugin should be called index.ts.

    • Client: src/core/plugins/example-plugin/client

      • The main import file for the plugin should be called index.ts.

    • Shared: src/core/plugins/example-plugin/shared

    • WebView: src/core/plugins/example-plugin/webview

      • There must be a main *.vue file in this folder.

      • Keep all components and additional vue files in subfolders.

  • Entry file for a Plugin should be index.ts

    • This applies to both client and server.

It is up to you as the plugin creator to provide GOOD instruction(s) on installation and removal of the plugin.

Dependencies

If you have server-side dependencies for an npm package you can create a dependencies.json in the root of your plugin structure to auto-install dependencies for an end-user.

{
    "dependencies": [
      "discord.js@latest"
    ],
    "devDependencies": [
      "glob"
    ]
}

Dependencies in devDependencies will not be installed during production mode of the server. Meaning if you want to use an npm package in the game mode you should put it in dependencies.

Example dependencies.json

Registering a Server Plugin

In your plugin's index file you should register your plugin.

import * as alt from 'alt-server';
import { PluginSystem } from '../../server/systems/plugins';

const PLUGIN_NAME = 'Example Plugin';

PluginSystem.registerPlugin(PLUGIN_NAME, () => {
    // Initialize other things for your plugin here...
    alt.log(`~lg~${PLUGIN_NAME} was Loaded`);
});

Learn from Example

Last but not least you should always look at the existing plugins to get a general idea of how they work and how they're being implemented.

PreviousLoad PluginsNextMods

Last updated 3 years ago