lia.command

Registration, parsing, and handling of commands.

Commands can be ran through the chat with slash commands or they can be executed through the console. Commands can be manually restricted to certain usergroups using a CAMI-compliant admin mod.

If you are looking for the command structure, you can find it here.

Functions

extractArgs(text)

Returns a table of arguments from a given string. Words separated by spaces will be considered one argument. To have an argument containing multiple words, they must be contained within quotation marks.

Parameters

  • text String

    String to extract arguments from

Returns

  • table

    Arguments extracted from string

Example Usage

PrintTable(lia.command.extractArgs("these are \"some arguments\""))
> 1 = these
> 2 = are
> 3 = some arguments

findFaction(client, name)

Attempts to find a faction by an identifier.

Parameters

  • client Player

    to give a notification to if the faction could not be found

  • name String

    Search query

Returns

  • table

    Faction that matches the given search query

  • OR
  • nil

    If a faction could not be found

findPlayer(client, name)

Attempts to find a player by an identifier. If unsuccessful, a notice will be displayed to the specified player. The search criteria is derived from lia.command.findPlayer.

Parameters

  • client

    Player The client to give a notification to if the player could not be found.

  • name

    string Search query

Returns

  • player or nil

    Player that matches the given search query, or nil if a player could not be found

See Also

findPlayerSilent(client, name)

Attempts to find a player by an identifier silently.

Parameters

  • client Player

    to give a notification to if the player could not be found

  • name String

    Search query

Returns

  • player or nil

    Player that matches the given search query, or nil if not found

hasAccess(client, command, data)

Internal

This is an internal function! You are able to use it, but you risk unintended side effects if used incorrectly.

Returns true if a player is allowed to run a certain command.

Parameters

  • client Player

    to check access for

  • command String

    Name of the command to check access for

  • data Table optional

    command data, if not provided, it will be fetched from lia.command.list

Returns

  • bool

    Whether or not the player is allowed to run the command

parse(client, text, realCommand, arguments)

Internal

This is an internal function! You are able to use it, but you risk unintended side effects if used incorrectly.

Parses a command from an input string and executes it.

Parameters

  • client Player

    The player who is executing the command

  • text String

    Input string to search for the command format

  • realCommand String optional

    Specific command to check for. If specified, it will only try to run this command

  • arguments Table optional

    Array of arguments to pass to the command. If not specified, it will try to extract them from the text

Returns

  • any

    bool Whether or not a command has been found and executed

Example Usage

lia.command.parse(player.GetByID(1), "/roll 10")

run(client, command, arguments)

Forces a player to execute a command by name.

Parameters

  • client Player

    who is executing the command

  • command String

    Full name of the command to be executed. This string gets lowered, but it's good practice to stick with the exact name of the command

  • arguments Table

    Array of arguments to be passed to the command

Example Usage

lia.command.run(player.GetByID(1), "Roll", {10})

send(command, ...)

Request the server to run a command. This mimics similar functionality to the client typing /CommandName in the chatbox.

Parameters

  • command String

    Unique ID of the command

  • ... Table

    Arguments to pass to the command

Example Usage

lia.command.send("roll", 10)

Tables

CommandList

A list of available commands for use within the game. Each command is represented by a table with fields defining its functionality.

