Skip to content

Commit 7514e2f

Browse files
authored
Merge pull request #5 from chromiecraft/fix/gm-visibility-for-non-gm-accounts
Add server-side GM visibility control script
2 parents a6f99a0 + 1f23598 commit 7514e2f

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/GmCommands.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "Player.h"
2+
#include "PlayerScript.h"
23
#include "ScriptMgr.h"
34
#include "Chat.h"
45
#include "ChatCommand.h"
@@ -85,8 +86,39 @@ class mod_gm_commands_worldscript : public WorldScript
8586
}
8687
};
8788

89+
class mod_gm_commands_playerscript : public PlayerScript
90+
{
91+
public:
92+
mod_gm_commands_playerscript() : PlayerScript("mod_gm_commands_playerscript") {}
93+
94+
void OnPlayerSetServerSideVisibility(Player* player, ServerSideVisibilityType& type, AccountTypes& sec) override
95+
{
96+
if (type != SERVERSIDE_VISIBILITY_GM)
97+
return;
98+
99+
if (!player || player->isGMVisible())
100+
return;
101+
102+
WorldSession* session = player->GetSession();
103+
if (!session)
104+
return;
105+
106+
if (!sGMCommands->IsAccountAllowed(session->GetAccountId()))
107+
return;
108+
109+
if (sec != SEC_PLAYER)
110+
return;
111+
112+
if (!sGMCommands->IsCommandAllowed("gm") && !sGMCommands->IsCommandAllowed("gm visible"))
113+
return;
114+
115+
sec = SEC_GAMEMASTER;
116+
}
117+
};
118+
88119
void AddGmCommandScripts()
89120
{
90121
new GmCommands();
91122
new mod_gm_commands_worldscript();
123+
new mod_gm_commands_playerscript();
92124
}

0 commit comments

Comments
 (0)