I tried to use AddClientCommandCallback, but met a CLIENT SCRIPT COMPILE ERROR.
// CLIENT SCRIPT COMPILE ERROR Undefined variable "AddClientCommandCallback"
So I made this to allow you to custom commands in local easier.
You can type some commands like /ping in the chat. These commands you sent will not show to other players, so feel free to use them.
Type /helpor/? to get the commands list. Use up-arrow/down-arrow to scroll.
void function AddLocalClientCommand(string command, void functionref(entity, array<string>) func)You can add command with this function.
entity is the local player.
array<string> is an array of args. args[0] is the command string.
void function PingCommand(entity player, array<string> args)
{
int ping = MyPing()
Logger.Info("ping: " + ping)
}
// args[0] is the command string. Here is ping.
AddLocalClientCommand("ping", PingCommand)
It offer 5 functions you can use to log in the chat window(only shown to you). I don’t know how to colorize the text, so they are not color-modified.
Logger.Trace(string str)
Trace is not completed. Do not use.
Logger.Debug(string str)
Logger.Info(string str)
Default log level.
Logger.Warn(string str)
Logger.Error(string str)
Once if the log function you use is lower than the log level, the log message will not show.
Configure this int Logger.logLevel. You can find the levels with Logger.LogType["INFO"].
If you want to change the log level, just like this:
Logger.logLevel = Logger.LogType["DEBUG"]
Logger.Debug(command)
ping
Show ping.
list_all_player
List all players.
list_all_command
help
?
List all commands.
convar ConVarname
Show the value of the ConVarname.
"ConVars": [
// use to identify the commands, these chats will be blocked.
{
"Name": "l1nexus_local_client_command_prefix",
"DefaultValue": "/"
}
]
│ mod.json
│
└─mod
└─scripts
└─vscripts
l1nexus_local_client_command.nut
l1nexus_local_client_command_default_commands.nut
l1nexus_logger.nut