Fields

  • charsetspeed

    Sets the speed of the character | Staff Command.

  • playglobalsound

    Plays a sound globally for all players | Staff Command.

  • playsound

    Plays a sound for the invoking player | Staff Command.

  • charsetscale

    Sets the scale of the character | Staff Command.

  • charsetjump

    Sets the jump height of the character | Staff Command.

  • charaddmoney

    Adds money to the character's account | Staff Command.

  • charban

    Bans a character from the server | Staff Command.

  • charsetdesc

    Sets the description of the character | Staff Command.

  • charsetname

    Sets the name of the character | Staff Command.

  • chargetmodel

    Sets the target model for a character | Staff Command.

  • charsetmodel

    Sets the model of the character | Staff Command.

  • charsetbodygroup

    Sets the bodygroup of the character | Staff Command.

  • charsetskin

    Sets the skin of the character | Staff Command.

  • chargetmoney

    Sets the target money for a character | Staff Command.

  • charsetmoney

    Sets the money of the character | Staff Command.

  • clearinv

    Clears the inventory of the character | Staff Command.

  • flaggive

    Gives a flag to a character | Staff Command.

  • flaggiveall

    Gives a flag to all characters | Staff Command.

  • flagtakeall

    Removes all flags from all characters | Staff Command.

  • flagtake

    Removes a flag from a character | Staff Command.

  • charkick

    Kicks a character from the server | Staff Command.

  • viewcoreinformation

    Displays core faction information | Staff Command.

  • charunban

    Unbans a character from the server | Staff Command.

  • flagpet

    Sets a character as a pet | Staff Command.

  • flagragdoll

    Sets a character as a ragdoll | Staff Command.

  • flags

    Displays all available flags | Staff Command.

  • freezeallprops

    Freezes all props on the map | Staff Command.

  • checkmoney

    Checks the money of a character | Staff Command.

  • status

    Displays your character's status information.

  • redownloadlightmaps

    Forces a redownload of lightmaps | Staff Command.

  • cleanitems

    Cleans up all dropped items on the map | Staff Command.

  • cleanprops

    Cleans up all props on the map | Staff Command.

  • forcesave

    Forces a save of server data | Staff Command.

  • cleannpcs

    Cleans up all NPCs on the map | Staff Command.

  • checkallmoney

    Checks the money of all characters | Staff Command.

  • return

    Returns to a previous position | Staff Command.

  • findallflags

    Finds all characters with a specific flag | Staff Command.

  • chargiveitem

    Gives an item to a character | Staff Command.

  • announce

    Announces a message to all players | Staff Command.

  • listents

    Lists all entities on the server | Staff Command.

  • flip

    Flips a coin.

  • liststaff

    Lists all staff members on the server.

  • listondutystaff

    Lists all staff members currently on duty.

  • listvip

    Lists all VIP members on the server.

  • listusers

    Lists all users on the server.

  • rolld

    Rolls a specific-sided die | Staff Command.

  • vieweventlog

    Views the server's event log | Staff Command.

  • editeventlog

    Edits the server's event log | Staff Command.

  • roll

    Rolls a die.

  • chardesc

    Sets the description of a character.

  • chargetup

    Sets the target usergroup of a character.

  • givemoney

    Gives money to a character.

  • bringlostitems

    Brings lost items back to the character's inventory | Staff Command.

  • carddraw

    Draws a card from a deck.

  • fallover

    Causes an entity to fall over.

  • getpos

    Gets the position of an entity.

  • entname

    Gets the name of an entity.

  • permflaggive

    Gives a flag permanently to a character | Staff Command.

  • permflagtake

    Removes a flag permanently from a character | Staff Command.

  • permflags

    Displays all permanent flags | Staff Command.

  • flagblacklist

    Adds a flag to the blacklist | Staff Command.

  • flagunblacklist

    Removes a flag from the blacklist | Staff Command.

  • flagblacklists

    Displays all flags on the blacklist | Staff Command.

  • dropmoney

    Drops money at the character's position.

  • membercount

    Displays the count of members in the server.

  • charsetattrib

    Sets the attributes of the character | Staff Command.

  • charaddattrib

    Adds attributes to the character | Staff Command.

  • viewBodygroups

    Displays the bodygroups of the character | Staff Command.

  • storagelock

    Locks the storage container.

  • trunk

    Accesses the trunk of a vehicle.

  • pktoggle

    Toggles the player's PK mode | Staff Command.

  • toggleraise

    Toggles whether the player raises their weapon.

  • fixpac

    Fixes the PAC3 outfit of the player | Staff Command.

  • pacenable

    Enables PAC3 for the player | Staff Command.

  • pacdisable

    Disables PAC3 for the player | Staff Command.

  • cleardecals

    Clears all decals from the world | Staff Command.

  • playtime

    Displays the playtime of the player | Staff Command.

  • 3dradioclean

    Cleans up 3D radio entities on the map | Staff Command.

  • auditmoney

    Audits the money transactions on the server | Staff Command.

  • report

    Reports a player to the staff team | Player Command.

  • spawnadd

    Adds a spawn point to the map | Staff Command.

  • respawn

    Respawns the player at their last location | Player Command.

  • spawnremove

    Removes a spawn point from the map | Staff Command.

  • returnitems

    Returns lost items to the player's inventory | Staff Command.

  • classwhitelist

    Whitelists a class for spawning | Staff Command.

  • plytransfer

    Transfers a player to a different server | Staff Command.

  • plywhitelist

    Whitelists a player for spawning | Staff Command.

  • plyunwhitelist

    Removes a player from the whitelist | Staff Command.

  • beclass

    Sets the player's class.

  • setclass

    Sets the player's class | Staff Command.

  • classunwhitelist

    Removes a class from the whitelist | Staff Command.

  • factionlist

    Displays a list of factions.

  • charvoiceunban

    Unbans a character's voice | Staff Command.

  • charvoiceban

    Bans a character's voice | Staff Command.

  • voicetoggle

    Toggles the player's voice | Staff Command.

  • banooc

    Bans OOC chat for the player | Staff Command.

  • unbanooc

    Unbans OOC chat for the player | Staff Command.

  • blockooc

    Blocks OOC chat for the player | Staff Command.

  • refreshfonts

    Refreshes the fonts for the player | Staff Command.

  • clearchat

    Clears the chat for the player | Staff Command.

  • doorsell

    Sells a door to the player | Staff Command.

  • doorsetlocked

    Sets the door as locked | Staff Command.

  • doorbuy

    Buys a door for the player | Staff Command.

  • doorsetunownable

    Sets the door as unownable | Staff Command.

  • doorsetownable

    Sets the door as ownable | Staff Command.

  • dooraddfaction

    Adds a faction to the door | Staff Command.

  • doorremovefaction

    Removes a faction from the door | Staff Command.

  • doorsetdisabled

    Sets the door as disabled | Staff Command.

  • doorsettitle

    Sets the title of the door | Staff Command.

  • doorsetparent

    Sets the parent of the door | Staff Command.

  • doorsetchild

    Sets the child of the door | Staff Command.

  • doorremovechild

    Removes the child from the door | Staff Command.

  • doorsetclass

    Sets the class of the door | Staff Command.

  • savedoors

    Saves the state of the doors | Staff Command.

  • legacylogs

    Views the legacy logs | Staff Command.

  • logger

    Views the server's log | Staff Command.

  • deletelogs

    Deletes the logs | Staff Command.

  • restockallvendors

    Restocks all vendors on the map | Staff Command.

  • resetallvendormoney

    Resets all vendor money on the map | Staff Command.

  • savevendors

    Saves the state of the vendors | Staff Command.

