Jump to content

xeross

Members
  • Posts

    36
  • Joined

  • Last visited

    Never
  • Donations

    0.00 GBP 

Posts posted by xeross

  1. 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

  2. TytytytytytytytyTytytytytytytytyTytytytytytytytyTytytytytytytytyTytytytytytytytyTytytytytytytytyTytytytytytytytyTyty

    tytytytytytyTytytytytytytytyTytytytytytytytyTytytytytytytytyTytytytytytytytyTytytytytytytytyTytytytytytytytyTytytyty

    tytytytyTytytytytytytytyTytytytytytytytyTytytytytytytytyTytytytytytytytyTytytytytytytyty.

    Thanks for this, FInally support, finally udb will make a 3.0.3 database, begone Frozen Database

  3. i now have

    void World::SendBroadcast()
    {
       std::string msg;
       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());
       }
    }
    

    But i wonder if nextid will be saved till the next function call so that the correct message will be selected

  4. I am working on an announcer script and i have the following.

    void World::SendBroadcast()
    {
       std::string msg;
       int nextid;
    
       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].GetInt();
       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());
       }
    }

    All calls timers etc are configured properly, this is based on an announcer i found.

    However i get the following errors

    2>..\\..\\src\\game\\World.cpp(2629) : error C2065: 'result' : undeclared identifier
    2>..\\..\\src\\game\\World.cpp(2631) : error C2065: 'result' : undeclared identifier
    2>..\\..\\src\\game\\World.cpp(2631) : error C2227: left of '->Fetch' must point to class/struct/union/generic type
    2>        type is ''unknown-type''
    2>..\\..\\src\\game\\World.cpp(2631) : error C2228: left of '.GetInt' must have class/struct/union
    2>..\\..\\src\\game\\World.cpp(2632) : error C2065: 'result' : undeclared identifier
    2>..\\..\\src\\game\\World.cpp(2632) : error C2227: left of '->Fetch' must point to class/struct/union/generic type
    2>        type is ''unknown-type''
    2>..\\..\\src\\game\\World.cpp(2632) : error C2228: left of '.GetString' must have class/struct/union
    2>..\\..\\src\\game\\World.cpp(2633) : error C2065: 'result' : undeclared identifier
    2>..\\..\\src\\game\\World.cpp(2633) : error C2541: 'delete' : cannot delete objects that are not pointers

    I think i did something wrong with nextit, it needs to be saved for the next function call so it gets the correct message from mysql, how would i accomplish this ?

    Thanks for your time, Xeross

  5. Hey,

    Im working on a script myself atm and i need to put a variable into a query i have the following code :

    QueryResult *result = WorldDatabase.PQuery("SELECT `text`, `next` FROM `autobroadcast` WHERE `id` = %u", nextid);

    Now i want to know what do the %u etc mean and how do i use them properly.

    The variable nextid has been set btw.

    Also i've assigned nextid to be a uint32 but it will never reach a number higher then 32 or so what is the best variable type to use for it ?

    Thanks for your time, Xeross

  6. Hey,

    I have a vote reward system i made but it was for ascent i now need to convert it for mangos.

    How would i do this does anyone have an example of a script that can insert mail into the game or a vote reward system that does this.

    Or can someone point me in the right direction ?

    Thanks for your time, Xeross

×
×
  • 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