You are viewing an older version of the site. Click here to view
the latest version of this page. (This may be a dead link, if so, try the root page of the docs
here.)
== auto_include.ms ==
This file goes into the same directory as your aliases.msa file, and is normally used for [[Procedures]].
You can put useful commands that you want in every alias here. Here's a simple one, that is used by the example
scripts below
Copy Code
This lets you use the alias _bc in every alias, to do a Broadcast to the server, with a leading subject. You will see
it used below.
== Reset a Spleef Arena ==
This script lets anyone with the permission "command.fixspleef" reset a spleef arena. It also only lets it happen every
5 minutes, to stop people spamming it.
Copy Code
== Brand and Unbrand a user ==
Someone giving you problems? Want to make sure everyone else knows about it? Brand them. Note that this is written for use with [https://github.com/PEXPlugins/PermissionsEx/wiki/Commands PermissionsEx] and you'll have to change the prefix commands for your own permissions system.
Copy Code
You'll notice the last line relies on CH's greedy pattern matching. If someone tries /brand GrieferTest Is an idiot, it WON'T match on the /brand $user $brand alias, because it has too many parameters. It will, however, happily match on the bottom line, and give a warning to the person who tried to brand to only use one word.
== Sign Editing ==
Instead of handling permission checking yourself, you can let CommandHelper do it using an alias permission label. This will display an error if a restricted function, like set_sign_text(), is ran without permission. Ensure that your base group (in our case, 'default') has the permission 'commandhelper.alias.safe'
This is made from three commands. The first is when someone types /fixsign without any options. It tells them the parameters. The 'text' is gray as a hint that it's an optional parameter.
Copy Code
The second is when they use /fixsign 3 to delete the third line of the sign
Copy Code
And the third is to actually edit the sign. Note that the magic variable '$' is used here, which catches any number of words and returns it as a single string.
Copy Code
== Let users see their regions ==
This ties into WorldGuard, and uses the sk_region commands.
== Use BungeeCord with CommandHelper ==
Copy Code
Those two functions, when added to auto_include.ms, will let you do something like this:
Copy Code
You could also have a script that moves EVERYONE off the server, like this:
Copy Code
You would then type "/sendall lobby" to send all players on the current server to the lobby.
== A toggle to let admins and mods join the server unannounced ==
aliases.msa:
Copy Code
Main.ms:
Copy Code
Auto_include.ms:
Copy Code
== Simple mail system ==
-added by russellsayshi
In aliases.msa
Copy Code
In main.ms
Copy Code
== Pagination ==
In auto_include.ms
Copy Code
proc _bc(@label, @str) {
broadcast(colorize('&e[&a' . @label . '&e] &f' . @str));
}

1
2 {{keyword|proc}} {{function|_bc}}(@label, @str) {
3 {{function|broadcast}}({{function|colorize}}('&e[&a' . @label . '&e] &f' . @str));
4 }
*:/fixspleef = >>>
# This checks if they have the permission to run the command
if(!has_permission('command.fixspleef')) {
die('You do not have permission for this command');
}
# How many seconds they have to wait before being able
# to re-run fixspleef
@cooldown = 300;
# Ensure the persistent variable exists. If it doesn't, set it to 0.
if(is_null(get_value('spleef1_lastreset'))) {
store_value('spleef1_lastreset', 0);
}
# This makes the command only able to be used by a user in the world called: "world"
if(pworld() != 'world') {
die(color('RED').'You need to be in the normal world to use this command!');
}
# Get our persistent value
@lastreset = get_value('spleef1_lastreset');
# Note that time is in msec, not sec. So we always divide it by 1000.
if(@lastreset + @cooldown > time() / 1000) {
# then
msg('[ Error ] Less than 5 minutes since last reset.')
@timeleft = @lastreset + @cooldown - time() / 1000;
die('[ Error ] ' . @timeleft . ' seconds to go');
}
# Save the current time() (in seconds) in spleef1_lastreset
store_value('spleef1_lastreset', time() / 1000);
# The runas() command runs in a separate namespace. This NORMALLY doesn't
# cause problems, until you start caring about edge cases - This is one.
# Run the selection in the same namespace as the //set. Even though the
# user may have access to /region select, it won't work. Trust me. Do it
# this way.
# Note that you need to have your region defined as a one block high area, that
# will be set to snow. Change the region name below to whatever yours is.
sudo('/region select spleef-arena');
sudo('//set snow_block');
# Now we do a broadcast, using my handy-dandy broadcast procedure
# to tell everyone who did the reset. This is just in case someone
# tries to cheat, everyone gets to know about it.
_bc(Spleef, display_name() . ' has just reset the spleef arena with the /fixspleef command!');
<<<

01 *:/fixspleef = >>>
02 # This checks if they have the permission to run the command
03
04 {{keyword|if}}(!{{function|has_permission}}('command.fixspleef')) {
05 {{function|die}}('You do not have permission for this command');
06 }
07
08 # How many seconds they have to wait before being able
09
10 # to re-run fixspleef
11
12 @cooldown = 300;
13
14 # Ensure the persistent variable exists. If it doesn't, set it to 0.
15
16 {{keyword|if}}({{function|is_null}}({{function|get_value}}('spleef1_lastreset'))) {
17 {{function|store_value}}('spleef1_lastreset', 0);
18 }
19
20 # This makes the command only able to be used by a user in the world called: "world"
21
22 {{keyword|if}}({{function|pworld}}() != 'world') {
23 {{function|die}}({{function|color}}('RED').'You need to be in the normal world to use this command!');
24 }
25
26 # Get our persistent value
27
28 @lastreset = {{function|get_value}}('spleef1_lastreset');
29
30 # Note that time is in msec, not sec. So we always divide it by 1000.
31
32 {{keyword|if}}(@lastreset + @cooldown > {{function|time}}() / 1000) {
33 # then
34
35 {{function|msg}}('[ Error ] Less than 5 minutes since last reset.')
36 @timeleft = @lastreset + @cooldown - {{function|time}}() / 1000;
37 {{function|die}}('[ Error ] ' . @timeleft . ' seconds to go');
38 }
39
40 # Save the current time() (in seconds) in spleef1_lastreset
41
42 {{function|store_value}}('spleef1_lastreset', {{function|time}}() / 1000);
43
44 # The runas() command runs in a separate namespace. This NORMALLY doesn't
45
46 # cause problems, until you start caring about edge cases - This is one.
47
48 # Run the selection in the same namespace as the //set. Even though the
49
50 # user may have access to /region select, it won't work. Trust me. Do it
51
52 # this way.
53
54 # Note that you need to have your region defined as a one block high area, that
55
56 # will be set to snow. Change the region name below to whatever yours is.
57
58 {{function|sudo}}('/region select spleef-arena');
59 {{function|sudo}}('//set snow_block');
60
61 # Now we do a broadcast, using my handy-dandy broadcast procedure
62
63 # to tell everyone who did the reset. This is just in case someone
64
65 # tries to cheat, everyone gets to know about it.
66
67 {{function|_bc}}(Spleef, {{function|display_name}}() . ' has just reset the spleef arena with the /fixspleef command!');
68 <<<
*:/brand $user $brand = >>>
# run() still checks if the player has permission to run that command.
run('/pex user ' . $user . ' prefix &e[' . $brand . ']&8');
_bc('Branding', $user . ' has been branded ' . $brand);
<<<
*:/unbrand $user = >>>
run('/pex user ' . $user . ' prefix ""');
_bc('Branding', $user . ' has been unbranded');
<<<
*:/brand $user $brand $ = msg('You can only brand with a single word');

01 *:/brand $user $brand = >>>
02 # run() still checks if the player has permission to run that command.
03
04 {{function|run}}('/pex user ' . $user . ' prefix &e[' . $brand . ']&8');
05 {{function|_bc}}('Branding', $user . ' has been branded ' . $brand);
06 <<<
07
08 *:/unbrand $user = >>>
09 {{function|run}}('/pex user ' . $user . ' prefix ""');
10 {{function|_bc}}('Branding', $user . ' has been unbranded');
11 <<<
12
13 *:/brand $user $brand $ = {{function|msg}}('You can only brand with a single word');
safe:/fixsign = >>>
msg(color('WHITE') . 'Usage: ' . color('RED') . '/fixsign lineno' . color('GRAY') . ' text');
<<<

1 safe:/fixsign = >>>
2 {{function|msg}}({{function|color}}('WHITE') . 'Usage: ' . {{function|color}}('RED') . '/fixsign lineno' . {{function|color}}('GRAY') . ' text');
3 <<<
safe:/fixsign $line = >>>
if(!is_integer($line)) {
die($line . ' should be a line number');
}
@lineno = $line;
@lineno--;
if($line >= 5 || $line <= 0) {
die('Line number ' . $line . ' should be between 1 and 4');
}
@loc = pcursor();
if(!is_sign_at(@loc)) {
die('Your crosshairs are not looking at a sign. Sorry.');
}
@text = get_sign_text(@loc);
@text[@lineno] = '';
set_sign_text(@loc, @text);
<<<

01 safe:/fixsign $line = >>>
02 {{keyword|if}}(!{{function|is_integer}}($line)) {
03 {{function|die}}($line . ' should be a line number');
04 }
05 @lineno = $line;
06 @lineno--;
07 {{keyword|if}}($line >= 5 || $line <= 0) {
08 {{function|die}}('Line number ' . $line . ' should be between 1 and 4');
09 }
10 @loc = {{function|pcursor}}();
11 {{keyword|if}}(!{{function|is_sign_at}}(@loc)) {
12 {{function|die}}('Your crosshairs are not looking at a sign. Sorry.');
13 }
14 @text = {{function|get_sign_text}}(@loc);
15 @text[@lineno] = '';
16 {{function|set_sign_text}}(@loc, @text);
17 <<<
safe:/fixsign $line $ = >>>
if(!is_integer($line)) {
die($line . ' should be a line number');
}
@lineno = $line;
@lineno--;
if($line >= 5 || $line <= 0) {
die('Line number ' . $line . ' should be between 1 and 4');
}
@loc = pcursor();
if(!is_sign_at(@loc)) {
die('Your crosshairs are not looking at a sign. Sorry.');
}
@text = get_sign_text(@loc);
@text[@lineno] = $;
set_sign_text(@loc, @text);
<<<

01 safe:/fixsign $line $ = >>>
02 {{keyword|if}}(!{{function|is_integer}}($line)) {
03 {{function|die}}($line . ' should be a line number');
04 }
05 @lineno = $line;
06 @lineno--;
07 {{keyword|if}}($line >= 5 || $line <= 0) {
08 {{function|die}}('Line number ' . $line . ' should be between 1 and 4');
09 }
10 @loc = {{function|pcursor}}();
11 {{keyword|if}}(!{{function|is_sign_at}}(@loc)) {
12 {{function|die}}('Your crosshairs are not looking at a sign. Sorry.');
13 }
14 @text = {{function|get_sign_text}}(@loc);
15 @text[@lineno] = $;
16 {{function|set_sign_text}}(@loc, @text);
17 <<<
proc _writeUTF(@ba, @str) {
@len = length(@str);
if (@len > 200) {
die('String too long');
}
ba_put_byte(@ba, 0);
ba_put_byte(@ba, @len);
ba_put_bytes(@ba, string_get_bytes(@str, 'ascii'));
}
proc _changeserver(@player, @server) {
@ba = byte_array();
_writeUTF(@ba, 'Connect');
_writeUTF(@ba, @server);
bind(player_quit, array(priority: normal, id: 'pq-'.@player), array(player: @player), @event) {
modify_event('message', @event['player'] . ' has left for another realm');
unbind('pq-' . @event['player']);
}
send_plugin_message(@player, 'BungeeCord', @ba);
}

01 {{keyword|proc}} {{function|_writeUTF}}(@ba, @str) {
02 @len = {{function|length}}(@str);
03 {{function|if}} (@len > 200) {
04 {{function|die}}('String too long');
05 }
06 {{function|ba_put_byte}}(@ba, 0);
07 {{function|ba_put_byte}}(@ba, @len);
08 {{function|ba_put_bytes}}(@ba, {{function|string_get_bytes}}(@str, 'ascii'));
09 }
10
11 {{keyword|proc}} {{function|_changeserver}}(@player, @server) {
12 @ba = {{function|byte_array}}();
13 {{function|_writeUTF}}(@ba, 'Connect');
14 {{function|_writeUTF}}(@ba, @server);
15 {{keyword|bind}}(player_quit, {{function|array}}(priority: normal, id: 'pq-'.@player), {{function|array}}(player: @player), @event) {
16 {{function|modify_event}}('message', @event['player'] . ' has left for another realm');
17 {{function|unbind}}('pq-' . @event['player']);
18 }
19 {{function|send_plugin_message}}(@player, 'BungeeCord', @ba);
20 }
*:/pvp = >>>
_changeserver(player(), 'pvp');
<<<

1 *:/pvp = >>>
2 {{function|_changeserver}}({{function|player}}(), 'pvp');
3 <<<
*:/sendall $world = >>>
if(has_permission('command.sendall')) {
die('You do not have permission to send all players.');
}
foreach(@player in all_players()) {
_changeserver(@player, $world);
}
<<<

1 *:/sendall $world = >>>
2 {{keyword|if}}({{function|has_permission}}('command.sendall')) {
3 {{function|die}}('You do not have permission to send all players.');
4 }
5 {{keyword|foreach}}(@player {{keyword|in}} {{function|all_players}}()) {
6 {{function|_changeserver}}(@player, $world);
7 }
8 <<<
aliases.msa:
*:/silentjoin [$player] [$] = >>>
_verify_mod() # A procedure that checks if the user has the custom permission that all moderators have
@array = get_value('silentjoin.players');
if( is_null(@array) ) {
@array = array();
} else {
array_sort(@array, 'STRING_IC');
}
if(to_lower($player) == 'list') { # This shows a list of all people with it enabled, hopefully you don't a player called 'list'!
msg(color('DARK_GREEN') . 'Players with Silent Join Enabled:');
msg(color('YELLOW') . array_implode(@array, ', '));
die();
}
if($player == '') {
@player = to_lower(player());
} else {
_verify_op();
@player = to_lower($player);
}
if(array_contains(@array, @player)) { # Remove from the list.
array_remove_values(@array, @player);
store_value('silentjoin.players', @array);
@bcmsg = colorize('&c' . @player . ' &ehas had Silent Join &cdisabled');
msg(@bcmsg)
console(@bcmsg . colorize('&e by &5' . player()));
} else { # Add to the list.
@array[] = @player;
store_value('silentjoin.players', @array);
@bcmsg = colorize('&c'. @player. ' &ehas had Silent Join &a'. 'enabled');
msg(@bcmsg)
console(@bcmsg . colorize('&e by &5' . player()));
}
<<<

01 *:/silentjoin [$player] [$] = >>>
02 {{function|_verify_mod}}() # A procedure that checks if the user has the custom permission that all moderators have
03
04
05 @array = {{function|get_value}}('silentjoin.players');
06 {{keyword|if}}( {{function|is_null}}(@array) ) {
07 @array = {{function|array}}();
08 } {{keyword|else}} {
09 {{function|array_sort}}(@array, 'STRING_IC');
10 }
11
12 {{keyword|if}}({{function|to_lower}}($player) == 'list') { # This shows a list of all people with it enabled, hopefully you don't a player called 'list'!
13
14 {{function|msg}}({{function|color}}('DARK_GREEN') . 'Players with Silent Join Enabled:');
15 {{function|msg}}({{function|color}}('YELLOW') . {{function|array_implode}}(@array, ', '));
16 {{function|die}}();
17 }
18
19 {{keyword|if}}($player == '') {
20 @player = {{function|to_lower}}({{function|player}}());
21 } {{keyword|else}} {
22 {{function|_verify_op}}();
23 @player = {{function|to_lower}}($player);
24 }
25
26 {{keyword|if}}({{function|array_contains}}(@array, @player)) { # Remove from the list.
27
28 {{function|array_remove_values}}(@array, @player);
29 {{function|store_value}}('silentjoin.players', @array);
30
31 @bcmsg = {{function|colorize}}('&c' . @player . ' &ehas had Silent Join &cdisabled');
32 {{function|msg}}(@bcmsg)
33 {{function|console}}(@bcmsg . {{function|colorize}}('&e by &5' . {{function|player}}()));
34 } {{keyword|else}} { # Add to the list.
35
36 @array[] = @player;
37 {{function|store_value}}('silentjoin.players', @array);
38
39 @bcmsg = {{function|colorize}}('&c'. @player. ' &ehas had Silent Join &a'. 'enabled');
40 {{function|msg}}(@bcmsg)
41 {{function|console}}(@bcmsg . {{function|colorize}}('&e by &5' . {{function|player}}()));
42 }
43 <<<
bind(player_join, null, null, @event) {
### Change the default join message ###
modify_event('message', color('GRAY') . 'Player Join: ' . color('YELLOW') . player());
@array = get_value('silentjoin.players');
if( is_null(@array) ) {
@array = array();
}
if(array_contains_ic(@array, player())) {
modify_event('message', '');
_bc_mods(color('AQUA') . 'Silent Join: ' . color('YELLOW') . player());
}
}
bind(player_quit, null, null, @event) {
### Change the default quit message ###
modify_event('message', color('GRAY') . 'Player Quit: ' . color('YELLOW') . player());
@array = get_value('silentjoin.players');
if( is_null(@array) ) {
@array = array();
}
if(array_contains_ic(@array, player())) {
modify_event('message', '');
_bc_mods(color('AQUA') . 'Silent Quit: ' . color('YELLOW') . player());
}
}

01 {{keyword|bind}}(player_join, {{keyword|null}}, {{keyword|null}}, @event) {
02 ### Change the default join message ###
03
04 {{function|modify_event}}('message', {{function|color}}('GRAY') . 'Player Join: ' . {{function|color}}('YELLOW') . {{function|player}}());
05
06 @array = {{function|get_value}}('silentjoin.players');
07 {{keyword|if}}( {{function|is_null}}(@array) ) {
08 @array = {{function|array}}();
09 }
10
11 {{keyword|if}}({{function|array_contains_ic}}(@array, {{function|player}}())) {
12 {{function|modify_event}}('message', '');
13 {{function|_bc_mods}}({{function|color}}('AQUA') . 'Silent Join: ' . {{function|color}}('YELLOW') . {{function|player}}());
14 }
15 }
16
17 {{keyword|bind}}(player_quit, {{keyword|null}}, {{keyword|null}}, @event) {
18 ### Change the default quit message ###
19
20 {{function|modify_event}}('message', {{function|color}}('GRAY') . 'Player Quit: ' . {{function|color}}('YELLOW') . {{function|player}}());
21
22 @array = {{function|get_value}}('silentjoin.players');
23 {{keyword|if}}( {{function|is_null}}(@array) ) {
24 @array = {{function|array}}();
25 }
26
27 {{keyword|if}}({{function|array_contains_ic}}(@array, {{function|player}}())) {
28 {{function|modify_event}}('message', '');
29 {{function|_bc_mods}}({{function|color}}('AQUA') . 'Silent Quit: ' . {{function|color}}('YELLOW') . {{function|player}}());
30 }
31 }
proc _bc_mods(@str) {
foreach(@user in all_players()) {
if(has_permission(@user, 'ch_mod')) { # The custom permission we gave the mods group.
tmsg(@user, @str);
}
}
}
proc _verify_mod(@msg = 'You do not have permission to run this command.') {
if(!has_permission('ch_mod')) {
die(color('GREEN') . @msg));
}
}

