Welcome to the MMOtop - Arcemu, Mangos, Trinity.
+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Jerry's Avatar
    Status : Jerry is offline
    Join Date : Mar 2009
    Location : Serbia
    Posts : 2,321
    Thanks: 223
    Thanked 501 Times in 286 Posts
    Rep Power : 10
    Reputation:2077Jerry has a reputation beyond repute Jerry has a reputation beyond repute Jerry has a reputation beyond repute Jerry has a reputation beyond repute Jerry has a reputation beyond repute Jerry has a reputation beyond repute Jerry has a reputation beyond repute Jerry has a reputation beyond repute Jerry has a reputation beyond repute Jerry has a reputation beyond repute Jerry has a reputation beyond repute

    Default [C++] Server Chat

    This is not made by me or mmotop.org team !!!

    Credits: Sdyess

    You might want to add colors to the chat or something. For ArcEmu btw.

    Type #c to talk in the chat.

    Code:
    #include "Setup.h"
    
    bool ContainsString(const char * Message)
    {
    	if (Message[0] == '#' && Message[1] == 'c')
    	{
    		return true;
    	}
    	return false;
    }
    
    std::string MakeString(const char * Message)
    {
    	string newmsg = static_cast<string>(Message);
    	return newmsg;
    }
    
    void DisplayString(const char * message)
    {
    	sWorld.SendWorldText(message);
    }
    
    void ParseString(Player * pPlayer, const char * Message)
    {
    	string currentmsg = MakeString(Message);
    	string newmsg = "[";
    	if (pPlayer->GetSession()->CanUseCommand('z'))
    	{
    		newmsg+= "Admin";
    	}
    	else if (pPlayer->GetSession()->HasGMPermissions())
    	{
    		newmsg+= "GM";
    	}
    	newmsg += "][";
    	newmsg += pPlayer->GetName();
    	newmsg += "]: ";
    	newmsg += currentmsg.substr((currentmsg.find("#c") + 2));
    
    	const char * message = &newmsg[0];
    	DisplayString(message);
    }
    
    
    
    bool ChatSystem(Player * pPlayer, uint32 Type, uint32 Lang, const char * Message, const char * Misc)
    {
    	if (ContainsString(Message))
    	{
    		ParseString(pPlayer, Message);
    		return false;
    	}
    	return true;
    }
    
    void SetupChatSystem(ScriptMgr * mgr)
    {
    	mgr->register_hook(SERVER_HOOK_EVENT_ON_CHAT, &ChatSystem);
    }

  2. #2
    Truster's Avatar
    Status : Truster is offline
    Join Date : Apr 2010
    Location : Norway
    Posts : 3,341
    Thanks: 46
    Thanked 87 Times in 83 Posts
    Rep Power : 10
    Reputation:2014Truster has a reputation beyond repute Truster has a reputation beyond repute Truster has a reputation beyond repute Truster has a reputation beyond repute Truster has a reputation beyond repute Truster has a reputation beyond repute Truster has a reputation beyond repute Truster has a reputation beyond repute Truster has a reputation beyond repute Truster has a reputation beyond repute Truster has a reputation beyond repute

    Default

    thanks for the share. May try this one when I start up server again :)

  3. #3
    yvo
    Status : yvo is offline
    Join Date : Jul 2009
    Location : Under a roof
    Posts : 304
    Thanks: 10
    Thanked 11 Times in 10 Posts
    Rep Power : 3
    Reputation:71yvo will become famous soon enough

    Default

    Thank you for sharing the code seems allright to me i dont see any errors in it :3


 

Visitors found this page by searching for:

chat thread c

Mangos c server chat

chat thread server c

TrinityCore C Chat color change

c server chat wow

SEO Blog

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts