[DiscordArchive] And you made your code all by yourself no reference wiki or anything?
[DiscordArchive] And you made your code all by yourself no reference wiki or anything?
Archived author: Whomadeit • Posted: 2025-01-31T16:58:06.991000+00:00
Original source
And you made your code all by yourself no reference wiki or anything?
Archived author: Whomadeit • Posted: 2025-01-31T16:58:10.023000+00:00
Original source
I’d be shocked
Archived author: Whomadeit • Posted: 2025-01-31T16:58:21.392000+00:00
Original source
lol
Archived author: Whomadeit • Posted: 2025-01-31T17:00:07.787000+00:00
Original source
Like this would work too depends if you want item or npc
Archived author: Whomadeit • Posted: 2025-01-31T17:00:09.811000+00:00
Original source
#include "Player.h"
#include "ScriptMgr.h"
#include "Creature.h"
#include "ObjectAccessor.h"
#include "Chat.h"
uint64 vendorNpcGuid = 0; // Global variable to track spawned vendor
void SendMenu_show_vendor(Player* player, Item* item)
{
uint32 vendor_id = 1234; // Replace with actual vendor NPC entry
uint32 distance = 2;
// Get player's current position
float playerX = player->GetPositionX();
float playerY = player->GetPositionY();
float playerZ = player->GetPositionZ();
float playerO = player->GetOrientation();
// Calculate summon position a few feet in front of the player
float summonX = playerX + distance * cos(playerO);
float summonY = playerY + distance * sin(playerO);
float summonZ = playerZ;
// Adjust summonZ if terrain height differs
summonZ = player->GetMap()->GetHeight(summonX, summonY, summonZ);
// Face NPC toward player
float npcOrientation = playerO + M_PI;
if (vendorNpcGuid)
{
// Find and despawn existing vendor
if (Creature* existingNpc = ObjectAccessor::GetCreature(*player, vendorNpcGuid))
{
if (existingNpc->IsInWorld())
existingNpc->DespawnOrUnsummon();
}
vendorNpcGuid = 0;
}
// Summon the vendor
if (Creature* summonedNpc = player->SummonCreature(vendor_id, summonX, summonY, summonZ, npcOrientation, TEMPSUMMON_MANUAL_DESPAWN, 300))
{
vendorNpcGuid = summonedNpc->GetGUID(); // Store NPC GUID for later reference
player->GetSession()->SendListInventory(summonedNpc->GetGUID(), summonedNpc->GetVendorEntries());
}
else
{
ChatHandler(player->GetSession()).PSendSysMessage("Failed to summon vendor. Please try again.");
}
}
Archived author: Thordekk • Posted: 2025-01-31T17:01:57.657000+00:00
Original source
wiki by hand like always
Archived author: Thordekk • Posted: 2025-01-31T17:02:07.265000+00:00
Original source
vendorNpcGuid = 0;
Archived author: Whomadeit • Posted: 2025-01-31T17:02:18.275000+00:00
Original source