Home
Items
  • Tribals.io Wiki
    • Items
      • Resources
        • Wood
        • Charcoal
        • Stone
        • Leaf
        • Rope
        • Iron
        • Iron Fragment
        • Iron Bar
        • Sulfur
        • Cooked Sulfur
        • Leather
        • Tusk
        • Hide
        • Fat
        • Bone
        • Feather
        • Gun Barrel
        • Spring
        • SemiAuto-Body
        • Gunpowder
        • Explosive Gunpowder
      • Food
        • Banana
        • Mashed Banana
        • Berry
        • Carrot
        • Raw Chicken
        • Cooked Chicken
        • Burned Chicken
        • Corn
        • Popcorn
        • Shrimp
        • Cooked Shrimp
        • Catfish
        • Cooked Catfish
        • Salmon
        • Cooked Salmon
        • Trout
        • Cooked Trout
        • Bass
        • Cooked Bass
        • Mushroom
        • Watermelon
        • Coconut
        • Food Garbage
        • Raw Meat
        • Cooked Meat
      • Books
        • Pistol Book
        • Worn Pistol Book
        • Musket Book
        • Worn Musket Book
        • Shotgun Book
        • Worn Shotgun Book
        • Explosives Book
        • Worn Explosives Book
        • Chainmail Boots Book
        • Worn Chainmail Boots Book
        • Chainmail Legs Book
        • Worn Chainmail Legs Book
        • Chainmail Chest Book
        • Worn Chainmail Chest Book
        • Chainmail Helmet Book
        • Worn Chainmail Helmet Book
        • IronPlated Boots Book
        • Worn IronPlated Boots Book
        • IronPlated Legs Book
        • Worn IronPlated Legs Book
        • IronPlated Chest Book
        • Worn IronPlated Chest Book
        • IronPlated Helmet Book
        • Worn IronPlated Helmet Book
      • Weapons and Equipment
        • Torch
        • Hatchet
        • Iron Hatchet
        • Stone Pickaxe
        • Iron Pickaxe
        • Bone Knife
        • Wooden Spear
        • Stone Spear
        • Iron Spear
        • Slingshot
        • Wooden Bow
        • Pistol
        • Musket
        • Shotgun
        • Upgrade Hammer
        • Paint Brush
        • Building Plan
        • Note
      • Ammunition
        • Stone Arrow
        • Pistol Ammo
        • Musket Ammo
        • Shotgun Ammo
        • Explosive Shotgun Ammo
      • Armor and Clothing
        • Leather Set
          • Leather Boots
          • Leather Pants
          • Leather ShortShirt
          • Leather LongShirt
          • Leather Gloves
        • Wood Set
          • Wood Boots
          • Wood Legs
          • Wood ChestPlate
          • Wood Helmet
        • Chainmail Set
          • Chainmail Boots
          • Chainmail Legs
          • Chainmail ChestPlate
          • Chainmail Helmet
        • IronPlated Set
          • IronPlated Boots
          • IronPlated Legs
          • IronPlated ChestPlate
          • IronPlated Helmet
    • Structures
      • Toolbox
      • Wooden Platform
      • Triangle Platform
      • Trap Platform
      • Wall
      • MidWall
      • Window
      • Roof
      • Triangle Roof
      • RoofHatch
      • Door Gateway
      • Door
      • Metal Door
      • Fence
      • Shelf
      • Ladder
      • Stairs
      • Slope
      • Pillar
      • Stone Structures
        • Stone Platform
        • Stone Triangle Platform
        • Stone Wall
        • Stone Midwall
        • Stone Window
        • Stone Roof
        • Stone Triangle Roof
        • Stone RoofHatch
        • Stone Door Gateway
        • Stone Ladder
    • Building elements
      • Sleeping Bed
      • Lock
      • Spike
      • Signpost
      • Fishing Net
      • Banner
      • Smelter
      • Camp Fire
      • Workbench
      • Wooden Box (Storage)
      • Big Storage
      • Repair Table
      • Water Collector
      • Vending Machine
      • Rug
      • Bear Trap
    • Creatures
      • Animals
        • Bear
        • Boar
        • Wolf
        • Chicken
        • Seagull
        • Fish
      • Humanoids
        • Pirate
    • Crafting
    • Decay
    • Clans
    • Tribals+
    • Server Transfer
    • Fast Crafting
    • Community (Private) Servers
      • Video tutorials
        • How to update your server?
        • How to add custom ammo?
      • Rules
      • Server Scripting
    • Special Events
      • Pirate Event
