[C++] BossTrack v1.0 menu

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    mager1794's Avatar Member
    Reputation
    356
    Join Date
    Feb 2008
    Posts
    703
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [C++] BossTrack v2.0



    I've was thinking about how everyone on retail always knows who was the first guild to down a certain boss, so i decided to develop that capability for private servers, you have to add the bosses yourself though. As well, us Lunar Scripters kinda need a way to get out name out into the public. So please enjoy the script, and post back.

    C++
    Code:
    #include "StdAfx.h"
    #include "Setup.h"
    #include <vector>
    
    vector<string> * command(string str)
    {
      char * cstr, *p;
    
      cstr = new char [str.size()+1];
      strcpy (cstr, str.c_str());
    
      vector<string> * strvec = new vector<string>();
      p=strtok (cstr," ");
      while (p!=NULL)
      {
        strvec->push_back(p);
        p=strtok(NULL," ");
      }
    
      delete[] cstr;  
      return strvec;
    }
    
    void BossCommands(Player * pPlayer, uint32 Type, uint32 Lang, const char * Message, const char * Misc)
    {
        if(!pPlayer)
            return;
        string comm = (string)Message;
        
        if(comm.at(0) == '#')
        {
        
        vector<string> * strs =command(comm);
        string command = strs->at(0);
        if(command == "#boss")
        {
            
            string arg = strs->at(1);
            QueryResult * qres = WorldDatabase.Query("SELECT * FROM `firstbosskills` WHERE `entryid` = '%s'", arg);
            if(!qres)
                return;
            Field * fields = qres->Fetch();
            string cname = fields[1].GetString();
            string gname = fields[2].GetString();
    
            char * Message;
            sprintf(Message,"%s was first killed by the guild %s",cname,gname);
            pPlayer->BroadcastMessage(Message);
        }
        else if(command == "#addboss")
        {
    
            if(pPlayer->GetSession()->HasGMPermissions())
            {
            Creature * selected = pPlayer->GetMapMgr()->GetCreature(GET_LOWGUID_PART(pPlayer->GetSelection()));
            if(selected != NULL)
            {
                uint32 arg = selected->GetEntry();
                    QueryResult * qres = WorldDatabase.Query("SELECT * FROM `bossids` WHERE `entry` = '%s'", arg);
                    if(!qres)
                    {
                        WorldDatabase.Query("INSERT INTO `bossids` VALUES(%u);",arg);
                    }
            }
            else if(strs->at(1) != "")
            {
                string arg = strs->at(1);
                QueryResult * qres = WorldDatabase.Query("SELECT * FROM `bossids` WHERE `entry` = '%s'", arg);
                if(!qres)
                {
                WorldDatabase.Query("INSERT INTO `bossids` VALUES(%s);",arg);
                }
            }
            else
            {
                pPlayer->BroadcastMessage("Be sure to select an Npc or type an npc entry id");
            }
            }
            else
            {
                pPlayer->BroadcastMessage("Command doesn't exist");
            }
    
    
        }
        else if(command == "#bosslookup")
        {
            string arg = strs->at(1);
            QueryResult * qres = WorldDatabase.Query("SELECT * FROM `firstbosskills` WHERE `creaturename` like '%s'", arg);
            if(!qres)
                return;
            int count = qres->GetRowCount();
            
            for(int i = 1; i >= count;i++)
            {
                        Field * fields = qres->Fetch();
                        string cname = fields[1].GetString();
                        string id = fields[0].GetString();
                        char * Message;
                        sprintf(Message,"%s: %s",cname,id);
                        pPlayer->BroadcastMessage(Message);
                        qres->NextRow();
                        if(i > 15)
                            i = count + 1;
    
            }
    
            if(count > 15)
            {
                pPlayer->BroadcastMessage("Over 15 Results returned try to shorter the search query");
            }
    
        }
        }
        else
        {
            pPlayer->BroadcastMessage("Command doesn't exist");
        }
    }
    
    
    class AddFirstKillAI : public CreatureAIScript
    {
    public:
        AddFirstKillAI(Creature* cre) : CreatureAIScript(cre) {}
    
        void OnDied(Unit * mKiller)
        {
            const char * gname = ((Player*)mKiller)->GetGuild()->GetGuildName();
            const char * cname = ((Creature*)_unit)->GetCreatureInfo()->Name;
            uint32 id = _unit->GetEntry();
            QueryResult * qres = WorldDatabase.Query("SELECT * FROM `firstbosskills` WHERE `entryid` = '%u'", id);
            if(!qres)
                WorldDatabase.Execute("INSERT INTO `firstbosskills` VALUES(%u,%s,%s);",id,gname,cname);
        }
    
        void Destroy()
        {
            delete (AddFirstKillAI*)this;
        }
    
        static CreatureAIScript *Create(Creature * c) { return new AddFirstKillAI(c); }
    };
    
    
    void SetupFirstBossKill(ScriptMgr * mgr)
    {
        mgr->register_hook(SERVER_HOOK_EVENT_ON_CHAT, &BossCommands);
    
        QueryResult * qres = WorldDatabase.Query("SELECT * FROM `bossids`;");
            if(!qres)
                return;
        int count = qres->GetRowCount();
        for(int i = 0;i >= count;i++)
        {
            Field * fields = qres->Fetch();
            uint32 id = fields[0].GetUInt32();
            mgr->register_creature_script(id, &AddFirstKillAI::Create);
            qres->NextRow();
        }
    }
    SQL
    Code:
    CREATE TABLE "bossids" (
      "entry" int(10) unsigned default NULL
    );
    
    
    CREATE TABLE "firstbosskills" (
      "entryid" int(10) unsigned default NULL,
      "guildname" text,
      "creaturename" text,
      UNIQUE KEY "entryid" ("entryid")
    );
    #boss x - x is the entryid of the boss use this and it will look up the npc and find out who first killed it

    #bosslookup x - x is the name of the npc no spaces can be used it will search and return entry ids

    #addboss x - x is the entry id and this will add the npc to the database of first killed npcs, also alternatively you can select an npc and just type'#addboss' without any entry id and it will work

    Lunar Scriptor Website


    Enjoy leave feedback

    -- Edit --

    Thanks you AzolexX for alerting me the difference in Entry and Guid
    Last edited by mager1794; 12-25-2009 at 11:37 PM.
    Lunar Gaming - Reaching For The Stars

    [C++] BossTrack v1.0
  2. #2
    stoneharry's Avatar Moderator Harry

    Authenticator enabled
    Reputation
    1613
    Join Date
    Sep 2007
    Posts
    4,554
    Thanks G/R
    151/146
    Trade Feedback
    0 (0%)
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Very nice, your original ideas that you put into reality always amazes me. +Rep if I can.

  3. #3
    mager1794's Avatar Member
    Reputation
    356
    Join Date
    Feb 2008
    Posts
    703
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks stoneharry right now I pretty much just finished a second version of this and im almost ready to release

    The new version will be easier on the newbies because its fully database ran all you have to do is select in npc and type #addboss

    rather than actually registering a creature in a script
    Lunar Gaming - Reaching For The Stars

  4. #4
    Link_S's Avatar Member
    Reputation
    125
    Join Date
    Dec 2008
    Posts
    293
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The prettiest part is the function "vector<string> * command(string str)", really impressive. +Rep if I can.
    Why do I need a signature?

  5. #5
    mager1794's Avatar Member
    Reputation
    356
    Join Date
    Feb 2008
    Posts
    703
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the compliments guys, i worked hard on this, enjoy
    Lunar Gaming - Reaching For The Stars

  6. #6
    Hellgawd's Avatar Account not activated by Email
    Reputation
    710
    Join Date
    Jun 2007
    Posts
    2,480
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Another unique, great release from Mager.
    Keep the scripts comin; the emulation section is coming alive again!

  7. #7
    Kiev's Avatar Contributor
    Reputation
    288
    Join Date
    Nov 2007
    Posts
    1,819
    Thanks G/R
    0/4
    Trade Feedback
    3 (100%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Where you get the ideas for this i dont know.

    Epic. +Rep

  8. #8
    Valmere's Avatar Contributor
    Reputation
    166
    Join Date
    Apr 2007
    Posts
    362
    Thanks G/R
    16/31
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Pretty cool release, too bad I'm not a lunar person
    wat

  9. #9
    Trle94's Avatar Contributor
    Reputation
    167
    Join Date
    May 2009
    Posts
    329
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This new version is EPIC!!! And it was so fast update good job!! +Rep


  10. #10
    mager1794's Avatar Member
    Reputation
    356
    Join Date
    Feb 2008
    Posts
    703
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Pretty cool release, too bad I'm not a lunar person


    Whats wrong with Lunar
    Last edited by stoneharry; 12-23-2009 at 03:12 PM.
    Lunar Gaming - Reaching For The Stars

  11. #11
    Valmere's Avatar Contributor
    Reputation
    166
    Join Date
    Apr 2007
    Posts
    362
    Thanks G/R
    16/31
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by mager1794 View Post
    Whats wrong with Lunar
    [/COLOR]
    Didn't say anything was wrong with it, its just not for me
    wat

  12. #12
    mager1794's Avatar Member
    Reputation
    356
    Join Date
    Feb 2008
    Posts
    703
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh lol

    Guess I interpretted it wrong, glad you liked the script though.
    Last edited by mager1794; 12-23-2009 at 03:17 PM.
    Lunar Gaming - Reaching For The Stars

  13. #13
    Sounddead's Avatar Contributor
    Reputation
    160
    Join Date
    Sep 2007
    Posts
    1,126
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Good job mager

    I live in a shoe

  14. #14
    s0rs's Avatar Member

    Reputation
    1
    Join Date
    Jun 2009
    Posts
    21
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Looks nice... not that I dabble with private servers anymore, but well done

  15. #15
    mager1794's Avatar Member
    Reputation
    356
    Join Date
    Feb 2008
    Posts
    703
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmmm, peoples not posting anymore. Guys if you enjoy the script please post back
    Lunar Gaming - Reaching For The Stars

Page 1 of 2 12 LastLast
All times are GMT -5. The time now is 08:40 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search