Jump to content

[Help]Create a command wich make say something to player


Guest Pixeel

Recommended Posts

Hello all, I need some help writing a new command for make say something to character (like .npc say). I start to builds upon in my inspiration files "Player.cpp & Level1.ccp"

This gives it

bool ChatHandler::HandlePlayerSayCommand(const char* args)

{

if(!*args)

return false;

Player* pPlayer = getSelectedPlayer();

if(!pPlayer)

{

SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);

SetSentErrorMessage(true);

return false;

}

pPlayer->PlayerSay(args, LANG_UNIVERSAL, 0);

if(sWorld.getConfig(CONFIG_CHATLOG_PUBLIC))

sLog.outChat("[sAY] Player %s says (language %u): %s",

GetName(), language, text.c_str());

// Execute an emote is the last letter is "?" or "!"

char lastchar = args[strlen(args) - 1];

switch(lastchar)

{

case '?': m_session->GetPlayer( )->SetUInt32Value( UNIT_NPC_EMOTESTATE , EMOTE_ONESHOT_QUESTION ); break

case '!': m_session->GetPlayer( )->SetUInt32Value( UNIT_NPC_EMOTESTATE , EMOTE_ONESHOT_EXCLAMATION ); break

default: m_session->GetPlayer( )->SetUInt32Value( UNIT_NPC_EMOTESTATE , EMOTE_ONESHOT_TALK ); break

}

return true;

}

Can anyone help me to enrich this code and to make him able to work, please?

Link to comment
Share on other sites

The existing command ".npc whisper" does allow you to have a specified NPC to whisper whatever you wish to a player.

Perhaps that section of the program code could be used as a template for creating an ".npc say" command?

".npc playemote" lets you specify an NPC acting out a particular emote, like /dance, by using the correct emote ID#.

".npc textemote" allows you to have an NPC say one of the many preset phrases available to players, like /incoming.

I think those are covered in 'Chat.cpp' but I'm not a scholar of the MaNGOS source code tree.

Link to comment
Share on other sites

This code can help you althoug it isn't correct ;)

bool ChatHandler::HandlePlayerSayCommand(const char* args)
{
   if(!*args)
       return false;
Player* chr = getSelectedPlayer();

if (!chr)
   {
       SendSysMessage(LANG_NO_CHAR_SELECTED);
       SetSentErrorMessage(true);
       return false;
   }
   chr->Say(args, LANG_UNIVERSAL, 0);
   return true;
}
bool ChatHandler::HandlePlayerYellCommand(const char* args)
{
   Player* chr = getSelectedPlayer();

if (!chr)
   {
       SendSysMessage(LANG_NO_CHAR_SELECTED);
       SetSentErrorMessage(true);
       return false;
   }
   chr->Yell(args, LANG_UNIVERSAL, 0);
   return true;
}
//show text emote by creature in chat
bool ChatHandler::HandlePlayerTextEmoteCommand(const char* args)
{
   if(!*args)
       return false;
   Player* chr = getSelectedPlayer();

if (!chr)
   {
       SendSysMessage(LANG_NO_CHAR_SELECTED);
       SetSentErrorMessage(true);
       return false;
   }
   chr->TextEmote(args, 0);
   return true;
}

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use