playerOnboarding
- builtin
- by Takaro
- Takaro >=0.0.1
- all
Built-in modules ship with Takaro — no import needed.
Collection of functions that are executed when a player joins the server. Helps with onboarding new players, like sending a welcome message. Fixed issue with starterkit item identifiers.
Configuration 2
Settings you fill in when installing the module on a server.
| Setting | Type | Default | Description |
|---|---|---|---|
message Message | string | "Welcome {player} to the server!" | The message to send to the player when they join the server. |
starterKitItems Starter kit items | array | — | List of items a player will receive when they execute the starterkit command for the first time. |
Raw config schema
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"message": {
"title": "Message",
"description": "The message to send to the player when they join the server.",
"type": "string",
"minLength": 1,
"maxLength": 256,
"default": "Welcome {player} to the server!"
},
"starterKitItems": {
"type": "array",
"title": "Starter kit items",
"x-component": "item",
"description": "List of items a player will receive when they execute the starterkit command for the first time.",
"uniqueItems": true,
"items": {
"type": "object",
"title": "Item",
"properties": {
"item": {
"type": "string",
"title": "Item"
},
"amount": {
"type": "number",
"title": "Amount"
},
"quality": {
"type": "string",
"title": "Quality"
}
}
}
}
},
"required": [],
"additionalProperties": false
} Raw UI schema
{
"starterKitItems": {
"items": {
"item": {
"ui:widget": "item"
}
}
}
} Commands 1
Chat commands players trigger in game.
-
starterkit
Get a starter kit, you can only execute this once on a server!
Command source
import { takaro, data, TakaroUserError } from '@takaro/helpers'; const VARIABLE_KEY = 't_starterkit_lock'; async function main() { const items = data.module.userConfig.starterKitItems; if (!items || items.length === 0) { throw new TakaroUserError('No starter kit items configured. Please ask your server administrator to configure this.'); } const starterKitLockRes = await takaro.variable.variableControllerSearch({ filters: { key: [VARIABLE_KEY], gameServerId: [data.gameServerId], playerId: [data.player.id], }, }); if (starterKitLockRes.data.data.length > 0) { throw new TakaroUserError('You already used starterkit on this server'); } await data.player.pm('You are about to receive your starter kit...'); const itemRecords = (await takaro.item.itemControllerSearch({ filters: { id: items.map((_) => _.item) } })).data.data; const fullItems = items.map((item) => { const itemRecord = itemRecords.find((record) => record.id === item.item); if (!itemRecord) { throw new TakaroUserError(`Item with ID ${item.item} not found.`); } return { id: itemRecord.id, quality: item.quality, amount: item.amount, }; }); await Promise.all(fullItems.map(async (item) => { return takaro.gameserver.gameServerControllerGiveItem(data.gameServerId, data.player.id, { name: item.id, quality: item.quality ?? '', amount: item.amount, }); })); await takaro.variable.variableControllerCreate({ key: VARIABLE_KEY, value: '1', gameServerId: data.gameServerId, playerId: data.player.id, }); await data.player.pm(`Gave ${items.length} items, enjoy!`); } await main(); //# sourceMappingURL=starterkit.js.map
Hooks 1
Code that runs in reaction to a game or Takaro event.
-
playerConnected
Hook for player-connected events
Hook source
import { takaro, data } from '@takaro/helpers'; async function main() { const { player } = data; const rawMessage = data.module.userConfig.message; const message = rawMessage.replace('{player}', player.name); await takaro.gameserver.gameServerControllerSendMessage(data.gameServerId, { message, }); } await main(); //# sourceMappingURL=playerConnected.js.map