| Date uploaded | a year ago |
| Version | 1.0.0 |
| Download link | kestrel-Chat_Commands-1.0.0.zip |
| Downloads | 117 |
| Dependency string | kestrel-Chat_Commands-1.0.0 |
This mod requires the following mods to function
BepInEx-BepInExPack
BepInEx pack for Mono Unity games. Preconfigured and ready to use.
Preferred version: 5.4.2100straftatmodding-MyceliumNetworking
An easy to use networking library for sending custom RPCs through Steam.
Preferred version: 1.1.15README
Chat Commands
This mod adds a command system to the chat, with syntax similar to that of the console in source games.
What does the mod do?
This mod is mostly intended to be a library mod for other mod developers to add their own commands as an easy to implement way to run code in their mods. However, I have included a few builtin commands! Some features of them you might find helpful include:
- Spawning any weapon while in exploration mode
- Ignoring players, hiding their chat messages from you
- Banning players from your lobbies, instantly kicking them if they join
- Changing a few settings like brightness or sensitivity without opening the settings menu~ and setting them to exact values instead of using a slider
- Binding any command or sequence of commands to a key or the mousewheel
Syntax and basic guide to commands
To begin a command, enter a slash (/) into chat. you can also hit the slash key and the chat box will open with a slash already in it. After the slash, enter the command name, then the command's parameters seperated by spaces.
To view a list of all commands currently registered, run the command help (or its alias h). if you want to
see help text for a particular command, or a particular category of commands, enter the command name or category
name as a parameter after the command name.
If you want to enter something with spaces in it as a parameter, e.g. a sentence, surround the parameter with quotation marks (" or ') to create a string (a sequence of characters). If you want to enter another string inside a string, you can either use the type of quotation mark you did not use for the outer string, or enter a backslash (\) before quotation marks you use inside the string.
Some commands may have optional parameters. These parameters have a default value that will be chosen if you do not enter a value for them. Optional parameters will always appear at the end of a command's parameter list.
You can run multiple commands in one go by separating them with a semicolon (;). You can also take the output of
a command and directly append it to the parameters of the following command by putting a pipe (|) after the first
command. This allows for many complicated and advanced setups, for example gamma | add 0.5 | gamma | concat 'gamma: ' | echo. This command will get the current brightness setting (gamma with no parameters), send it
to add as the second parameter, adding 0.5 to the value, send the value back to gamma as a parameter, setting
the brightness to the value, then send the new brightness value to concat as the second parameter, joining it to
the string 'gamma: ', and finally send the output of that to echo, printing the result. Altogether, this results
in the brightness setting being incremented by 0.5 and some handy feedback being sent in the chat to show the new
value. I personally have this command bound to a key, as well as one that reduces the brightness by 0.5 (i'll leave
that one to you to figure out :3), as a handy way to quickly change brightness while in a game.
For any further help, you can find me @sneaky_kestrel in the #modding channel in the official straftat discord!
For mod developers~ getting started
- Download the zip from the Thunderstore page, take out
ChatCommands.dll, put it somewhere safe and then add a reference to it in your project. - Add a
[BepInDependency(ChatCommands.PluginInfo.PLUGIN_GUID)]attribute to your main plugin class - If you are planning to upload your mod to Thunderstore, add the package's dependency string, that can be found on the Thunderstore page, to your manifest.json.
- Call
CommandRegistry.RegisterCommandsFromAssembly()in your plugin's startup logic.
Creating Commands
To create a command, add the [Command] attribute to any static method. The attribute has a few parameters:
name: Self explanatory. the name of your command.description: A short description of your command and what it does~ this will be shown in the output ofhelp.flags: Flags that define extra behaviour your command requires, or how it should be used. Not required, and defaults toCommandFlags.None. This is a flags enum, so multiple flags can be applied with a logical or.
The return value of a command will be output to chat by default~ if you'd like to return a value but wouldn't
like it to be printed you can add CommandFlags.Silent to your command.
By default, the following types are supported as parameters for commands. See below on how to add support for custom types.
- Any system type that implements
IConvertible UnityEngine.KeyCode~ also supports the standard source engine key namesbool~ a custom parser that also parses numbers i.e. 1 -> true, 0 -> false.Vector2&Vector3
Aliases
Aliases can be added to your commands with the [CommandAliases] attribute. Apply this to the method and enter
any aliases you want to be associated with your command as parameters.
Categories
By default, your command will be in the category Misc. If you wish to specify a category name for your commands,
put a [CommandCategory] attribute on the class containing them. This attribute has one argument, the category name.
Exceptions
If you'd like to cause a command to fail with some feedback for the user on why, you can throw a CommandException.
The command evaluator will catch these and display an error in chat, as well as the message contained in the exception.
Command Overriding
You can also override existing commands from other mods. All commands have a registryPriority associated with them.
If any command is registered that shares the name or any aliases of another command, the command with the higher priority
will be registered, and the other will be removed from the registry. All commands have a priority of 0 by default.
To set the priority of your command, add a [CommandOverride] attribute to it, with the parameter being the new
priority of the command. If you want your command to always override its target, i'd recommend int.MaxValue here. Please
note that both names and aliases are taken into account when commands are overriden, so check your aliases carefully
on any commands with above normal priority. It's also worth mentioning that by setting a command's priority to a negative value, you can force it to be overriden
by any other commands by default. I have no idea when this might be useful. It's a thing though.
Custom Parsers
If you'd like to use types that don't have built in parsers as parameters to commands, you can implement ParserBase
and create your own! You'll need to implement two members: ParseResultType, a property that returns the type your
parser converts to, and object Parse(string value), a method that parses a string input to your desired type and
returns the value boxed to an object. After implementing the class for all types you wish to convert to, call
ParserLocator.RegisterParsersFromAssembly() in your plugin's startup logic to register all your parsers.
Also worth noting is the fact that ParserLocator's ParseTo(), TryParseTo() and their generic counterparts are
public for your utility.
Manual Installation Instructions
(you should probably just use a mod manager like r2modman or gale though)
!!! You need Bepinex 5 !!!
(if you have no idea what the versions mean try BepInEx_x64_5.4.21.0 and it might work. maybe)
Once BepInEx is installed, extract the zip into the BepInEx/plugins folder in the game's root directory.
have fun :3
CHANGELOG
v1.2.8
- Fixed for straftat 1.4.6
- Removed
ban,unban,banlist&clearbans, as lobby bans have been in the game for quite a while now.
v1.2.7
- Fixed for straftat 1.4.3
v1.2.6
- Fixed
maxfpscommand
v1.2.5
General
- Added a
propcommand (aliasp) that allows you to spawn props (barrels, aboubi heads) in exploration mode- Works identically to the
weaponcommand, but with names of props instead
- Works identically to the
- Added teleportation commands (in the new category
Teleportation, all are exploration only)saveloc: saves your location (aliastps)loadloc: loads your saved location again (aliastpl, useful for movement routing in exploration mode!)teleport: teleports you to a specific location with a specific rotation (aliastp)teleportplayer: teleports a specified player to another player (aliastpp). Requires the target player to have chat commands installed.
- Commands that would previously have used a Steam ID parameter (
ban,ignore, etc.) now allow you to enter either any Steam ID or the username (not case-sensitive) of a player in your lobby. - Fixed the
helpcommand not including some parameters - Fixed the
helpcommand not including all command flags
API Changes ~ For Mod Developers (some potentially breaking changes this time! please read!)
- Nullable types are now properly supported in command parameters
- This means you can now create optional parameters with no default value (previously you'd have to use a special value as the default).
- The
Parsersnamespace has been moved toParsing ParserBaseis now the interfaceIParsingExtensionParserLocator.RegisterParsersFromAssembly()is nowParserLocator.RegisterExtensionsFromAssembly()- Returning custom messages from parsing extensions is now possible through the message of an
InvalidCastException- If this exception is thrown while parsing, and a message is present, the message will be shown to the user in chat.
- For an example of how this could be used, check
Utils.ParameterTypes.PlayerParser.
- Added a new
Playerhelper type inUtils.ParameterTypes- This type has a custom parser that allows both usernames and steam ids to parse to it
- Useful for commands that need to take in a player as a parameter
- It is up to you to verify that a given player is actually in the lobby with
Player.InCurrentLobby
v1.1.5
General
weapon,randomweapon,weaponrainandclearweaponscan now be run by non-hosts, as long as the host has chat commands installed.
API Changes ~ For Mod Developers
- Added a new command flag:
TryRunOnHost- Commands with this flag will be run on the host's machine if possible.
- The output of commands with this flag will be shown to the user, but will not be sent for piping to other commands (because i can't be bothered to implement that)
- It's therefore best to only use this flag on commands that do not return a value.
- To get the steam id of the person requesting the command's execution, add a CSteamID parameter called
requesterwith a default value (CSteamID requester = default) as the last parameter of your command.
v1.0.5
- Fixed
fovcommand
v1.0.4
- Fixed
saycommand
v1.0.3
- Fixed for straftat 1.3.3c
- Improved
bancommand: the mod now warns you when joining the lobby of someone on your banlist - Removed
weaponscommand weaponcommand now takes an extra optional parameter:countrandomweaponcommand now takes an extra optional parameter:count
v1.0.2
- Fixed
helpcommand returning help text for some commands multiple times when getting help by command category
v1.0.1
- Fixed
jumpcommand not working when run from chat - Added Github repo url to Thunderstore page
v1.0.0
- Initial release