Warmups and Cooldowns

Overview

In ScrollingMenuSign v2.1.1 and later, it is possible to run commands with a warmup, i.e. a configurable delay between clicking the menu item and actually running the command, and with a cooldown, i.e. enforcing a given time between re-running a command.

Warmups

To run a command with a warm-up, use the special AFTER keyword, e.g.

/sms add mymenu "Delayed Hello" "AFTER 40 \\hello"

The delay amount is in server ticks; there are 20 ticks per second, so the above delay of 40 means a delay of 2 seconds.

Warm-up Applications

Warm-ups may be necessary if you need to run a command which pops up an inventory window, and you're running the command from a inventory view. It can be problematic to pop up an inventory when another inventory is already open. An example of this is the /market listings command from Global Market plugin.

/sms add mymenu "Market Listings" "AFTER 2 /market listings"

A delay of at least 2 ticks appears to be necessary here.

Another possible use is allowing players to use warps, but with an activation time, e.g.

/sms add mymenu "Go Home" "\\Teleporting in 5 seconds... && AFTER 100 /@warp home"

(here the /warp command would not normally be available to players, hence the use of permission elevation - see Command Parser)

Cooldowns

To run a command with a cooldown, use the special COOLDOWN keyword:

/sms add mymenu "Free Food" "COOLDOWN food 2hrs $baked_potato,-4 \\Have some food! $$ \\&6You must wait before doing that again"

Notes:

  • Each cooldown has a name (food in the above example). Multiple commands can share the same named cooldown.
  • The cooldown duration can be specified in a variety of units: milliseconds (ms), seconds (s), minutes (min), hours (h), days (d), or even weeks (w). Don't put any whitespace between the number and the unit. If no unit is given, the duration will be in seconds.
  • If the cooldown is not yet finished, no error will be given, but the command won't run and will be considered restricted; this means you can run a custom error command by using "$$", as in the example above. See Command Parser for more examples of command chaining.
  • You can also have global cooldowns, which apply to all players, by putting "global:" in front of the cooldown name, e.g.:
/sms add mymenu "Free Food" "COOLDOWN global:food 30min $baked_potato,-4 \\Have some food! $$ \\&6No food available now, sorry"

Cooldowns are persistent across server restarts; the cooldown timer is ticking even while the server is not running (e.g. if a player runs a command on a 2 hour cooldown, then the server goes down for an hour, that player will have 1 hour remaining on the cooldown when the server comes back up).


Comments

Posts Quoted:
Reply
Clear All Quotes