5
« on: August 27, 2011, 07:29:53 pm »
Hi, I've made this custom command for trinity and it compiles fine but in game when I type the command it says 'Incorrect Syntax' could someone look over the code and tell me if they see any problems please?
[spoiler:w9dljthv]#include "ScriptMgr.h"
#include "ObjectMgr.h"
#include "Chat.h"
class cheat_commandscript : public CommandScript
{
public:
cheat_commandscript() : CommandScript("cheat_commandscript") { }
ChatCommand* GetCommands() const
{
static ChatCommand cheatCommandTable[] =
{
{ "fly", SEC_PLAYER, false, &HandleCheatFlyCommand, "", NULL },
{ "land", SEC_PLAYER, false, &HandleCheatLandCommand, "", NULL },
{ NULL, 0, false, NULL, "", NULL }
};
static ChatCommand commandTable[] =
{
{ "cheat", SEC_PLAYER, false, NULL, "", cheatCommandTable },
{ NULL, 0, false, NULL, "", NULL }
};
return commandTable;
};
static bool HandleCheatFlyCommand(ChatHandler* handler, const char* args)
{
if (!*args)
return false;
Player* target = handler->GetSession()->GetPlayer();
WorldPacket data(12);
data.SetOpcode(SMSG_MOVE_SET_CAN_FLY);
data.append(target->GetPackGUID());
data << uint32(0);
target->SendMessageToSet(&data, true);
handler->PSendSysMessage("Fly mode enabled");
return true;
};
static bool HandleCheatLandCommand(ChatHandler* handler, const char* args)
{
if (!*args)
return false;
Player* target = handler->GetSession()->GetPlayer();
WorldPacket data(12);
data.SetOpcode(SMSG_MOVE_UNSET_CAN_FLY);
data.append(target->GetPackGUID());
data << uint32(0);
target->SendMessageToSet(&data, true);
handler->PSendSysMessage("Fly mode disabled");
return true;
};
};
void AddSC_cheat_commandscript()
{
new cheat_commandscript();
};
[/spoiler:w9dljthv]