CommandStructure

When registering commands with lia.command.add, you'll need to pass in a valid command structure. This is simply a table with various fields defined to describe the functionality of the command.

Fields

  • onRun function

    This function is called when the command has passed all the checks and can execute. The arguments will be the calling player and subsequent argument list.

  • adminOnly bool default: false

    Provides an additional check to see if the user is an admin before running.

  • superAdminOnly bool default: false

    Provides an additional check to see if the user is a superadmin before running.

  • privilege string default: nil

    Manually specify a privilege name for this command. It will always be prefixed with "Commands - ". This is used in the case that you want to group commands under the same privilege, or use a privilege that you've already defined (i.e grouping /charban and /charunban into the Commands - Ban Characters privilege).

  • onCheckAccess function default: nil

    This callback checks whether or not the player is allowed to run the command. This callback should NOT** be used in conjunction with adminOnly or superAdminOnly, as populating those fields create a custom a OnCheckAccess callback for you internally. This is used in cases where you want more fine-grained access control for your command. Consider this example command:

    lia.command.add("slap", {
        adminOnly = true,
        privilege = "Can Slap",
        onRun = function(client, arguments)
            -- WHAM!
        end
    })
    

    Creates a new command.

  • command String

    Name of the command (recommended in UpperCamelCase)

  • data Table

    Data describing the command

See Also