Extra
Script plugin example: exported helper, chat greeting and a command. No rebuild.
- Kind
- Script (.sa)
- Status
- script example, no rebuild
- Natives
- none
- Hooks
player::connect
Enable
Add the path to server.plugins (or `plugins` in server.cfg).
knight
server.plugins = ["plugins/extra"];Workflow
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
Source
plugins/extra/extra.sa
32 lines
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()}");
};