Welcome to AC Web.
Results 1 to 3 of 3

Thread: C++ Teleporter

  1. #1


    Join Date
    Sep 2014
    Location
    nloli#6788 - I dont answer PMs
    Posts
    446

    C++ Teleporter


    REGISTER! (FREE)
    Registered members see less ads
    and also gain access to other great features.
    Trying to make a C++ teleporter but im getting an error ive never experienced before, since I was somewhat inactive with C++ in the past 2 years and trinitycore functions have changed again and Im generally very bad with C++, I just know how to copy paste and do simple edits, this error is confusing me, never saw it before:
    Code:
    error C2259: 'Teleporter': cannot instantiate abstract class
    note: due to following members:
    note: 'CreatureAI *CreatureScript::GetAI(Creature *) const': is abstract
    note: see declaration of 'CreatureScript::GetAI'
    here's the teleporter script:
    https://pastebin.com/x0gH8NUb

    Got an updated TC version (last 1month~ ago)
    I put in a lot of #includes because I thought that would help
    Last edited by Project2k14; 08-10-2019 at 05:50 PM.

  2. #2
    fixed it for you:

    Code:
    #include "ScriptPCH.h"
    
    //====== Defined Locations =======
    const WorldLocation mallLoc(571, 5505.55f, 4748.57f, -194.433f, 2.5689f);
    const WorldLocation direMaulLoc(1, -3761.47f, 1137.59f, 131.099f, 4.7281f);
    
    class Teleporter : public  CreatureScript
    {
    public:
        Teleporter() : CreatureScript("Teleporter")
        {
        }
    
        static bool OnGossipHello(Player* player, Creature* creature)
        {
            if (player->IsInCombat())
            {
                creature->Whisper("You're in combat.", LANG_UNIVERSAL, player);
                return true;
            }
            AddGossipItemFor(player, 1, "|TInterface/ICONS/achievement_zone_westfall_01:35:35:-23:0|t Moonbrook", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2);
            AddGossipItemFor(player, 1, "|TInterface/ICONS/achievement_zone_sholazar_01:35:35:-23:0|t [Mall] River's Heart", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3);
            AddGossipItemFor(player, 1, "|TInterface/ICONS/achievement_arena_2v2_7:35:35:-23:0|t [PvP] Dire Maul Arena", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4);
            AddGossipItemFor(player, 1, "Nevermind ..", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
            player->PlayerTalkClass->SendGossipMenu(1, creature->GetGUID());
            return true;
        }
    
        static bool OnGossipSelect(Player* player, Creature* creature, uint32 Sender, uint32 action)
        {
            player->PlayerTalkClass->ClearMenus();
    
            if (player->IsInCombat())
            {
                creature->Whisper("You're in combat.", LANG_UNIVERSAL, player);
                return true;
            }
    
            switch (action)
            {
            case GOSSIP_ACTION_INFO_DEF + 1:
                break;
            case GOSSIP_ACTION_INFO_DEF + 2:
                player->TeleportTo(0, -10936.608398f, 1424.476196f, 42.965355f, 2.962100f);
                creature->Whisper("You've been teleported to Moonbrook.", LANG_UNIVERSAL, player);
                break;
            case GOSSIP_ACTION_INFO_DEF + 3:
                player->TeleportTo(mallLoc);
                creature->Whisper("You've been teleported to the Mall.", LANG_UNIVERSAL, player);
                break;
            case GOSSIP_ACTION_INFO_DEF + 4:
                player->TeleportTo(direMaulLoc);
                creature->Whisper("You've been teleported to the PvP Arena.", LANG_UNIVERSAL, player);
                break;
            }
    
            player->PlayerTalkClass->SendCloseGossip();
            return true;
        }
    
        class TeleporterAI : public ScriptedAI
        {
        public:
            TeleporterAI(Creature* creature) : ScriptedAI(creature) {}
    
            bool GossipHello(Player* player) override
            {
                return OnGossipHello(player, me);
            }
    
            bool GossipSelect(Player* player, uint32 /*menu_id*/, uint32 gossipListId) override
            {
                int32 sender = player->PlayerTalkClass->GetGossipOptionSender(gossipListId);
                int32 action = player->PlayerTalkClass->GetGossipOptionAction(gossipListId);
                return OnGossipSelect(player, me, sender, action);
            }
        };
    
        CreatureAI* GetAI(Creature* creature) const override
        {
            return new TeleporterAI(creature);
        }
    };
    
    void AddSC_Teleporter()
    {
        new Teleporter();
    }

  3. #3


    Join Date
    Sep 2014
    Location
    nloli#6788 - I dont answer PMs
    Posts
    446

    REGISTER! (FREE)
    Registered members see less ads
    and also gain access to other great features.
    Thanks its working just fine
    would give +rep but I can't yet :/

 

 

Posting Permissions

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