gimme

  • builtin
  • by Takaro
  • Takaro >=0.0.1
  • 7 days to die
  • rust
  • minecraft
Version

Built-in modules ship with Takaro — no import needed.

View export JSON

Randomly selects item from a list of items and entities. Fixed issue with item identifiers.

Configuration 2

Settings you fill in when installing the module on a server.

SettingTypeDefaultDescription
items required Items array List of items that a player can receive.
commands Commands array ["say hello from gimme"]
Raw config schema
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "items": {
      "x-component": "item",
      "type": "array",
      "title": "Items",
      "description": "List of items that a player can receive.",
      "uniqueItems": true,
      "items": {
        "type": "object",
        "title": "Item",
        "properties": {
          "item": {
            "type": "string",
            "title": "Item"
          },
          "amount": {
            "type": "number",
            "title": "Amount"
          },
          "quality": {
            "type": "string",
            "title": "Quality"
          }
        }
      }
    },
    "commands": {
      "title": "Commands",
      "type": "array",
      "default": [
        "say hello from gimme"
      ],
      "items": {
        "type": "string"
      }
    }
  },
  "required": [
    "items"
  ],
  "additionalProperties": false
}
Raw UI schema
{
  "items": {
    "items": {
      "item": {
        "ui:widget": "item"
      }
    }
  }
}

Commands 1

Chat commands players trigger in game.

  • gimme

    Randomly selects item from a list of items and entities.

    Command source
    import { takaro, data, TakaroUserError } from '@takaro/helpers';
    async function main() {
        const items = data.module.userConfig.items;
        const commands = data.module.userConfig.commands;
        if (items.length + commands.length === 0) {
            throw new TakaroUserError('No items or commands configured, please ask your server administrator to configure this module.');
        }
        // pick a random item between 0 and the length of both the items and commands arrays
        const randomIndex = Math.floor(Math.random() * (items.length + commands.length));
        const randomOption = items.concat(commands)[randomIndex];
        if (randomIndex < items.length) {
            const item = (await takaro.item.itemControllerFindOne(randomOption.item)).data.data;
            await takaro.gameserver.gameServerControllerGiveItem(data.gameServerId, data.player.id, {
                name: randomOption.item,
                amount: randomOption.amount,
                quality: randomOption.quality ?? '',
            });
            await data.player.pm(`You received ${randomOption.amount}x ${item.name}!`);
        }
        else {
            await takaro.gameserver.gameServerControllerExecuteCommand(data.gameServerId, { command: randomOption });
        }
    }
    await main();
    //# sourceMappingURL=gimme.js.map