Attempting to fix chat command call

This commit is contained in:
Flerp 2025-10-24 23:56:48 -07:00
parent e792efff8c
commit 3e07ca5ee7

View File

@ -1,23 +1,27 @@
// src/teleport-to-node.cpp
#include "ScriptMgr.h" #include "ScriptMgr.h"
#include "CommandScript.h" #include "CommandScript.h"
#include "Chat.h" #include "Chat.h"
#include "ChatCommand.h"
#include "Player.h" #include "Player.h"
#include "GameObject.h" #include "GameObject.h"
using namespace Acore::ChatCommands;
namespace namespace
{ {
// === CONFIG === // === CONFIG ===
static constexpr float TELEPORT_DISTANCE = 200.0f; // yards static constexpr float TELEPORT_DISTANCE = 200.0f; // yards
static constexpr float Z_BUMP = 1.5f; // anti-clip offset static constexpr float Z_BUMP = 1.5f; // anti-clip offset
// Mining node entries (trim this list to what you actually want) // Mining node entries (trim as needed)
static const std::vector<uint32> kVeinEntries = { static const std::vector<uint32> kVeinEntries = {
324, 1610, 1667, 1731, 1732, 1733, 1734, 2054, 2055, 3763, 3764, 19903, 324,1610,1667,1731,1732,1733,1734,2054,2055,3763,3764,19903,
73940, 73941, 103711, 103713, 105569, 123848, 150080, 150082, 175404, 73940,73941,103711,103713,105569,123848,150080,150082,175404,
176643, 177388, 179144, 179224, 180215, 181109, 181248, 181249, 181557, 176643,177388,179144,179224,180215,181109,181248,181249,181557,
185557, 191133, 1735, 2040, 2047, 2653, 73939, 123309, 123310, 150079, 185557,191133,1735,2040,2047,2653,73939,123309,123310,150079,
150081, 165658, 176645, 181108, 181555, 181556, 181569, 181570, 185877, 150081,165658,176645,181108,181555,181556,181569,181570,185877,
189978, 189979, 189980, 189981, 195036, 189978,189979,189980,189981,195036,
}; };
static GameObject* FindNearestVein(Player* player, float maxRange) static GameObject* FindNearestVein(Player* player, float maxRange)
@ -48,7 +52,7 @@ namespace
if (player->IsInCombat()) if (player->IsInCombat())
{ {
ChatHandler(player->GetSession()).PSendSysMessage("You can't use this while in combat."); ChatHandler(player->GetSession()).PSendSysMessage("You can't use this while in combat.");
return true; // handled return true;
} }
if (GameObject* node = FindNearestVein(player, TELEPORT_DISTANCE)) if (GameObject* node = FindNearestVein(player, TELEPORT_DISTANCE))
@ -74,27 +78,30 @@ class telenode_commandscript : public CommandScript
public: public:
telenode_commandscript() : CommandScript("telenode_commandscript") { } telenode_commandscript() : CommandScript("telenode_commandscript") { }
// NOTE: Use Acore::ChatCommands::ChatCommandTable (or the 'using' above)
ChatCommandTable GetCommands() const override ChatCommandTable GetCommands() const override
{ {
static ChatCommandTable commandTable = static ChatCommandTable cmds =
{ {
// .telenode // .telenode (player-only; change SEC if you want)
{ "telenode", { "telenode",
SEC_PLAYER,
Console::No,
// handler signature with no args
[](ChatHandler* handler) [](ChatHandler* handler)
{ {
if (Player* player = handler->GetSession() ? handler->GetSession()->GetPlayer() : nullptr) if (auto* session = handler->GetSession())
return DoTeleNode(player); return DoTeleNode(session->GetPlayer());
return false; return false;
}, },
SEC_PLAYER, // usable by anyone; override via DB 'command' table if desired "" // help text (optional)
Console::No
}, },
}; };
return commandTable; return cmds;
} }
}; };
// Module entry point (call this from your module's loader) // Called by your module loader
void Addmod_telenodeScripts() void Addmod_telenodeScripts()
{ {
new telenode_commandscript(); new telenode_commandscript();