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

[SOLVED] Not summon creature

Status
Not open for further replies.

jimteck

Emulation Addict
This script not work,i need summon random boses,but in compile no errors and gossip menu work,but creature not spawn

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


#define WAITTIME 1     // seconds
 
#define REWARD 43228    // item entry
#define AMOUNT 1     // amount of items
 
/* Warning Do not Spawn Bosses that are linked to instances such as algalon Lich king and so on so fourth outside of an instance , doing so will cause the core to crash */
 
 
class bossx_npc : public CreatureScript
{
public:
    bossx_npc() : CreatureScript("bossx_npc") { }
 
    bool OnGossipHello(Player * player, Creature * creature)
    {
        player->ADD_GOSSIP_ITEM(3, "I need spawn boss!", GOSSIP_SENDER_MAIN, 1);
        player->ADD_GOSSIP_ITEM(1, "Good bye...", GOSSIP_SENDER_MAIN, 0);
        player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
        return true;
    }
	
	bool OnCreatureSpawn(Player* player, Creature* npc)
{
    if (Creature* target = npc->FindNearestCreature(145, SIZE_OF_GRIDS, true))
        target->DespawnOrUnsummon();
}
 
    bool OnGossipSelect(Player * player, Creature * creature, uint32 sender, uint32 uiAction)
    {
        player->PlayerTalkClass->ClearMenus();
        if (uiAction == 1)
        {
            if(cooldowns.find(player->GetGUIDLow()) != cooldowns.end())
            {
                double diff = difftime(time(NULL), cooldowns[player->GetGUIDLow()]);
                if (diff < WAITTIME)
                {
                    player->GetSession()->SendNotification("You must whait 1 sec", diff);
                    OnGossipHello(player, creature);
                    return true;
                }
            }
 
                        cooldowns[player->GetGUIDLow()] = time(NULL);
                                return true;

                                 switch (urand(1, 4))
                                 {
                                 case 1:
									 player->SummonCreature(29793, player->GetPositionX(), player->GetPositionY() + 10, player->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 30000);
                     				 ChatHandler(player->GetSession()).PSendSysMessage("|cffff6060[Master caller]:|r Test 1!");
                                     break;
                                 case 2:
									 player->SummonCreature(29793, player->GetPositionX(), player->GetPositionY() + 10, player->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 30000);
                     				ChatHandler(player->GetSession()).PSendSysMessage("|cffff6060[Master caller]:|r Test 2..!");
                                    break;
                                 case 3:
									 player->SummonCreature(29793, player->GetPositionX(), player->GetPositionY() + 10, player->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 30000);
                     				 ChatHandler(player->GetSession()).PSendSysMessage("|cffff6060[Master caller]:|r Test 3!!");
                                     break;
                                 case 4:
									 player->SummonCreature(29793, player->GetPositionX(), player->GetPositionY() + 10, player->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 30000);
                     				ChatHandler(player->GetSession()).PSendSysMessage("|cffff6060[Master caller]:|r Test 4!");
                                    break;
            }
        }
 
        player->CLOSE_GOSSIP_MENU();
        return true;
    }

private:
	std::map<uint32, time_t> cooldowns;

	bool GiveItemAmount(Player * player, uint32 itemEntry, uint32 amount)
	{
		if (amount < 0)
		{
			player->DestroyItemCount(itemEntry, (-int(amount)), true, false);
			return true;
		}
		if (amount == 0)
			amount = 1;

		uint32 noSpaceForCount = 0;

		ItemPosCountVec dest;
		uint8 msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemEntry, amount, &noSpaceForCount);

		if (msg != EQUIP_ERR_OK)
			amount -= noSpaceForCount;

		if (amount == 0 || dest.empty())
			return false;

		Item* item = player->StoreNewItem(dest, itemEntry, true, Item::GenerateItemRandomPropertyId(43228));
		// player->SendNewItem(item, amount, true, false);
		return true;
	}
};
void AddSC_bossx_npc()
{
new bossx_npc();
}
 

Rochet2

Moderator / Eluna Dev
You should try look through the code and do some debugging with normal logging or prints or by a debugger.
See if the code you want to run is reached, if it is not, why is it not.. etc.

The error looks pretty clear. The spawning/summoning is never reached.
Would be great if you found out why. :)

ps. indentating the code properly and reading it through probably helps you spot the error. If not, then debugging will.
If summoning doesnt work, then think about what else does not happen that should happen.
 
Last edited:
Status
Not open for further replies.
Top