7

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
  • I don't believe there is, but perhaps with some more specifics, I could make it for you? What should the scripts be able to do? Feb 29 '12 at 22:38
  • @JakeKing giving the players a CommandBook kit for an easy example, and maybe a different one every 10th respawn. Or making them invulnerable for the first minute unless they leave the spawning region earlier, if you prefer a challenge ;-)
    – Zommuter
    Mar 1 '12 at 7:12
3

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.

2
  • Since this answer was written back in 2012, CommandHelper now has the ability to bind to events, so Autorun is no longer required. I'll submit a separate answer with details :) Mar 5 at 4:08
  • Also, the config.txt no longer exists and is replaced by aliases.msa instead - with the same functionality. Mar 5 at 13:01
2

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')
3
  • 1
    Great to know, thanks! Unfortunately I haven't used bukkit for years and can't test this... Maybe nowadays a simple command block can also achieve this 🤔
    – Zommuter
    Mar 5 at 7:52
  • @Zommuter - Yeah, I noticed it was an old question :) Thought I'd answer for the benefit of others that come across it. Command blocks are powerful, but I don't think they can hook into e.g. the player respawn event. Mar 5 at 13:03
  • 1
    I stand corrected! It looks like command blocks can detect a respawn - gaming.stackexchange.com/questions/336529/… - but CH would be more flexible. Depending on the use case, it's entirely possible command blocks could be enough though. Mar 5 at 13:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.