Code Monkey home page Code Monkey logo

phanactions's Introduction

Phanactions

An extension to CommandHelper providing access to features of drtshock's Factions.

DOWNLOADS

Documentation

Add the following to main.ms to give yourself a /docs command that tabcompletes with functionnames and classes. For example, "/docs FactionsPlugin" will return a list of all the Factions functions, but you can see all functions containing "faction" by typing "/docs faction" and hitting tab. "/docs faction_finfo" will give you the documentation for the faction_finfo function.

The below can also be found on the forums.

# I do this as a cache because there are a lot of functions,
# this way I only have to use get_functions() once
@gfuncs = get_functions()
export('gfuncs', @gfuncs)
export('funclasses', array_keys(@gfuncs))
@funcs = array()
foreach(@gfuncs, @fc, @fa,
    foreach(@fa, @f,
        array_push(@funcs, @f)
    )
)
export('funcs', @funcs)
 
register_command('docs', array(
    description: 'Shows the documentation for a given CommandHelper function',
    permission: 'commandhelper.*',
    noPermMsg: color(c).'This is not the command you are looking for',
    usage: colorize('&aUsage&f: /docs [FunctionType|function_name]\n&aExample&f: /docs\n&aExample&f: /docs PlayerManagement\n&aExample&f: /docs ploc'),
    aliases: array('doc', 'func', 'funcs'),
    executor: closure(@al, @p, @args, @cmd,
        @gfuncs = import('gfuncs')
        @fcs = import('funclasses')
        @funcs = import('funcs')
        if(array_size(@args) == 0) {
            tmsg(@p, colorize('&aFunctionTypes&f: &e'.array_implode(@fcs, '&f, &e')))
            return(false)
        } else if (array_size(@args) == 1) {
            @choice = to_lower(@args[0])
            foreach(@fcs, @fc,
                if (@choice == to_lower(@fc)) {
                    tmsg(@p, colorize('&6'.@fc.'&f: &b'.array_implode(@gfuncs[@fc], '&f, &b')))
                    return(true)
                }
            )
            if (array_contains(@funcs, @choice)) {
                tmsg(@p, colorize('&2'.@choice.'&f:'))
                tmsg(@p, colorize('&aReturn&f: '.reflect_docs(@choice, return)))
                tmsg(@p, colorize('&aArgs&f: '.reflect_docs(@choice, args)))
                tmsg(@p, colorize('&aDescription&f: '.reflect_docs(@choice, description)))
            } else {
                tmsg(@p, 'You entered \''.@choice.'\'')
                tmsg(@p, 'Use \'/docs\' to get a list of valid function names')
            }
        } else {
            return(false)
        }
    ),
    tabcompleter: closure(@al, @p, @args, @cmd,
        @funcs = import('funcs')
        @gfuncs = import('gfuncs')
        @fcs = import('funclasses')
        if(array_size(@args) == 1) {
            @c = to_lower(@args[0])
            @returnable = array()
            foreach(@fcs, @fc,
                if(string_position(to_lower(@fc), @c) != -1) {
                    array_push(@returnable, @fc)
                }
            )
            foreach(@funcs, @f,
                if(string_position(@f, @c) != -1) {
                    array_push(@returnable, @f)
                }
            )
            return(@returnable)
        } else {
            return(array())
        }
    )
))

phanactions's People

Contributors

jb-aero avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.