01 {{keyword|proc}} {{function|_bc_mods}}(@str) {
02 {{keyword|foreach}}(@user {{keyword|in}} {{function|all_players}}()) {
03 {{keyword|if}}({{function|has_permission}}(@user, 'ch_mod')) { # The custom permission we gave the mods group.
04
05 {{function|tmsg}}(@user, @str);
06 }
07 }
08 }
09
10 {{keyword|proc}} {{function|_verify_mod}}(@msg = 'You do not have permission to run this command.') {
11 {{keyword|if}}(!{{function|has_permission}}('ch_mod')) {
12 {{function|die}}({{function|color}}('GREEN') . @msg));
13 }
14 }
*:/mail [$action] [$] = >>>
if($action == 'read') { #checking if they do /mail read
if(is_null(get_value('mail', player()))) { # the mail is stored in mail.playername
msg(color('GREEN') . 'No new mail.');
} else {
msg(color('GREEN') . get_value('mail', player()));
clear_value('mail', player());
msg(color('GREEN') . 'Your mail has been marked as read.');
}
} else {
if($ == '') { # if no message is specified
msg(color('RED') . 'Usage: /mail <player> <message>');
msg(color('RED') . 'To see your mail, do /mail read');
} else {
@player = $action;
if(ponline(@player)) { # if the player is online, notify them of their new message
tmsg($action, color('GREEN') . 'New mail message. Type /mail read to see your messages.');
}
if(is_null(get_value('mail', @player))) {
store_value('mail', @player, ' ' . player() . ': ' . $);
} else {
store_value('mail', @player, get_value('mail', @player) . '\n' . player() . ': ' . $);
}
}
}
<<<

