Welcome to AC Web.
Results 1 to 13 of 13
  1. #1

    [C++] Buff command help

    Severity Code Description Project File Line Suppression State
    Error (active) E0317 return type is not identical to nor covariant with return type "std::vector<ChatCommand, std::allocator<ChatCommand>>" of overridden virtual function "CommandScript::GetCommands" scripts c:\Trinity\Source\src\server\scripts\Custom\buff_c ommand.cpp 23

    Code:
     ChatCommand* GetCommands() const;
    GetCommands() Has red wavy lines around it, and I get the error up above.

  2. #2

  3. #3
    Okay, also how do I fix this red wavy code
    Code:
    void AddSC_buffcommand()
    {
        new buffcommand();
    }
    - - - Updated - - -

    Severity Code Description Project File Line Suppression State
    Error (active) E0322 object of abstract class type "buffcommand" is not allowed: scripts c:\Trinity\Source\src\server\scripts\Custom\buff_c ommand.cpp 59
    ------------------------------------------------------------------------------------------------------
    Severity Code Description Project File Line Suppression State
    Error C2259 'buffcommand': cannot instantiate abstract class scripts C:\Trinity\Source\src\server\scripts\Custom\buff_c ommand.cpp 59

  4. #4
    could help if u posted the script on pastebin

  5. #5
    Code:
    #include "ScriptPCH.h"
    #include "Chat.h"
    #include "RBAC.h"
    #include "ScriptMgr.h"
    #include "Channel.h"
    #include "ChannelMgr.h"
    -#include "Chat.h" (removed)
    #include "DatabaseEnv.h"
    #include "DBCStores.h"
    #include "Language.h"
    #include "ObjectAccessor.h"
    #include "ObjectMgr.h"
    #include "Player.h"
    #include "RBAC.h"
    #include "World.h"
    #include "WorldSession.h"
    #include "Define.h"
    #include "Common.h"
    #include "Commands\cs_message.cpp"
    #include "ScriptMgr.h"
     uint32 auras[] = { 48162, 48074, 48170, 43223, 36880, 467, 48469 };
     
    class buffcommand : public CommandScript
    {
    public:
        buffcommand() : CommandScript("buffcommand") { }
     
        std::vector<ChatCommand> GetCommands() const = 0;
     
            static bool HandleBuffCommand(ChatHandler * handler, const char * args)
        {
            Player * pl = handler->GetSession()->GetPlayer();
                    if(pl->InArena())
                    {
                            pl->GetSession()->SendNotification("You can't use that item in an arena match!");
                            return false;
                    }
           
                    pl->RemoveAurasByType(SPELL_AURA_MOUNTED);
                    for(int i = 0; i < 7; i++)
                        pl->AddAura(auras[i], pl);
                    handler->PSendSysMessage("|cffB400B4You have been buffed, enjoy!");
                    return true;
     
        }
    };
     
    void AddSC_buffcommand()
    {
        new buffcommand();
    }
    Don't mind my includes, I was just trying shit xD
    Last edited by grip27; 11-27-2017 at 03:15 AM.

  6. #6
    Code:
    #include "ScriptMgr.h"
    #include "Chat.h"
    #include "Player.h"
     uint32 auras[] = { 48162, 48074, 48170, 43223, 36880, 467, 48469 };
     
    class buffcommand : public CommandScript
    {
    public:
        buffcommand() : CommandScript("buffcommand") { }
     
        std::vector<ChatCommand> GetCommands() const override
        {
            static std::vector<ChatCommand> commandTable =
            {
                 "buff",        rbac:: RBAC_PERM_JOIN_DUNGEON_FINDER, true,  &HandleBuffCommand,  ""       },
            };
            return commandTable;
        }
            static bool HandleBuffCommand(ChatHandler * handler, const char * /*args*/)
        {
            Player * pl = handler->GetSession()->GetPlayer();
                    if(pl->InArena())
                    {
                            pl->GetSession()->SendNotification("You can't use that item in an arena match!");
                            return false;
                    }
           
                    pl->RemoveAurasByType(SPELL_AURA_MOUNTED);
                    for(int i = 0; i < 7; i++)
                        pl->AddAura(auras[i], pl);
                    handler->PSendSysMessage("|cffB400B4You have been buffed, enjoy!");
                    return true;
     
        }
    };
     
    void AddSC_buffcommand()
    {
        new buffcommand();
    }
    try this

    untested, wrote it right in the code tags

  7. #7
    Severity Code Description Project File Line Suppression State
    Error (active) E0289 no instance of constructor "std::vector<_Ty, _Alloc>::vector [with _Ty=ChatCommand, _Alloc=std::allocator<ChatCommand>]" matches the argument list scripts c:\Trinity\Source\src\server\scripts\Custom\buff_c ommand.cpp 39

    - - - Updated - - -

    Severity Code Description Project File Line Suppression State
    Error (active) E0040 expected an identifier scripts c:\Trinity\Source\src\server\scripts\Custom\buff_c ommand.cpp 41

    Severity Code Description Project File Line Suppression State
    Error (active) E0169 expected a declaration scripts c:\Trinity\Source\src\server\scripts\Custom\buff_c ommand.cpp 42
    Severity Code Description Project File Line Suppression State
    Error (active) E0169 expected a declaration scripts c:\Trinity\Source\src\server\scripts\Custom\buff_c ommand.cpp 60

  8. #8
    uh which visual studio are u using

  9. #9
    2017 enterprise

    - - - Updated - - -

    nevermind you just forgot a bracket
    Code:
    {"buff",        rbac::RBAC_PERM_JOIN_DUNGEON_FINDER, true,  &HandleBuffCommand,  "" },
    - - - Updated - - -

    Anyways, Thanks mate.

  10. #10
    Oops didn't notice, glad you got it solved.

  11. #11
    weird like that

    Join Date
    Feb 2010
    Location
    http://rochet2.github.io/
    Posts
    5,281
    Quote Originally Posted by grip27 View Post
    Code:
    {"buff",        rbac::RBAC_PERM_JOIN_DUNGEON_FINDER, true,  &HandleBuffCommand,  "" },
    btw the true should be false since you use handler->GetSession() without checking that it is null.
    the true/false toggles whether the command can be used from console or not. atm it would crash from console.

  12. #12
    Quote Originally Posted by Rochet2 View Post
    btw the true should be false since you use handler->GetSession() without checking that it is null.
    the true/false toggles whether the command can be used from console or not. atm it would crash from console.
    Didn't notice that @ https://github.com/TrinityCore/Trini...e75b8e7bb6fR50 ,learned something new, thanks~!

  13. #13
    try it

    #include "ScriptMgr.h"
    #include "Chat.h"
    #include "Player.h"

    uint32 auras[] = { 48162, 48074, 48170, 43223, 36880, 467, 48469 };

    class buffcommand : public CommandScript
    {
    public:
    buffcommand() : CommandScript("buffcommand") { }

    std::vector<ChatCommand> GetCommands() const override
    {
    static std::vector<ChatCommand> commandTable =
    {
    { "buff", SEC_PLAYER, false, &HandlePremiumBuffCommand, "" },
    };
    return commandTable;
    }

    static bool HandleBuffCommand(ChatHandler * handler, const char * /*args*/)
    {
    Player * pl = handler->GetSession()->GetPlayer();

    bool return_type;

    if(pl->InArena())
    {
    pl->GetSession()->SendNotification("You can't use that item in an arena match!");
    return_type = false;
    }
    else
    {
    pl->RemoveAurasByType(SPELL_AURA_MOUNTED);
    for(int i = 0; i < 7; i++)
    pl->AddAura(auras[i], pl);
    handler->PSendSysMessage("|cffB400B4You have been buffed, enjoy!");
    return_type = true;
    }
    }
    };

    void AddSC_buffcommand()
    {
    new buffcommand();
    }

 

 

Posting Permissions

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