This is a read only copy without any forum functionality of the old Modcraft forum.
If there is anything that you would like to have removed, message me on Discord via Kaev#5208.
Big thanks to Alastor for making this copy!

Menu

Author Topic: [SOLVED][C++] Trinity custom command - Syntax error  (Read 1930 times)

Everon Mightbane

  • Registred Member
  • Loreweaver
  • *****
  • Posts: 89
    • View Profile
[SOLVED][C++] Trinity custom command - Syntax error
« 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]
Code: [Select]
#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]
« Last Edit: August 30, 2011, 12:53:28 pm by Admin »

Laniax

  • Registred Member
  • Polygonshifter
  • *****
  • Posts: 62
    • View Profile
Re: [C++] Trinity custom command - Syntax error
« Reply #1 on: August 27, 2011, 09:17:35 pm »
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:
Code: [Select]
static bool HandleCheatFlyCommand(ChatHandler* handler, const char* args)
    {
        if (!*args)
            return false;

        Player* target =  handler->GetSession()->GetPlayer();

with this
Code: [Select]
static bool HandleCheatFlyCommand(ChatHandler* handler, const char* /*args*/)
    {
        Player* target =  handler->GetSession()->GetPlayer();
« Last Edit: January 01, 1970, 01:00:00 am by Admin »
Current project: AIO Emulation solution.

Everon Mightbane

  • Registred Member
  • Loreweaver
  • *****
  • Posts: 89
    • View Profile
Re: [C++] Trinity custom command - Syntax error
« Reply #2 on: August 27, 2011, 09:56:33 pm »
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.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Steff

  • Administrator
  • Creator of Worlds
  • *****
  • Posts: 4551
    • View Profile
Re: [SOLVED][C++] Trinity custom command - Syntax error
« Reply #3 on: March 07, 2012, 07:56:12 am »
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.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »
Please mark as solved if solved.
Don't ask if you could ask a question... JUST ask the Question.
You can send me also offline messages. I will answer if I get online.
Skype: project.modcraft
Discord: steff#6954