Sorry for double posting, but could someone take a look at this and tell me why its not working, it compiles just fine, however when I use .announce my worldserver.exe crashes.: [spoiler:2mi2ysll]#include "Chat.h"
#include "ScriptPCH.h"
class ann_commandscript : public CommandScript
{
public:
ann_commandscript() : CommandScript("ann_commandscript") { }
ChatCommand* GetCommands() const
{
static ChatCommand commandTable[] =
{
{ "announce", SEC_PLAYER, true, &HandleAnnounceCommand, "", NULL },
{ NULL, 0, false, NULL, "", NULL }
};
return commandTable;
};
static bool HandleAnnounceCommand(ChatHandler* handler, const char* args)
{
std::string rank("");
uint32 gmlevel;
WorldPacket data;
std::string name("Console");
if (WorldSession* session = handler->GetSession())
{
Player* player = session->GetPlayer();
gmlevel = player->GetSession()->GetSecurity();
switch (gmlevel)
{
case 0:
rank = "|cff0051FFPlayer|r"; break;
case 1:
rank = "|cff88DC51Voter|r"; break;
case 2:
rank = "|cffF28A00Donator|r"; break;
case 3:
rank = "|cffAD01B0Moderator|r"; break;
case 4:
rank = "|cffAD01B0Administrator|r"; break;
}
}
if (!*args)
return false;
if (WorldSession* session = handler->GetSession())
name = session->GetPlayer()->GetName();
sWorld->SendWorldText(LANG_CUSTOM_ANNOUNCE, rank, name, args);
return true;
}
};
void AddSC_ann_commandscript()
{
new ann_commandscript();
};
[/spoiler:2mi2ysll]
LANG_CUSTOM_ANNOUNCE is linked up in language.h and has the correct reference in my trinity_string table and the script compiles without issue.