Likes: 0
Results 1 to 6 of 6
Thread: Auto Announcer
-
25-07-08, 02:43 AM #1
Auto Announcer
Register to remove this adThis is an auto announcer
Works on both Ascent and Mangos
Announcer.cpp
Code://***This script was released under CodeCraft and cannot be redistrubted without giving credits** //Title of Script: Anouncer v2 //Description of Script: Sends a worldwide announcement in timed intervals. //Author: Daikenkaiking //Credits: Supalosa for his xml script that I learned some functions from. #include "StdAfx.h" #include "Setup.h" //Configure these as you wish #define BREAKTIME 300000 //The amount of seconds * 1000 you want to wait in between messages #define HEADERSTR "[Announcer]" //The string to place in front of the message //Define and create variables uint32 ann_next_id = 0; class Announcement { public: void Run(); }; void Announcement::Run() { // Variable Defines char query[255]; char display_str[255]; string body; uint32 id, next_id; if(ann_next_id == 0) { sprintf(query, "SELECT * FROM announcer_txt ORDER BY RAND() LIMIT 1"); } else { sprintf(query, "SELECT * FROM announcer_txt WHERE id = %i", ann_next_id); } QueryResult * result = WorldDatabase.Query(query); //Uh oh! if(!result) { ShowMsg("Something went wrong or there is no data to display!"); ann_next_id = 0; return; } //Lets get the data, and set everyting up Field * fields = result->Fetch(); id = fields[0].GetUInt32(); body = fields[1].GetString(); next_id = fields[2].GetUInt32(); //We may need to set next id, and set last id if(next_id != 0) ann_next_id = next_id; else ann_next_id = 0; //Lets format the String to display and then display it! sprintf(display_str, "%s %s", HEADERSTR, body.c_str()); sWorld.SendWorldText(display_str); //to prevent overscope and leaking WorldDatabase.FreeQueryResult(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); ShowMsg("Announcer has been started!"); } else { //Someone has their time set under 1 second. ;P ShowMsg("Announcer has been disabled. Please insure you have the config set right!"); } }
Code:void SetupAnnouncer(ScriptMgr * mgr); void ShowMsg(char * errmsg);
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;
› See More: Auto Announcer
-
03-08-08, 08:12 AM #2
- Rep Power
- 17
- Reputation
- 11
can u make a setup.cpp +Repx1
-
03-08-08, 08:15 AM #3
btw , i am already using it on my server forgot to give u +REp , so +Rep now
-
21-08-08, 02:28 PM #4
1>..\src\Announcer\Announcer.cpp(42) : error C3861: 'ShowMsg': identifier not found
I guess most of these scripts are outdated...
Edit!! Didn't see the box underneath.
-
31-08-08, 09:02 AM #5
Hmm, mate this script is very big i must say. U should check out the lua announcer that i've made Anyways its nice and works perfect.
-
31-08-08, 10:56 PM #6
Register to remove this adThis one works perfect too...and its made from Daikaikenking...a great C++ scripter