@gamecp/types
v0.4.1
Published
TypeScript type definitions for GameCP extensions
Maintainers
Readme
@gamecp/types
TypeScript type definitions for GameCP extensions.
Installation
npm install @gamecp/typesUsage
import type { Extension, ExtensionContext, CronEvent } from '@gamecp/types';
const extension: Extension = {
async onLoad(context: ExtensionContext) {
context.logger.info('Extension loaded!');
},
async onCron(event: CronEvent, context: ExtensionContext) {
const servers = await context.server?.getInfo();
context.logger.info('Cron tick', { servers });
}
};
export default extension;Type Definitions
Core Types
Extension- Main extension interface with lifecycle hooksExtensionContext- Runtime context available to extensionsExtensionManifest- Schema forgamecp.jsonmanifest file
Events
CronEvent- Cron schedule executionServerEvent- Server lifecycle eventsPlayerEvent- Player join/leave eventsConsoleOutputEvent- Server console output
APIs
ServerAPI- Server control methods (restart, sendCommand, etc.)Storage- Persistent key-value storageLogger- Structured logging
Manifest Schema
import type { ExtensionManifest } from '@gamecp/types';
const manifest: ExtensionManifest = {
id: 'my-extension',
name: 'My Extension',
version: '1.0.0',
description: 'Does something cool',
author: {
name: 'Your Name'
},
main: 'dist/index.js',
permissions: ['server:read', 'server:control'],
cron: [
{
expression: '*/5 * * * *',
description: 'Run every 5 minutes'
}
]
};License
MIT
