Modcraft - The community dedicated to quality WoW modding!
Wrath of the Lich King Modding => Serverside Modding => Topic started by: Everon Mightbane 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]
-
Uhm, you pass thru the args, checked if they were null. but dont use them afterwards?
Also, what are you writing ingame? .cheat fly? because you are asking for arguments (like on/off).
And you do realize there is a fly command already? .gm fly on/off
I'd say:
Replace this:
static bool HandleCheatFlyCommand(ChatHandler* handler, const char* args)
{
if (!*args)
return false;
Player* target = handler->GetSession()->GetPlayer();
with this
static bool HandleCheatFlyCommand(ChatHandler* handler, const char* /*args*/)
{
Player* target = handler->GetSession()->GetPlayer();
-
Yeah I knew, But I'm making a whole .cheat command with around 6-10 subcommands so I thought I'd add cheat fly in because its ease of access. I'm compiling it now so I'll see if it works. Thanks very much Laniax.
-
Have a look if you could fix the existing gm build commands. Like the gObject move rotate etc.
You have to re log to see your changes. That is stupid.