Got a question that the wiki doesn't answer? Ask on the forum (preferred), or join us on IRC.

CreeperHost
About the ads

CommandHelper/Example Script

From EngineHub.org Wiki
Jump to: navigation, search
#=========================================================================#
#
# Command Helper sample config file
#
#=========================================================================#

#lines that start with # are comments

#Essentials style /i command, with material name lookup
# Note that the second variable $qty is optional, and if no value
# is given, 1 is the default. The function player() returns the
# name of this player, and data_values() turns "stone" into 1
/i $data [$qty=1] = /give player() data_values($data) $qty
###

#Give the player a diamond pickaxe, shovel, and axe
# Note that commands are separated by \ and this creates a macro
/kit diamond = /give player() data_values('diamond_pickaxe') 1 \
	/give player() data_values('diamond_spade') 1 \
	/give player() data_values('diamond_axe') 1
###

#Give the player 64 each of gold tools
# Note that the data_values function uses the enum values of
# the material
/kit gold = /give player() data_values('gold_pickaxe') 64 \
	/give player() data_values('gold_spade') 64 \
	/give player() data_values('gold_axe') 64
###

#Sets the time on the server, and uses english words to set the time
#If the english word isn't "day" or "night", it uses the number
# Note that the equals function returns a true value if the two
# parameters are the same, and if() runs the second argument if the
# first argument is true, and the third argument if it is false.
# To make an "if else" statement, you can nest if() calls, as shown
# here.
/time $time = /time set if(equals($time, 'day'), 1, if(equals($time, 'night'), 13500, $time))
###

#Better tp. If "/tp name" is used, it implies "/tp thisplayer name"
#but if "/tp name1 name2" is used, it implies "/tp name1 name2"
/tp $p1 [$p2=''] = /tp if(equals($p2, ''), player(), $p1) if(equals($p2, ''), $p1, $p2)
###

#Simple alias for /tell
# The special variable "$" must be the last variable, and it matches all
# the arguments from that point on
/msg $player $ = /tell $player $
###

#Simple alias for /save-all
# Super simple aliases can be error proofed by matching all arguments, then
# not using them. Note that this will result in a warning, but it will
# compile fine.
/save $ = /save-all
###

#Shows help information
# This demonstrates how to use die() and msg(). They work basically the same, except
# die() kills the command if evaluated. They both send a message to the player.
/help [$cmd=''] = if(equals($cmd, ''), die('Do you need halp?'), if(equals($cmd, 'commandhelper'), msg('The best plugin ever!'), ''))
###

#Demonstrates the for function, as well as ivars
#Lists all players on the server
/list = >>>
    #Initialize an empty string
    assign(@pl, '')
    assign(@ap, all_players())
    #loop through the array stored in @ap, from 0 to one less than the size of the array
    for(assign(@i, 0), lt(@i, array_size(@ap)), assign(@i, add(@i, 1)),
        #append our player's name to the end of @pl string
        assign(@pl, concat(@pl, array_get(@ap, @i), ' '))
    )
    #output the string
    msg(@pl)
<<<



You can also look at Advanced Scripts for further information.



Namespaces

Variants
Actions