• This is a read only backup of the old Emudevs forum. If you want to have anything removed, please message me on Discord: KittyKaev

TrinityCore 3.3.5 Npc Innkeeper C++

Lstm

Respected Member
I'm trying to create a npc innkeeper in C ++, however it is not saving location
What am I doing wrong?

my script

Code:
#include "ScriptMgr.h"
#include "ObjectMgr.h"
#include "MapManager.h"
#include "Chat.h"
#include "Common.h"
#include "Language.h"
#include "CellImpl.h"
#include "GridNotifiers.h"
#include "ScriptedGossip.h"

class MTG_Utilitarios : public CreatureScript
{
public: MTG_Utilitarios() : CreatureScript("MTG_Utilitarios") {}

		bool OnGossipHello(Player* player, Creature* creature)
		{
			player->ADD_GOSSIP_ITEM(9, "|TInterface/Icons/INV_MISC_RUNE_01:40:40:-14|tHearthstone", GOSSIP_SENDER_MAIN, 1);
			player->ADD_GOSSIP_ITEM(9, "|TInterface/Icons/INV_Misc_Bag_07:40:40:-14|tBank", GOSSIP_SENDER_MAIN, 2);
			player->ADD_GOSSIP_ITEM(9, "|TInterface/Icons/INV_Letter_11:40:40:-14|tMail", GOSSIP_SENDER_MAIN, 3);
			player->PlayerTalkClass->SendGossipMenu(1, creature->GetGUID());
			return true;
		}

		bool OnGossipSelect(Player* player, Creature* creature, uint32 /*uiSender*/, uint32 uiAction)
		{
			if (player->IsInCombat())
			{
				player->CLOSE_GOSSIP_MENU();
				player->GetSession()->SendNotification("Você está em combate!", LANG_UNIVERSAL, player);
				return true;
			}

			player->PlayerTalkClass->ClearMenus();

			switch (uiAction)
			{
			[COLOR="#FFFF00"]case 1:	// HEARTH STONE
				player->CLOSE_GOSSIP_MENU();
				player->SetBindPoint->(GetPositionX, GetPositionY, GetPositionZ, GetOrientation, GetMapId, GetZoneId);[/COLOR]
				break;

			case 2:	// BANK
				player->CLOSE_GOSSIP_MENU();
				player->GetSession()->SendShowBank(player->GetGUID());
				break;

			case 3: // MAIL
				player->CLOSE_GOSSIP_MENU();
				player->GetSession()->SendShowMailBox(player->GetGUID());
				break;

			}

			return true;
		}
};



void AddSC_MTG_Utilitarios()
{
	new MTG_Utilitarios;
}

- - - Updated - - -

I've tried that way too

player->SetBindPoint(player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetMapId(), player->GetZoneId());
 

Rochet2

Moderator / Eluna Dev
Your NPC likely needs the innkeeper NPCflag have you set it?
It seems the bind position is set by a spell ultimately, so casting the spell on the player could also be used.

what does not work mean exactly? Does the game ask you if you want to set the location?
 

Tommy

Founder
yes, compiles haha
http://prntscr.com/b25jjy

It did not work the innkeeper: /

How is it compiling? It only takes one argument because it only has one parameter.

Code:
[URL="https://github.com/TrinityCore/TrinityCore/blob/3.3.5/src/server/game/Entities/Player/Player.cpp#L9363"]Player->SetBindPoint[/URL]

Are you using an older TrinityCore source you haven't mentioned? Because it should be:

Code:
player->SetBindPoint(creature->GetGUID());


Some more advice below.

Why do you have the combat check in OnGossipSelect? It is more logical to have it in OnGossipHello because that's before they click a menu option. It should also 'return false;' and not true as you don't want players to continue past it which makes the statement useless.

Secondly:

Code:
player->PlayerTalkClass->SendGossipMenu(1, creature->GetGUID());

There's a define directive just like "player->CLOSE_GOSSIP_MENU();" and it is:

Code:
player->GOSSIP_SEND_MENU(1, creature->GetGUID());

And I'm pretty sure half of those "#include" aren't needed. You should only include files if they are needed.

Cleaned up:

Code:
#include "ScriptMgr.h"
#include "ScriptedGossip.h"

class MTG_Utilitarios : public CreatureScript
{
public:
    MTG_Utilitarios() : CreatureScript("MTG_Utilitarios") {}

    bool OnGossipHello(Player* player, Creature* creature)
    {
        if (player->IsInCombat())
        {
            player->CLOSE_GOSSIP_MENU();
            player->GetSession()->SendNotification("Você está em combate!", LANG_UNIVERSAL, player);
            return false;
        }

        player->ADD_GOSSIP_ITEM(9, "|TInterface/Icons/INV_MISC_RUNE_01:40:40:-14|tHearthstone", GOSSIP_SENDER_MAIN, 1);
        player->ADD_GOSSIP_ITEM(9, "|TInterface/Icons/INV_Misc_Bag_07:40:40:-14|tBank", GOSSIP_SENDER_MAIN, 2);
        player->ADD_GOSSIP_ITEM(9, "|TInterface/Icons/INV_Letter_11:40:40:-14|tMail", GOSSIP_SENDER_MAIN, 3);
        player->SEND_GOSSIP_MENU(1, creature->GetGUID());
        return true;
    }

    bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action)
    {
        player->PlayerTalkClass->ClearMenus();

        switch (action)
        {			
            case 1:	// HEARTH STONE
                player->CLOSE_GOSSIP_MENU();
                player->SetBindPoint(creature->GetGUID());
                break;
            case 2:	// BANK
                player->CLOSE_GOSSIP_MENU();
                player->GetSession()->SendShowBank(player->GetGUID());
                break;
            case 3: // MAIL
                player->CLOSE_GOSSIP_MENU();
                player->GetSession()->SendShowMailBox(player->GetGUID());
                break;

        }

        return true;
    }
};



void AddSC_MTG_Utilitarios()
{
    new MTG_Utilitarios;
}
 

Lstm

Respected Member
The review I am using the trinity is the last, I am learning to ride scripts in C ++ still lack a lot hahaha
I do not know many functions still good that I am taking all my doubts with you (s) and acquiring more knowledge in the area
 
Top