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

[Tc, 4.3.4] Donor Npc

YouarexD

Exalted Member
Hello

This is my first c++ script. This script is for
a dispenser of NPC. This NPC has just four menu points.

Menu:
Level 85
-Change race
-Change faction
-Change character

Here are a few pictures.

wPGwnZ6.jpg


932m09p.jpg


Jy8IT2f.jpg


-----> here download <-----

Still menu do you have suggestions?
Then I write it to me trying to insert it.

Changes in your donor ID (49623) item

nice greetings

YouarexD
 
Last edited:

Tommy

Founder
Thanks for the script! It's great for a first time C++ script; However, things could be simplified. I took the liberty in updating it:

You forgot to call 'player->PlayerTalkClass->ClearMenus();' to clear the menus in 'OnGossipSelect'.

Code:
/*
    Script_Discription: Donor Npc he set your level to 85! Other menu´s cooming soon!
    Scripted by : YouarexD (http://emudevs.com)
*/
 
class donor_npc : public CreatureScript
{
public:
    donor_npc() : CreatureScript("donor_npc") { }
 
    bool OnGossipHello(Player* player, Creature* creature)
    {
        if (player->IsInCombat())
        {
            player->GetSession()->SendNotification("Bitte verlassen sie den Kampf!");
            return false;
        }
 
        player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "|cffFF0000Level :|r 85", GOSSIP_SENDER_MAIN, 1);
        player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Rasse wechseln", GOSSIP_SENDER_MAIN, 2);
        player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Fraktion wechseln", GOSSIP_SENDER_MAIN, 3);
        player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Character bearbeiten", GOSSIP_SENDER_MAIN, 4);
        player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Nevermind", GOSSIP_SENDER_MAIN, 99);
        player->SEND_GOSSIP_MENU(1, creature->GetGUID());
        return true;
    }
 
    bool OnGossipSelect(Player* player, Creature* creature, uint32 /* sender */, uint32 actions)
    {
        player->PlayerTalkClass->ClearMenus();
        if (actions == 1)
            DoAction(player, 49623, 1, AT_LOGIN_NONE, "Herzlichen Glueckwunsch! Sie wurden erfolgreich auf Level 85 gelevelt!");
        else if (actions == 2)
            DoAction(player, 49623, 1, AT_LOGIN_CHANGE_RACE, "Du musst dich neu einloggen, um deine Rasse zu wechseln!");
        else if (actions == 3)
            DoAction(player, 49623, 1, AT_LOGIN_CHANGE_FACTION, "Du musst dich neu einloggen, um deine Fraktion zu wechseln!");
        else if (actions == 4)
            DoAction(player, 49623, 1, AT_LOGIN_CUSTOMIZE, "Du musst dich neu einloggen, um deinen Character zu bearbeiten!");
        player->CLOSE_GOSSIP_MENU();
        return true;
    }
	
    void DoAction(Player* player, uint32 itemId, int count, AtLoginFlags loginFlags, const char* text)
    {
        if (player->HasItemCount(itemId, count, false))
        {
            player->DestroyItemCount(itemId, 1, true);
            if (loginFlags != AT_LOGIN_NONE)
                player->SetAtLoginFlag(loginFlags);
            else
                player->SetLevel(85);
            player->GetSession()->SendNotification(text);
        }
    }
};
 
void AddSC_donor_npc()
{
    new donor_npc();
}
 
Top