[Quest API] Add SendGMCommand() to Perl/Lua. (#2527)

* [Quest API] Add SendGMCommand() to Perl/Lua.

# Perl
- Add `$client->SendGMCommand(message)` to Perl.
- Add `$client->SendGMCommand(message, ignore_status)` to Perl.

# Lua
- Add `client:SendGMCommand(message)` to Lua.
- Add `client:SendGMCommand(message, ignore_status)` to Lua.

# Notes
- `ignore_status` allows you to have players use GM commands that they are not the required status level for through the Quest API.
- `ignore_status` is default false, so if you don't send it, it checks and makes sure the player can use the command you're sending before allowing it.

* Typo.

* Formatting.
This commit is contained in:
Kinglykrab
2022-11-14 16:47:02 -05:00
committed by GitHub
parent 36887203d3
commit f668949c24
7 changed files with 41 additions and 8 deletions
+4 -4
View File
@@ -48,7 +48,7 @@ int command_count; // how many commands we have
// this is the pointer to the dispatch function, updated once
// init has been performed to point at the real function
int (*command_dispatch)(Client *,std::string) = command_notavail;
int (*command_dispatch)(Client *, std::string, bool) = command_notavail;
std::map<std::string, CommandRecord *> commandlist;
std::map<std::string, std::string> commandaliases;
@@ -63,7 +63,7 @@ std::map<std::string, uint8> commands_map;
* not used
*
*/
int command_notavail(Client *c, std::string message)
int command_notavail(Client *c, std::string message, bool ignore_status)
{
c->Message(Chat::White, "Commands not available.");
return -1;
@@ -557,7 +557,7 @@ uint8 GetCommandStatus(Client *c, std::string command_name) {
* message - what the client typed
*
*/
int command_realdispatch(Client *c, std::string message)
int command_realdispatch(Client *c, std::string message, bool ignore_status)
{
Seperator sep(message.c_str(), ' ', 10, 100, true); // "three word argument" should be considered 1 arg
@@ -570,7 +570,7 @@ int command_realdispatch(Client *c, std::string message)
}
auto cur = commandlist[cstr];
if (c->Admin() < cur->admin) {
if (!ignore_status && c->Admin() < cur->admin) {
c->Message(Chat::White, "Your status is not high enough to use this command.");
return -1;
}