Skip to content

Commit 3d012a4

Browse files
authored
Merge pull request #4 from chromiecraft/command-hacks
Add initial account-based command behavior.
2 parents 8891d56 + 4757d61 commit 3d012a4

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

src/GmCommands.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,48 @@
11
#include "Player.h"
22
#include "ScriptMgr.h"
33
#include "Chat.h"
4+
#include "ChatCommand.h"
45
#include "Config.h"
56

7+
class GmCommands : public AllCommandScript
8+
{
9+
public:
10+
GmCommands() : AllCommandScript("GmCommands") {}
11+
12+
bool OnBeforeIsInvokerVisible(std::string name, Acore::Impl::ChatCommands::CommandPermissions permissions, ChatHandler const& who) override
13+
{
14+
if (who.IsConsole())
15+
return true;
16+
17+
Player* player = who.GetPlayer();
18+
19+
if (!player)
20+
return true;
21+
22+
uint32 accountID = player->GetSession()->GetAccountId();
23+
24+
if (!std::count(eligibleAccounts.begin(), eligibleAccounts.end(), accountID))
25+
return true; // Account is not eligible
26+
27+
if (std::count(eligibleCommands.begin(), eligibleCommands.end(), name))
28+
return false; // Command is eligible
29+
30+
return true; // Command is not eligible
31+
}
32+
33+
private:
34+
std::vector<uint32> eligibleAccounts =
35+
{
36+
94143, // HEYITSGMCH
37+
};
38+
39+
std::vector<std::string> eligibleCommands =
40+
{
41+
"gm fly",
42+
};
43+
};
44+
645
void AddGmCommandScripts()
746
{
47+
new GmCommands();
848
}

0 commit comments

Comments
 (0)