Usefull ".arena" command

Here’s the script, thx to Paradox for his help :

[CODE]#include “ScriptPCH.h”

#include “Chat.h”

class arena_command : public CommandScript

{

public:

    arena_command() : CommandScript("arenacommand") { }



    static bool HandleArenaCommand(ChatHandler* handler, const char* /*args*/)

    {

	    BattlegroundTypeId bgTypeId = BATTLEGROUND_AA;

		handler->GetSession()->SendBattlegGroundList(handler->GetSession()->GetPlayer()->GetGUID(), bgTypeId);

		return true;

    }


    ChatCommand* GetCommands() const

    {

        static ChatCommand ArenaCommand[] =

        {

            { "arena",          SEC_PLAYER,			false, &HandleArenaCommand,	"", NULL },

            { NULL,             0,                  false, NULL,				"", NULL }

        };

        return ArenaCommand;

    }

};

void AddSC_Arena_Command()

{

new arena_command();

}[/CODE]

Comment the lines 643 to 649 from BattleGroundHandler.cpp

[CODE]/* if (!unit)

    return;


if (!unit->isBattleMaster())                             // it's not battle master

    return; */[/CODE]

Don’t forget to add the .arena command in your DB, command table /emoticons/default_smile.png

Here’s the SQL :

INSERT INTO `command` (`name`, `security`, `help`) VALUES ('arena', '0', 'Syntax: .arena');

Use the commandscripts, this way is obsolete.

Paradox can you please give a link containing information about command scripts. I searched and it only returned your post. I also create commands like he does so I would like to know how to do it the proper way.

src\server\scripts\Commands

src\server\scripts\Examples\example_commandscript.cpp

Since i’m very bad in c++ i never really take the time and make the effort to read some tutorials on it i don’t know the proper way to includes files and what to define to make the script work, That’s why i used the hacky way, i’ll try to make it using the commandscript and post it back when i’m done /emoticons/default_smile.png

This should help with what to include, etc.

http://www.trinitycore.org/w/How-to:CustomScript

Hopefully, the edits I just made will make it easier to use, if you notice anything wrong, or that you don’t understand, ask and I will see about fixing the howto more, if needed.

So i try’d this script :

[CODE]#include “ScriptPCH.h”

#include “Chat.h”

class arena_command : public CommandScript

{

public:

    arena_command() : CommandScript("arenacommand") { }


    static bool HandleArenaCommand(ChatHandler* handler, const char* /*args*/)

    {

	    BattlegroundTypeId bgTypeId = BATTLEGROUND_AA;

		m_session->SendBattlegGroundList(m_session->GetPlayer()->GetGUID(), bgTypeId);

		return true;

    }


    ChatCommand* GetCommands() const

    {

        static ChatCommand ArenaCommand[] =

        {

            { "arena",          SEC_PLAYER,			false, &HandleArenaCommand,	"", NULL },

            { NULL,             0,                  false, NULL,				"", NULL }

        };

        return ArenaCommand;

    }

};

void AddSC_Arena_Command()

{

new arena_command();

}[/CODE]

And got those error :

[I]‘m_session’ : undeclared identifier

left of ‘->SendBattlegGroundList’ must point to class/struct/union/generic type[/I]

How can i declare m_session ?

Also is that possible to disable this part of the code :

[CODE]/* if (!unit)

    return;


if (!unit->isBattleMaster())                             // it's not battle master

    return; */[/CODE]

Within the custom scripts ?

Sorry for the stupids question i’m learning here, thanx a lot for your help i realy apprecied it !

looking through the existing commandscripts would show you what it needs to be changed to to work.

and, I don’t understand the second question.

Edit:

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

is an example

Okay in fact “WorldSession * m_session;”

was declared in both Chat.h and Player.h so it didn’t knew wich one to choose i guess

i declared it again in the custom script and it worked !

That’s not what I said, but, eh.

But i didn’t understand target = handler->GetSession()->GetPlayer();

i tought target = was a part of the code i need to look at and didn’t find it anywhere lol, But now i see

Actualy compiling is fine but it make crash your server on .arena

So basicly i just have to replace m_session by handler-> ?

it compile fine but i don’t completly understand why handler work and why m_session didn’t, i guess i should at least read some tutorials about the basics of c++ before trying those kind of modification, will try to test it ingame.

Edit : It worked !

What your code did was create a NULL m_session, the method I showed you actually retrieves the session of the player.

You neeed to change the topic name from:

Usefull “.arena” command

to:

“Usefull” .arena command

Well its very usefull not to have to stand before a npc, and it’s included for other battlegrounds (HotKey “H”).

use this so you can chain arena without having to slack in the mall.

hello , i use this script but after click to Join nothing will happen

Did you edit BattleGroundHandler.cpp correctly ?

Yes