01 *:/mail [$action] [$] = >>>
02 {{keyword|if}}($action == 'read') { #checking if they do /mail read
03
04 {{keyword|if}}({{function|is_null}}({{function|get_value}}('mail', {{function|player}}()))) { # the mail is stored in mail.playername
05
06 {{function|msg}}({{function|color}}('GREEN') . 'No new mail.');
07 } {{keyword|else}} {
08 {{function|msg}}({{function|color}}('GREEN') . {{function|get_value}}('mail', {{function|player}}()));
09 {{function|clear_value}}('mail', {{function|player}}());
10 {{function|msg}}({{function|color}}('GREEN') . 'Your mail has been marked as read.');
11 }
12 } {{keyword|else}} {
13 {{keyword|if}}($ == '') { # if no message is specified
14
15 {{function|msg}}({{function|color}}('RED') . 'Usage: /mail <player> <message>');
16 {{function|msg}}({{function|color}}('RED') . 'To see your mail, do /mail read');
17 } {{keyword|else}} {
18 @player = $action;
19 {{keyword|if}}({{function|ponline}}(@player)) { # if the player is online, notify them of their new message
20
21 {{function|tmsg}}($action, {{function|color}}('GREEN') . 'New mail message. Type /mail read to see your messages.');
22 }
23 {{keyword|if}}({{function|is_null}}({{function|get_value}}('mail', @player))) {
24 {{function|store_value}}('mail', @player, ' ' . {{function|player}}() . ': ' . $);
25 } {{keyword|else}} {
26 {{function|store_value}}('mail', @player, {{function|get_value}}('mail', @player) . '
' . {{function|player}}() . ': ' . $);
27 }
28 }
29 }
30 <<<
bind(player_join, null, null, @event) {
if(is_null(get_value('mail', player()))) {
msg(color('GRAY') . 'You have no new mail.');
} else {
msg(color('GREEN') . 'You have new mail! Type /mail read to see your messages.');
}
}

1 {{keyword|bind}}(player_join, {{keyword|null}}, {{keyword|null}}, @event) {
2 {{keyword|if}}({{function|is_null}}({{function|get_value}}('mail', {{function|player}}()))) {
3 {{function|msg}}({{function|color}}('GRAY') . 'You have no new mail.');
4 } {{keyword|else}} {
5 {{function|msg}}({{function|color}}('GREEN') . 'You have new mail! Type /mail read to see your messages.');
6 }
7 }
proc _paginate(@title, @list, @page, @perpage=15) {
### Check if @list is empty and sorts alphabetically ###
if( @list == null ) {
@list = array();
}
array_sort(@list, 'STRING_IC');
### Checks to see if any values would appear on the specified page, and if so, ###
### get all values from that page and push them to the array, else get page 1 ###
@maxpage = ceil(array_size(@list) / @perpage);
if(!is_integral(@page) || @maxpage == 0) {
@maxpage = 1;
}
### If the page number is less than 1, or higher than the maximum page ###
if(@page < 1 || @page > @maxpage) {
die(colorize('&4Error: &cPlease supply a valid page number between 1 and @{maxpage}...'));
}
@finalList = array();
for(@i = (@page - 1) * @perpage, @i < (@page * @perpage), @i++) {
if(array_size(@list) > @i) {
array_push(@finalList, @list[@i]);
}
}
msg(colorize("&5The list of @title (". array_size(@list). "): &7(Page: @{page}/@{maxpage})"));
msg(colorize('&6'. array_implode(@finalList, '&7, &6')));
}

01 {{keyword|proc}} {{function|_paginate}}(@title, @list, @page, @perpage=15) {
02
03 ### Check if @list is empty and sorts alphabetically ###
04
05 {{keyword|if}}( @list == {{keyword|null}} ) {
06 @list = {{function|array}}();
07 }
08
09 {{function|array_sort}}(@list, 'STRING_IC');
10
11 ### Checks to see if any values would appear on the specified page, and if so, ###
12
13 ### get all values from that page and push them to the array, else get page 1 ###
14
15 @maxpage = {{function|ceil}}({{function|array_size}}(@list) / @perpage);
16 {{keyword|if}}(!{{function|is_integral}}(@page) || @maxpage == 0) {
17 @maxpage = 1;
18 }
19
20 ### If the page number is less than 1, or higher than the maximum page ###
21
22 {{keyword|if}}(@page < 1 || @page > @maxpage) {
23 {{function|die}}({{function|colorize}}('&4Error: &cPlease supply a valid page number between 1 and @{maxpage}...'));
24 }
25
26 @finalList = {{function|array}}();
27
28 {{keyword|for}}(@i = (@page - 1) * @perpage, @i < (@page * @perpage), @i++) {
29 {{keyword|if}}({{function|array_size}}(@list) > @i) {
30 {{function|array_push}}(@finalList, @list[@i]);
31 }
32 }
33
34 {{function|msg}}({{function|colorize}}("&5The list of @title (". {{function|array_size}}(@list). "): &7(Page: @{page}/@{maxpage})"));
35 {{function|msg}}({{function|colorize}}('&6'. {{function|array_implode}}(@finalList, '&7, &6')));
36 }
Find a bug in this page? Edit this page yourself, then submit a pull request.