Powered by GitBook
On this page
  • Settings (settings.json) file structure
  • Game Mode
  • Mode Settings
  • Mode Name
  • Events
  • Actors
  • Methods
  • Bypass Methods
  • Scripts
  • Example Script:
  1. Tribals.io Wiki
  2. Community (Private) Servers

Server Scripting

Players who own a server can create customized game modes via editing the conditions/events in Settings rule file, without needing to know coding!

PreviousRulesNextSpecial Events

Last updated 1 year ago

Everything inside of the settings file can be customized to create different game modes. Apart from current settings in the file, more ways to customize the private servers will be added soon.

Rule files in Tribals are written in file format, including settings.json file.

Settings (settings.json) file structure

  • (onCancel)

Game Mode

It defines which of the specified modeSetting will be set as the current game mode.

Mode Settings

modeSettings is the parent category of the game modes in your server. All of your game modes will be a child element of this element. You can share your modes with other players, and they can easily add them under their modeSettings area.

Mode Name

The name of your mode. Usually defines the general gameplay rules of your server. For example, official Tribals servers have PVP, PVE, and Test type of game modes. But you can name your script as anything! Make sure its name can only contain the letters in the English alphabet, and numbers.

Events

Events are the things that we listen if they triggered or not. When triggered, it brings back the information about the thing it triggered with. We can use the information to set an outcome of the triggered event. We can listen actors, set methods, and add scripts under the event we listen.

  • onInteract: When player interacts with it.

  • onSpawn: When player spawns.

  • onAttack: When player attacks to it.

  • onKill: When player kills it.

  • onDropItem: When player drops item.

  • onCraft: When player crafts a something

  • onBuild: When player builds something

Actors

  • Building

  • Player

  • Animal

Methods

onCancel is the only method available for now. When specified, it will cancel the triggered event, based on the terms you specify. An error message can be set when event cancelled.

This effect can be overridden with bypass methods.

Also, the things listed after the onCancel method will also override the cancel.

Bypass Methods

Bypasses the onCancel method, based on the specified terms. The bypass methods are only for the building elements. More methods will be added soon.

It will bypass the event if:

  • isResource: The "building" is a resource

  • decaying: The building is decaying

  • isProtected: The building is protected

  • authorized: Player is authorized to the building

  • owner: The building is owned by the player

Scripts

  • Clearall: clears the player inventory Usage: "script": ["clearall"]

  • Heal: fully heals the player health, hunger and thirst. Usage: "script": ["heal"]

  • Destroy: Destroys the object/building Usage: "script": ["destroy"]

  • Add Item: Adds the specified item and quantity. Usage: "script": ["addItem shit 1"]

  • Add Items: Used to add items to specific slots, with specified quantity. It should be used after "clearall" to avoid errors. Make sure the last item doesn't have a comma after it. Usage: "addItems": [ { "name": "Pistol", "amount": 1, "slot": 1 }, { "name": "PistolAmmo", "amount": 99, "slot": 2 } ]

  • Any of the script can be run at the same time. Usage: "script": ["heal", "clearall", "addItem shit 1", "destroy"]

Example Script:

Let's create a "PVE" game mode from settings.json file

  1. modeSettings is where you will write scripts for different modes. It's the parent category of your game modes.

  2. The next line is for the name of your script. It can include any letter in the English alphabet. In this case, we'll use "PvE".

  1. Next, you'll create the event you want to listen. In this example, we will use onInteract event. It will be triggered, when player "interacts" with this object.

  1. Under onInteract event, we will define exactly what this script is for; Building, Player, or Animal. In this example, I use Building:

  1. We want to cancel building, so we'll use onCancel event to prevent buildings from interacted. Before that, we can specify things that'll bypass the onCancel event. In this case the owner of the house, resources, and authorized players can be interacted with each other.

  2. If we want to add more building elements that will bypass onCancel event, we can list them under it. For this example, we should add the Toolbox to the items that can be interacted, so players can interact with toolbox to get authorized.

The things that determines what triggered this event. We can prevent specific actors to trigger in any event, via method.

Scripts are premade commands that does something. Can be use under , , and in objects (item or building)

onCancel
events
actors
JSON
Game mode
Mode settings
Mode name
Events
Actors
Methods
Bypass methods
Scripts
Creating a PVE server example
Settings.json file, "PVP Deathmatch" game mode settings
"Test" is the specified game mode.
Plants can be destroyed, while the rest of the "Building" elements can't be damaged
The name of the game mode script
The event we listen to interact with other things
We can define specific things that will happen when player interacts with something. In this case, player interacts with a Building.
A script that prevents the building elements from being interacted. Thanks to bypass; it will allow owners to be interact with their buildings, resources can still be interacted, and authorized users may interact with the buildings element they authorized to.