User Tag List

Results 1 to 4 of 4

Thread: Profession Teleporter

  1. #1
    Enthusiast
    Join Date
    May 2014
    Location
    LocalHost
    Posts
    11
    XP
    1,781
    Level
    11
    Thanks
    7
    Thanked 4 Times in 2 Posts

    Post Profession Teleporter

    H! Emu Devies,
    This is my first C++ Script, Umm Idk Its Exist or NOT in But I Made it!
    Code:
    class Profession_Teleporter : CreatureScript
    {
    public:
        Profession_Teleporter() : CreatureScript("Profession_Teleporter") { }
    
        bool OnGossipHello(Player* player, Creature* creature) 
        { 
            if (player->IsInCombat()) // Check If Player Is In Combat!
            {
                player->GetSession()->SendNotification("Ummm Sorry! You Are In Combat!");
                player->CLOSE_GOSSIP_MENU();
                return false;
            }
             
            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "|TInterface\\icons\\Trade_Alchemy:30|t  Alchemy Trainer", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "|TInterface\\icons\\Trade_BlackSmithing:30|t  Blacksmithing Trainer", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2);
            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "|TInterface\\icons\\INV_Misc_Food_17:30|t  Cooking Trainer", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3);
            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "|TInterface\\icons\\Trade_Engraving:30|t  Enchanting Trainer", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4);
            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "|TInterface\\icons\\Trade_Engineering:30|t  Engineering Trainer", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5);
            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "|TInterface\\icons\\Achievement_BG_winSOA_underXminutes:30|t  First Aid Trainer", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6);
            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "|TInterface\\icons\\Trade_Fishing:30|t  Fishing Trainer", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 7);
            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "|TInterface\\icons\\Trade_Herbalism:30|t  Herbalism Trainer", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 8);
            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "|TInterface\\icons\\INV_Inscription_Tradeskill01:30|t  Inscription Trainer", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 9);
            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "|TInterface\\icons\\INV_Misc_Gem_01:30|t  Jewelcrafting Trainer", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 10);
            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "|TInterface\\icons\\Trade_LeatherWorking:30|t  Leatherworking Trainer", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 11);
            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "|TInterface\\icons\\Trade_Mining:30|t  Mining Trainer", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 12);
            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "|TInterface\\icons\\INV_Chest_Leather_17B:30|t  Skinning Trainer", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 13);
            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "|TInterface\\icons\\Trade_Tailoring:30|t  Tailoring Trainer", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 14);
            player->SEND_GOSSIP_MENU(1, creature->GetGUID());
    
            return true; 
        }
    
        bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 actions) 
        { 
            player->PlayerTalkClass->ClearMenus();
            switch (actions)
            {
                case GOSSIP_ACTION_INFO_DEF + 1:
                    player->TeleportTo(571, 5897.17f, 710.857f, 642.047f, 4.05559f);
                    break;
                case GOSSIP_ACTION_INFO_DEF + 2:
                    player->TeleportTo(571, 5897.31f, 687.73f, 642.226f, 5.48005f);
                    break;
                case GOSSIP_ACTION_INFO_DEF + 3:
                    if (player->GetTeam() == HORDE)
                        player->TeleportTo(571, 5856.23f, 469.502f, 639.796f, 2.56461f);
                    else 
                        player->TeleportTo(571, 5704.55f, 715.124f, 642.475f, 2.55934f);
    		break;
                case GOSSIP_ACTION_INFO_DEF + 4:
                    player->TeleportTo(571, 5831.55f, 715.347f, 640.949f, 0.884089f);
                    break;
                case GOSSIP_ACTION_INFO_DEF + 5:
                    player->TeleportTo(571, 5912.26f, 728.859f, 641.194f, 6.22951f);
                    break;
                case GOSSIP_ACTION_INFO_DEF + 6:
                    player->TeleportTo(571, 5866.21f, 735.482f, 639.531f, 2.00328f);
                    break;
                case GOSSIP_ACTION_INFO_DEF + 7:
                    player->TeleportTo(571, 5702.65f, 616.026f, 646.733f, 5.79517f);
                    break;
                case GOSSIP_ACTION_INFO_DEF + 8:
                    player->TeleportTo(571, 5870.35f, 684.824f, 643.31f, 0.84559f);
                    break;
                case GOSSIP_ACTION_INFO_DEF + 9:
                    player->TeleportTo(571, 5854.94f, 695.134f, 641.949f, 0.963398f);
                    break;
                case GOSSIP_ACTION_INFO_DEF + 10:
                    player->TeleportTo(571, 5872.45f, 727.237f, 643.212f, 4.9862f);
                    break;
                case GOSSIP_ACTION_INFO_DEF + 11:
                    player->TeleportTo(571, 5905.92f, 754.916f, 641.073f, 1.27871f);
                    break;
                case GOSSIP_ACTION_INFO_DEF + 12:
                    player->TeleportTo(571, 5922.1f, 711.743f ,642.515f, 6.18113f);
                    break;
                case GOSSIP_ACTION_INFO_DEF + 13:
                    player->TeleportTo(571, 5908.69f, 757.053f, 641.081f, 1.45068f);
                    break;
                case GOSSIP_ACTION_INFO_DEF + 14:
                    player->TeleportTo(571, 5880.02f, 748.165f, 640.372f, 1.83633f);
                    break;
            }
            player->CLOSE_GOSSIP_MENU();
    
            return true; 
        }
    };
        
    void AddSC_Profession_Teleporter()
    {
        new Profession_Teleporter();
    }
    Last edited by ImperialDev; 05-10-2014 at 09:56 AM. Reason: For Fun!
    Achievements:
    1 year registered Level X

  2. The Following 2 Users Say Thank You to ImperialDev For This Useful Post:


  3. #2
    Founder <span style='color: #FF4500'>Tommy</span>'s Avatar
    Join Date
    Apr 2013
    Posts
    7,391
    XP
    3,449,104
    Level
    378
    Thanks
    889
    Thanked 1,856 Times in 1,119 Posts
    Very nice for a first. However, let me give you some future advice.

    You don't need to include 'ScriptPCH.h'. It's pretty much already handled via CMake and other sources.
    Code could have better indentation. It's pretty messy.
    Capitalizing variables such as 'Player* Player' and 'Creature* Creature' isn't what you should be doing in my opinion. Surprisingly enough I'm surprised it won't throw an error due to your variables having the same name as the class names. It would be best to do 'Player* player' and 'Creature* creature'.
    Brackets look much better if you unify them. Example:

    Before:
    Code:
    {}
    After:
    Code:
    { }
    Code such as 'player->PlayerTalkClass->SendCloseGossip();' can be replaced with the more simple define directive: 'player->CLOSE_GOSSIP_MENU();'

    Not sure what the intent is here:

    Code:
    virtual bool OnGossipSelect
    The 'virtual' isn't needed.

    The 'sender' parameter can be commented out as it is rarely/never used:

    Code:
    bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action)
    The code checking 'sender' can be removed too.

    The if statement checking if a player is Horde or Alliance can be changed from:

    Code:
                    if (player->GetTeam() == HORDE)
    		{
                        player->TeleportTo(571, 5856.23f, 469.502f, 639.796f, 2.56461f); 
    		    return false; 
                    } // Check Player is Horde Or Aliance And TP Near NPC!
                    else 
                    { 
                        player->TeleportTo(571, 5704.55f, 715.124f, 642.475f, 2.55934f); 
                        return false; 
                    }
    to:

    Code:
                    if (player->GetTeam() == HORDE)
                        player->TeleportTo(571, 5856.23f, 469.502f, 639.796f, 2.56461f); 
                    else 
                        player->TeleportTo(571, 5704.55f, 715.124f, 642.475f, 2.55934f);
    In any if statement like this, there is no need to call 'return false' at any point. The else can skip Horde if the player is Alliance.
    Lastly, your cases are pretty messy in my perspective.


    Cleaned outcome:

    Code:
    class Profession_Teleporter : CreatureScript
    {
    public:
        Profession_Teleporter() : CreatureScript("Profession_Teleporter") { }
    
        bool OnGossipHello(Player* player, Creature* creature) 
        { 
            if (player->IsInCombat()) // Check If Player Is In Combat!
            {
                player->GetSession()->SendNotification("Ummm Sorry! You Are In Combat!");
                player->CLOSE_GOSSIP_MENU();
                return false;
            }
             
            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "|TInterface\\icons\\Trade_Alchemy:30|t  Alchemy Trainer", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "|TInterface\\icons\\Trade_BlackSmithing:30|t  Blacksmithing Trainer", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2);
            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "|TInterface\\icons\\INV_Misc_Food_17:30|t  Cooking Trainer", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3);
            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "|TInterface\\icons\\Trade_Engraving:30|t  Enchanting Trainer", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4);
            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "|TInterface\\icons\\Trade_Engineering:30|t  Engineering Trainer", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5);
            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "|TInterface\\icons\\Achievement_BG_winSOA_underXminutes:30|t  First Aid Trainer", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6);
            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "|TInterface\\icons\\Trade_Fishing:30|t  Fishing Trainer", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 7);
            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "|TInterface\\icons\\Trade_Herbalism:30|t  Herbalism Trainer", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 8);
            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "|TInterface\\icons\\INV_Inscription_Tradeskill01:30|t  Inscription Trainer", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 9);
            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "|TInterface\\icons\\INV_Misc_Gem_01:30|t  Jewelcrafting Trainer", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 10);
            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "|TInterface\\icons\\Trade_LeatherWorking:30|t  Leatherworking Trainer", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 11);
            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "|TInterface\\icons\\Trade_Mining:30|t  Mining Trainer", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 12);
            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "|TInterface\\icons\\INV_Chest_Leather_17B:30|t  Skinning Trainer", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 13);
            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "|TInterface\\icons\\Trade_Tailoring:30|t  Tailoring Trainer", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 14);
            player->SEND_GOSSIP_MENU(1, creature->GetGUID());
    
            return true; 
        }
    
        bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 actions) 
        { 
            player->PlayerTalkClass->ClearMenus();
            switch (actions)
            {
                case GOSSIP_ACTION_INFO_DEF + 1:
                    player->TeleportTo(571, 5897.17f, 710.857f, 642.047f, 4.05559f);
                    break;
                case GOSSIP_ACTION_INFO_DEF + 2:
                    player->TeleportTo(571, 5897.31f, 687.73f, 642.226f, 5.48005f);
                    break;
                case GOSSIP_ACTION_INFO_DEF + 3:
                    if (player->GetTeam() == HORDE)
                        player->TeleportTo(571, 5856.23f, 469.502f, 639.796f, 2.56461f);
                    else 
                        player->TeleportTo(571, 5704.55f, 715.124f, 642.475f, 2.55934f);
    		break;
                case GOSSIP_ACTION_INFO_DEF + 4:
                    player->TeleportTo(571, 5831.55f, 715.347f, 640.949f, 0.884089f);
                    break;
                case GOSSIP_ACTION_INFO_DEF + 5:
                    player->TeleportTo(571, 5912.26f, 728.859f, 641.194f, 6.22951f);
                    break;
                case GOSSIP_ACTION_INFO_DEF + 6:
                    player->TeleportTo(571, 5866.21f, 735.482f, 639.531f, 2.00328f);
                    break;
                case GOSSIP_ACTION_INFO_DEF + 7:
                    player->TeleportTo(571, 5702.65f, 616.026f, 646.733f, 5.79517f);
                    break;
                case GOSSIP_ACTION_INFO_DEF + 8:
                    player->TeleportTo(571, 5870.35f, 684.824f, 643.31f, 0.84559f);
                    break;
                case GOSSIP_ACTION_INFO_DEF + 9:
                    player->TeleportTo(571, 5854.94f, 695.134f, 641.949f, 0.963398f);
                    break;
                case GOSSIP_ACTION_INFO_DEF + 10:
                    player->TeleportTo(571, 5872.45f, 727.237f, 643.212f, 4.9862f);
                    break;
                case GOSSIP_ACTION_INFO_DEF + 11:
                    player->TeleportTo(571, 5905.92f, 754.916f, 641.073f, 1.27871f);
                    break;
                case GOSSIP_ACTION_INFO_DEF + 12:
                    player->TeleportTo(571, 5922.1f, 711.743f ,642.515f, 6.18113f);
                    break;
                case GOSSIP_ACTION_INFO_DEF + 13:
                    player->TeleportTo(571, 5908.69f, 757.053f, 641.081f, 1.45068f);
                    break;
                case GOSSIP_ACTION_INFO_DEF + 14:
                    player->TeleportTo(571, 5880.02f, 748.165f, 640.372f, 1.83633f);
                    break;
            }
            player->CLOSE_GOSSIP_MENU();
    
            return true; 
        }
    };
        
    void AddSC_Profession_Teleporter()
    {
        new Profession_Teleporter();
    }
    Nice job regardless. :P

  4. The Following User Says Thank You to Tommy For This Useful Post:


  5. #3
    Original Poster
    Enthusiast
    Join Date
    May 2014
    Location
    LocalHost
    Posts
    11
    XP
    1,781
    Level
    11
    Thanks
    7
    Thanked 4 Times in 2 Posts
    Lots Of Thanks Tommy!

  6. #4
    Emulation Addict
    Join Date
    Aug 2016
    Posts
    28
    XP
    497
    Level
    5
    Thanks
    3
    Thanked 1 Time in 1 Post
    for 4.3.4 you do not have?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •