TransWikia.com

Is there a bukkit plugin to run small scripts when players (re)spawn?

Arqade Asked on September 27, 2021

I’d like to setup my bukkit server to run a small script (like, giving players basic items) when players respawn or enter a world for the first time (or cause every 10th respawn to be in another place). Is there a plugin to do this with bukkit?

2 Answers

Yes, it is possible to run a script on certain events like respawning or first join.

You will need two plugins to do be able to do this: Autorun and CommandHelper. This will assume you have both fully installed.

For this example, I want two commands to run when a player logs on.

  1. Decide what commands you want to use

  2. Create a new alias/macro in Commandhelpers config.txt with the following syntax:

    /macro_name = /command_1 /command_2
    
  3. Do a server reload

  4. In game, create a Autorun identifier for your macro:

    /addacommand identifier_name macro_name
    
  5. Now bind the identifier to run when a player joins:

    /setjoincommand identifier_name
    
  6. Done.

This is a very simplified way of doing something like this, and both plugins are capable of much more. For instance Autorun can run commands when a player walks over a defined block; and Command helper can be used as an advanced scripting plugin.

Always make sure to read the instructions for both plugins before you start. However, you probably only need to read the beginners section of Commandhelper, as the rest covers very advanced scripting information.

Hope this answers your question.

Correct answer by Zachary on September 27, 2021

Since the other (marked correct) answer was written in 2012, CommandHelper now supports binding to events and therefore this is possible with only CommandHelper installed as a plugin.

  1. Install plugin CommandHelper. Download it here: https://builds.enginehub.org/job/commandhelper

  2. Restart your server to generate configuration

  3. Add the following to plugins/CommandHelper/main.ms

bind('player_spawn', null, null, @event) {
  // Do something here, like sending them a message.
  msg('Oops, that was silly of you!');
}
  1. Run /reloadaliases from the server console to activate it (or restart server)

CommandHelper uses a language called MethodScript, and the API documentation with a list of functions and how to use them can be found here: https://methodscript.com/docs/3.3.4/API.html

If you want to hook into different events (e.g. player_join as well), you may be interested in the Event API documentation: https://methodscript.com/docs/3.3.4/Event_API.html


Specific functions you may be interested in:

  • Giving players basic items (see pgive_item)
  • Change respawn location (intercept player_spawn event as in the example above, but change the spawn location with modify_event('x', 123) and similar for y/z)
  • Tracking if they are up to their 10th respawn (take a look at store_value / get_value, as you can use them to store a counter value like 'player.respawnCount')

Answered by LeigerGaming on September 27, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP