triviaTime
- community
- minigames
- by limon
- Takaro main
- all
Limon_triviaTime: Interactive Trivia Game System
The Limon_triviaTime module transforms your gaming server with an engaging trivia game system that automatically poses questions and rewards correct answers. This interactive Takaro module enhances player engagement while creating fun community interactions.
Key Benefits:
- Customizable Question Library: Build your own collection of trivia questions and answers
- Flexible Reward System: Choose between currency or item rewards for winners
- Automated Scheduling: Set trivia events to run at specified intervals
- Player Engagement Tool: Keeps your community active and entertained
- Simple Answer Validation: Easy command-based answer submission system
Features:
- Configurable question database with pre-populated examples
- Dual reward types (currency or items)
- Customizable item quality and quantity settings
- Permission-based participation control
- Automated trivia scheduling with cron jobs
- Real-time feedback on incorrect answers
- Server-wide announcements for winners
Ideal for server administrators looking to increase player retention and build community through interactive gameplay elements. Works seamlessly with existing Takaro economy and item systems.
Configuration 4
Settings you fill in when installing the module on a server.
| Setting | Type | Default | Description |
|---|---|---|---|
rewardItems Items | array | — | If you choose items as a rewardtype, you will be able to select a list of items. |
rewardType rewardType | string | "currency" | Choose Currency or items |
rewardAmount rewardAmount | number | 0 | If you choose currency this will be the reward amount |
questions Questions | array | [{"question":"What is the capital of France?","answer":"Paris"},{"question":"What is a baby goat called?","answer":"Kid"},{"question":"What is the largest mammal?","answer":"Blue Whale"},{"question":"What is the largest planet in our solar system?","answer":"Jupiter"},{"question":"What is the largest ocean on Earth?","answer":"Pacific Ocean"},{"question":"What is the largest country in the world?","answer":"Russia"},{"question":"What is the largest desert in the world?","answer":"Antarctica"},{"question":"What is the largest continent on Earth?","answer":"Asia"},{"question":"What is the largest mountain in the world?","answer":"Mount Everest"},{"question":"What is the largest forest in the world?","answer":"Amazon Rainforest"}] | Key value pairs of questions and answers |
Raw config schema
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"rewardItems": {
"title": "Items",
"description": "If you choose items as a rewardtype, you will be able to select a list of items.",
"x-component": "item",
"type": "array",
"uniqueItems": true,
"items": {
"type": "object",
"title": "Item",
"properties": {
"item": {
"type": "string",
"title": "Item"
},
"amount": {
"type": "number",
"title": "Amount"
},
"quality": {
"type": "string",
"title": "Quality"
}
}
}
},
"rewardType": {
"title": "rewardType",
"description": "Choose Currency or items",
"default": "currency",
"type": "string",
"enum": [
"currency",
"items"
]
},
"rewardAmount": {
"title": "rewardAmount",
"description": "If you choose currency this will be the reward amount",
"default": 0,
"type": "number",
"minimum": 1,
"maximum": 100000
},
"questions": {
"type": "array",
"title": "Questions",
"description": "Key value pairs of questions and answers",
"items": {
"type": "object",
"properties": {
"question": {
"type": "string",
"description": "The question",
"minLength": 1
},
"answer": {
"type": "string",
"description": "The answer"
}
}
},
"default": [
{
"question": "What is the capital of France?",
"answer": "Paris"
},
{
"question": "What is a baby goat called?",
"answer": "Kid"
},
{
"question": "What is the largest mammal?",
"answer": "Blue Whale"
},
{
"question": "What is the largest planet in our solar system?",
"answer": "Jupiter"
},
{
"question": "What is the largest ocean on Earth?",
"answer": "Pacific Ocean"
},
{
"question": "What is the largest country in the world?",
"answer": "Russia"
},
{
"question": "What is the largest desert in the world?",
"answer": "Antarctica"
},
{
"question": "What is the largest continent on Earth?",
"answer": "Asia"
},
{
"question": "What is the largest mountain in the world?",
"answer": "Mount Everest"
},
{
"question": "What is the largest forest in the world?",
"answer": "Amazon Rainforest"
}
]
}
},
"additionalProperties": false
} Raw UI schema
{
"rewardItems": {
"items": {
"item": {
"ui:widget": "item"
}
}
}
} Commands 1
Chat commands players trigger in game.
-
playerAnswer
No help text available
Command source
import { takaro, data, TakaroUserError, checkPermission } from '@takaro/helpers'; async function main() { const { gameServerId, module: mod, player, chatMessage, pog } = data; if (!checkPermission(pog, 'TRIVIA_PARTICIPATE')) { throw new TakaroUserError('You do not have permission to participate in trivia!'); } const answer = chatMessage.msg.split(' ').slice(1).join(' '); // Get all trivia variables const triviaVars = await takaro.variable.variableControllerSearch({ filters: { key: ['trivia_question', 'trivia_answer', 'trivia_reward'], gameServerId: [gameServerId], moduleId: [mod.moduleId] } }); if (triviaVars.data.data.length === 0) { throw new TakaroUserError('There is no active trivia question right now!'); } // Parse variables const vars = triviaVars.data.data.reduce((acc, curr) => { acc[curr.key] = curr; return acc; }, {}); const question = vars.trivia_question.value; const correctAnswer = vars.trivia_answer.value; const reward = JSON.parse(vars.trivia_reward.value); if (answer.toLowerCase() === correctAnswer.toLowerCase()) { if (reward.type === 'currency') { await takaro.playerOnGameserver.playerOnGameServerControllerAddCurrency(gameServerId, player.id, { currency: reward.amount }); const currencyName = (await takaro.settings.settingsControllerGetOne('currencyName', gameServerId)).data.data.value; await takaro.gameserver.gameServerControllerSendMessage(gameServerId, { message: `${player.name} answered "${question}" correctly and received ${reward.amount} ${currencyName}!` }); } else { // For items, we need to get the item details first const itemDetails = (await takaro.item.itemControllerFindOne(reward.itemId)).data.data; await takaro.gameserver.gameServerControllerGiveItem(gameServerId, player.id, { name: itemDetails.code, amount: reward.amount, quality: reward.quality || '' }); await takaro.gameserver.gameServerControllerSendMessage(gameServerId, { message: `${player.name} answered "${question}" correctly and received ${reward.amount}x ${itemDetails.name}!` }); } // Clean up all trivia variables await Promise.all(Object.values(vars).map(variable => takaro.variable.variableControllerDelete(variable.id) )); } else { await takaro.gameserver.gameServerControllerSendMessage(gameServerId, { message: `${player.name} guessed "${answer}" - That's not correct! Try again!` }); } } await main();
Cron jobs 1
Work the module runs on a schedule.
-
TriviaTime
Cron job source
import { takaro, data } from '@takaro/helpers'; async function main() { const { gameServerId, module: mod } = data; // Check for online players const currentPlayers = (await takaro.playerOnGameserver.playerOnGameServerControllerSearch({ filters: { gameServerId: [gameServerId], online: [true] } })).data.meta; if (currentPlayers.total === 0) { return; } // Get questions from config or use default const questions = mod.userConfig.questions || [ { question: "What is the largest country in the world?", answer: "Russia" } ]; // Clear any existing questions/rewards const existingVariables = await takaro.variable.variableControllerSearch({ filters: { key: ['trivia_question', 'trivia_answer', 'trivia_reward'], gameServerId: [gameServerId], moduleId: [mod.moduleId] } }); // Delete all existing trivia variables await Promise.all(existingVariables.data.data.map(variable => takaro.variable.variableControllerDelete(variable.id) )); // Select random question const randomQuestion = questions[Math.floor(Math.random() * questions.length)]; // Store question separately await takaro.variable.variableControllerCreate({ key: 'trivia_question', value: randomQuestion.question, gameServerId, moduleId: mod.moduleId }); // Store answer separately await takaro.variable.variableControllerCreate({ key: 'trivia_answer', value: randomQuestion.answer, gameServerId, moduleId: mod.moduleId }); // Setup reward const rewardType = mod.userConfig.rewardType || 'currency'; if (rewardType === 'items') { const configuredItems = mod.userConfig.rewardItems || []; if (configuredItems.length > 0) { const randomItemIndex = Math.floor(Math.random() * configuredItems.length); const selectedItem = configuredItems[randomItemIndex]; // Store reward info separately await takaro.variable.variableControllerCreate({ key: 'trivia_reward', value: JSON.stringify({ type: 'items', itemId: selectedItem.item, amount: selectedItem.amount || 1, quality: selectedItem.quality || '' }), gameServerId, moduleId: mod.moduleId }); } else { console.error('Items reward type selected but no items configured'); return; } } else { // Store currency reward info await takaro.variable.variableControllerCreate({ key: 'trivia_reward', value: JSON.stringify({ type: 'currency', amount: mod.userConfig.rewardAmount || 100 }), gameServerId, moduleId: mod.moduleId }); } const prefix = (await takaro.settings.settingsControllerGetOne('commandPrefix', gameServerId)).data.data.value; await takaro.gameserver.gameServerControllerSendMessage(gameServerId, { message: `Trivia Time! ${randomQuestion.question} (Answer with ${prefix}answer <your guess>)` }); } await main();
Permissions 1
Roles you can grant to decide who may use what.
-
TRIVIA_PARTICIPATE
TRIVIA_PARTICIPATE