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?
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.
Decide what commands you want to use
Create a new alias/macro in Commandhelpers config.txt with the following syntax:
/macro_name = /command_1 /command_2
Do a server reload
In game, create a Autorun identifier for your macro:
/addacommand identifier_name macro_name
Now bind the identifier to run when a player joins:
/setjoincommand identifier_name
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.
Install plugin CommandHelper. Download it here: https://builds.enginehub.org/job/commandhelper
Restart your server to generate configuration
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!');
}
/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:
player_spawn
event as in the example above, but change the spawn location with modify_event('x', 123)
and similar for y/z)store_value
/ get_value
, as you can use them to store a counter value like 'player.respawnCount')Answered by LeigerGaming on September 27, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP