wiki:Hooks

Hooks are a way to add additional behaviour to the scripts. They are basically custom scripts that are called upon specific events. For example one could define a hook which is called on player connects and then send a message in the in-game chat to greet the new player.

All hooks have to executable files that are either placed in SDTD_BASE/hooks/<name of hook>/<any name>.sh for global hooks that apply to all instances or SDTD_BASE/instances/<name of instance>/hooks/<name of hook>/<any name>.sh for hooks that only apply to that specific instance. The folder <name of hook> has to be in exactly the same case as the hook name column in the table below shows it.

If you want to use the functions of the management scripts in your hook you can add this to the start of your script:

#!/bin/bash
. /usr/local/lib/7dtd/common.sh

An example can be found in the greet.sh hook for playerConnect. Note that you have to use Bash as interpreter for your script if you want to use the script functions!

An example on how to use PHP for hooks can be found on the forum.

If you think a hook for another event could be interesting please create a ticket or contact me.

Currently the following hooks are defined:

Hook name

Called on event

Passed parameters

Examples

Notes

playerConnect

After a player has connected

  1. Instance name
  2. Entity ID
  3. Nickname
  4. Platform ID
  5. Client IP
  6. Steam Owner ID
  7. Crossplatform ID

playerDisconnect

After a player has disconnected

serverPreStart

Before an instance is started

  1. Instance name

serverPostStart

After an instance was started

serverPreStop

Before an instance is stopped

serverPostStop

After an instance was stopped

serverPreBackup

Before the actual backup routine is started

Only as global hook, not per instance.

serverPostBackup

After a backup was created

  1. Path of new backup folder

Only as global hook, not per instance.

backup

After a backup was created

  1. Path of new backup folder

Deprecated: Use serverPostBackup instead

playerSpawned

After a player has spawned in the world

  1. Instance name
  2. Entity ID
  3. Platform ID
  4. Steam Owner ID
  5. Nickname
  6. Spawn reason
  7. Position
  8. Crossplatform ID

Spawning in the world includes deaths, teleports etc. Check the reason if the event is valid for your purpose.

chat

After message was sent in the chat

  1. Instance name
  2. Sending player's name
  3. Message
  4. Platform ID of sender (if sent by a player, "-non-player-" otherwise)
  5. EntityID of sender (if sent by a player, -1 otherwise)
  6. Message target type

gmsg

After a game message was sent in the chat (e.g. player killed)

  1. Instance name
  2. Game message including player name(s)

remoteCommand

After a command was executed from a client

  1. Instance name
  2. Executed command
  3. Player name

telnetCommand

After a command was executed from a telnet session

  1. Instance name
  2. Executed command
  3. Client IP
Last modified 5 months ago Last modified on 14.11.2023 16:54:11

Attachments (3)

Download all attachments as: .zip