Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Function that allows you to loop through a given string's characters like
- // looplist does for an item's list, usage: /loopchar <var> [action]
- loopchar = [
- loop $arg1 (strlen $arg2) [
- @arg1 = (substr $arg2 (getalias [@arg1]) 1)
- @arg3
- ]
- ]
- // Function to add 1 to given value and alias it back, usage: /++ <var>
- "++" = [$arg1 = (+ (getalias $arg1) 1)]
- // Conditional function that operates based on flags, and their order before executing given content.
- // usage: cmd <flags> [content]
- // example: cmd cmp [say hi] -- would say "hi" when you are connected, have master rights, and are playing.
- // note 1: each flag that comes back negative stops the script, to avoid notification spam.
- // note 2: the order the flags are used plays an important role in determining which error comes first.
- // note 3: all flags must be tested positive before the content is executed.
- cmd = [
- _cmd_tmp = 0
- loopchar f $arg1 [
- if (> $tmp -1) [
- cases $f "m" [
- if (ismaster (getclientnum)) [++ _cmd_tmp] [
- error "^f3You do not have master rights!"
- _cmd_tmp = -1
- ]
- ] "a" [
- if (isadmin (getclientnum)) [++ _cmd_tmp] [
- error "^f3You do not have admin rights!"
- _cmd_tmp = -1
- ]
- ] "s" [
- if (isspectator (getclientnum)) [++ _cmd_tmp] [
- error "^f3You can only do this while spectating!"
- _cmd_tmp = -1
- ]
- ] "p" [
- if (! (|| (isspectator (getclientnum)) $editing)) [++ _cmd_tmp] [
- error "^f3You can only do this while playing!"
- _cmd_tmp = -1
- ]
- ] "c" [
- if (isconnected) [++ _cmd_tmp] [
- error "^f3You can only do this while online"
- _cmd_tmp = -1
- ]
- ] "o" [
- if (! (isconnected)) [++ _cmd_tmp] [
- error "^f3You can only do this while offline"
- _cmd_tmp = -1
- ]
- ] "e" [
- if $editing [++ _cmd_tmp] [
- error "^f3You can only do this while in editmode!"
- _cmd_tmp = -1
- ]
- ] () [error "^f3Invalid command flag:" $f]
- ]
- ]
- if (= $_cmd_tmp (strlen $arg1)) arg2
- ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement