This is an Auto Announcer that can announce colored messages.
Credits for the Auto Announcer script go to the guy who made it
Credits for adding colors go to DrakeFish(me).
Add this to your Character Database:
Code:
CREATE TABLE `announcer_txt` (
`id` int(3) NOT NULL auto_increment,
`body` tinytext NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1;
Setup.cpp:
Code:
#include "StdAfx.h"
#include "Setup.h"
#include <scriptSetup.h>
extern "C" SCRIPT_DECL uint32 _exp_get_script_type()
{
return SCRIPT_TYPE_MISC;
}
extern "C" SCRIPT_DECL void _exp_script_register(ScriptMgr* mgr)
{
SetupAnnouncer(mgr);
}
#ifdef WIN32
BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved )
{
return TRUE;
}
#endif
Setup.h:
Code:
#pragma once
void SetupAnnouncer(ScriptMgr * mgr);
void ShowMsg(char * errmsg);
Announcer.cpp:
Code:
#include "StdAfx.h"
//Configure these as you wish
#define BREAKTIME 600000 //The amount of seconds * 1000 you want to wait in between messages
#define HEADERSTR "[Staff]" //The string to place in front of the message
#define HEADERCOLOR MSG_COLOR_GREEN //The color of the string in front of the message (Example: MSG_COLOR_RED)
#define TEXTCOLOR MSG_COLOR_LIGHTBLUE //The color of the text (Example: MSG_COLOR_LIGHTBLUE)
class Announcement
{
public:
void Run();
};
void Announcement::Run()
{
char sZprava[500];
QueryResult * result = CharacterDatabase.Query("SELECT * FROM announcer_txt ORDER BY id ASC");
if(result)
{
do {
sprintf(sZprava, "%s%s %s%s", HEADERCOLOR, HEADERSTR, TEXTCOLOR, result->Fetch()[1].GetString());
sWorld.SendWorldText(sZprava);
}while(result->NextRow());
delete result;
}
}
void ShowMsg(char * errmsg)
{
char errstr[255];
sprintf(errstr, "\nAnnouncer v2: %s", errmsg);
sLog.outString(errstr);
}
void SetupAnnouncer(ScriptMgr * mgr)
{
Announcement Announcer;
//If all is good, set up the timer event and lets roll!
if(BREAKTIME >= 1000)
{
TimedEvent * te = TimedEvent::Allocate(&Announcer, new CallbackP0<Announcement>(&Announcer, &Announcement::Run), 1, BREAKTIME, 0);
sWorld.event_AddEvent(te);
} else {
//Someone has their time set under 1 second.;P
ShowMsg("Announcer has been disabled. Please insure you have the config set right!");
}
}
All the colors:
MSG_COLOR_LIGHTRED
MSG_COLOR_LIGHTBLUE
MSG_COLOR_BLUE
MSG_COLOR_GREEN
MSG_COLOR_RED
MSG_COLOR_GOLD
MSG_COLOR_GREY
MSG_COLOR_WHITE
MSG_COLOR_SUBWHITE
MSG_COLOR_MAGENTA
MSG_COLOR_YELLOW
MSG_COLOR_CYAN
Have fun!