Knight docs
EN ID
GitHub
← Semua plugin

Extra

Contoh plugin skrip: fungsi export, sapaan chat, dan command. Tanpa rebuild.

Jenis
Script (.sa)
Status
contoh skrip, tanpa rebuild
Native
tidak ada
Hook
player::connect

Mengaktifkan

Tambahkan path ke server.plugins (atau `plugins` di server.cfg).

knight
server.plugins = ["plugins/extra"];

Alur kerja

flowchart TD
  A["server.plugins path"] --> B["Load extra.sa"]
  B --> C["export function extraGreeting()"]
  B --> D["on player::connect"]
  B --> E["player::command /plugin"]
  D --> F["SendClientMessage greeting"]
  E --> G["Call exported helper"]
  C --> G

Kode sumber

plugins/extra/extra.sa 32 baris
knight
// Example script plugin: a single .sa file loaded with
//   server.plugins = ["plugins/json", "plugins/extra/extra.sa"];
// or  plugins plugins/json plugins/extra/extra.sa  in server.cfg.
//
// A script plugin behaves like an imported module: its functions are callable
// and its `on` hooks run with the gamemode's handlers.
module "extra" {
    version: "1.0.0";
    author: "Knight";
};

const GREETING = "Halo dari plugin .sa!";

let joins = {};

function extraJoins(int id) {
    return at(joins, id);
}

export function extraGreeting() {
    return GREETING;
}

on player::connect() {
    joins[playerid] = 1;
    SendClientMessage(playerid, GREETING);
};

player::command("/plugin") {
    SendClientMessage(playerid, "script plugin aktif, greeting={extraGreeting()}");
};