Hey,
I've got the following announcer script(Modified by me)
void World::SendBroadcast()
{
std::string msg;
static int nextid;
QueryResult *result;
if(nextid != 0)
{
QueryResult *result = WorldDatabase.PQuery("SELECT `text`, `next` FROM `autobroadcast` WHERE `id` = %u", nextid);
}
else
{
QueryResult *result = WorldDatabase.PQuery("SELECT `text`, `next` FROM `autobroadcast` ORDER BY RAND() LIMIT 1");
}
if(!result)
return;
nextid = result->Fetch()[1].GetUInt8();
msg = result->Fetch()[0].GetString();
delete result;
static uint32 abcenter = 0;
abcenter = sConfig.GetIntDefault("AutoBroadcast.Center", 0);
if(abcenter == 0)
{
sWorld.SendWorldText(LANG_AUTO_BROADCAST, msg.c_str());
sLog.outString("AutoBroadcast: '%s'",msg.c_str());
}
if(abcenter == 1)
{
WorldPacket data(SMSG_NOTIFICATION, (msg.size()+1));
data << msg;
sWorld.SendGlobalMessage(&data);
sLog.outString("AutoBroadcast: '%s'",msg.c_str());
}
if(abcenter == 2)
{
sWorld.SendWorldText(LANG_AUTO_BROADCAST, msg.c_str());
WorldPacket data(SMSG_NOTIFICATION, (msg.size()+1));
data << msg;
sWorld.SendGlobalMessage(&data);
sLog.outString("AutoBroadcast: '%s'",msg.c_str());
}
}
the sql table:
CREATE TABLE IF NOT EXISTS `autobroadcast` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`text` longtext NOT NULL,
`next` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ;
INSERT INTO `autobroadcast` (`id`, `text`, `next`) VALUES
(1, 'type /join World to chat with all players', 2),
(2, 'Don''t forget to vote 4 us at ******', 3),
(3, 'Also check our forums at ******', 1);
Somehow it crashes on
nextid = result->Fetch()[1].GetUInt8();
Can anyone help me with fixing this ?
Thanks for your time, Xeross