View difference between Paste ID: 5WnbVtbD and 3QJr7fJT
SHOW: | | - or go back to the newest paste.
1
// Original script by Ghostcrawler336
2
3
#include "ScriptPCH.h"
4
#define TOKEN_ID   60007   // Replace 60007 to YOUR_TOKEN_ID
5
6
class Level_NPC : public CreatureScript
7
{
8
public:
9-
	Level_NPC() : CreatureScript("Level_NPC") {}
9+
    Level_NPC() : CreatureScript("Level_NPC") {}
10
11-
	bool OnGossipHello(Player* pPlayer, Creature* _creature)
11+
    bool OnGossipHello(Player* pPlayer, Creature* _creature)
12-
	{
12+
    {
13-
		pPlayer->ADD_GOSSIP_ITEM(7, "Welcome to the level NPC!", GOSSIP_SENDER_MAIN, 0);
13+
        pPlayer->ADD_GOSSIP_ITEM(7, "Welcome to the level NPC!", GOSSIP_SENDER_MAIN, 0);
14-
		pPlayer->ADD_GOSSIP_ITEM(10, "Level 10(1 Token)", GOSSIP_SENDER_MAIN, 1);
14+
        pPlayer->ADD_GOSSIP_ITEM(10, "Level 10(10 Token)", GOSSIP_SENDER_MAIN, 1);
15-
		pPlayer->ADD_GOSSIP_ITEM(10, "Level 20(2 Tokens)", GOSSIP_SENDER_MAIN, 2);
15+
        pPlayer->ADD_GOSSIP_ITEM(10, "Level 20(20 Tokens)", GOSSIP_SENDER_MAIN, 2);
16-
		pPlayer->ADD_GOSSIP_ITEM(10, "Level 30(3 Tokens)", GOSSIP_SENDER_MAIN, 3);
16+
        pPlayer->ADD_GOSSIP_ITEM(10, "Level 30(30 Tokens)", GOSSIP_SENDER_MAIN, 3);
17-
		pPlayer->ADD_GOSSIP_ITEM(10, "Level 40(4 Tokens)", GOSSIP_SENDER_MAIN, 4);
17+
        pPlayer->ADD_GOSSIP_ITEM(10, "Level 40(40 Tokens)", GOSSIP_SENDER_MAIN, 4);
18-
		pPlayer->ADD_GOSSIP_ITEM(10, "Level 50(5 Tokens)", GOSSIP_SENDER_MAIN, 5);
18+
        pPlayer->ADD_GOSSIP_ITEM(10, "Level 50(50 Tokens)", GOSSIP_SENDER_MAIN, 5);
19-
		pPlayer->ADD_GOSSIP_ITEM(10, "Level 60(6 Tokens)", GOSSIP_SENDER_MAIN, 6);
19+
        pPlayer->ADD_GOSSIP_ITEM(10, "Level 60(60 Tokens)", GOSSIP_SENDER_MAIN, 6);
20-
		pPlayer->ADD_GOSSIP_ITEM(10, "Level 70(7 Tokens)", GOSSIP_SENDER_MAIN, 7);
20+
        pPlayer->ADD_GOSSIP_ITEM(10, "Level 70(70 Tokens)", GOSSIP_SENDER_MAIN, 7);
21-
		pPlayer->ADD_GOSSIP_ITEM(10, "Level 80(8 Tokens)", GOSSIP_SENDER_MAIN, 8);
21+
        pPlayer->ADD_GOSSIP_ITEM(10, "Level 80(80 Tokens)", GOSSIP_SENDER_MAIN, 8);
22
23-
		pPlayer->PlayerTalkClass->SendGossipMenu(907, _creature->GetGUID());
23+
        pPlayer->PlayerTalkClass->SendGossipMenu(907, _creature->GetGUID());
24-
		return true;
24+
        return true;
25-
	}
25+
    }
26
27-
	bool OnGossipSelect(Player* pPlayer, Creature* _creature, uint32 uiSender, uint32 uiAction)
27+
    bool OnGossipSelect(Player* pPlayer, Creature* _creature, uint32 uiSender, uint32 uiAction)
28-
	{
28+
    {
29-
		pPlayer->PlayerTalkClass->ClearMenus();
29+
        pPlayer->PlayerTalkClass->ClearMenus();
30-
		if(uiAction != 0)
30+
        if(uiAction != 0)
31-
			if (pPlayer->HasItemCount(TOKEN_ID, uiAction, true))
31+
            if (pPlayer->HasItemCount(TOKEN_ID, uiAction*10, false))
32-
			{
32+
            {
33-
				pPlayer->SetLevel(uiAction*10); // changed to setlevel, give level gives X amount of levels I think.
33+
                if(pPlayer->getLevel() >= 80)
34-
				pPlayer->DestroyItemCount(TOKEN_ID, uiAction, true);
34+
                {
35-
				pPlayer->GetSession()->SendAreaTriggerMessage("You are now Level %u!", uiAction*10);
35+
                    pPlayer->GetSession()->SendNotification("You are already level 80!");
36-
				pPlayer->PlayerTalkClass->SendCloseGossip();
36+
                }
37-
				return true;
37+
                else
38-
			}
38+
                {
39-
			else
39+
                    uint8 newlevel = pPlayer->getLevel()+uiAction*10;
40-
				pPlayer->GetSession()->SendNotification("You don't have the required token");
40+
                    if(newlevel > 80)
41-
		OnGossipHello(pPlayer, _creature);
41+
                        newlevel = 80;
42-
		return true;
42+
                    pPlayer->GiveLevel(newlevel);
43-
	}
43+
                    pPlayer->InitTalentForLevel();
44
                    pPlayer->SetUInt32Value(PLAYER_XP, 0);
45
                    pPlayer->DestroyItemCount(TOKEN_ID, uiAction*10, true);
46
                    pPlayer->GetSession()->SendAreaTriggerMessage("You are now Level %u!", uint32(pPlayer->getLevel()));
47-
	new Level_NPC();
47+
                    pPlayer->PlayerTalkClass->SendCloseGossip();
48
                    return true;
49
                }
50
            }
51
            else
52
                pPlayer->GetSession()->SendNotification("You don't have the required token");
53
        OnGossipHello(pPlayer, _creature);
54
        return true;
55
    }
56
};
57
void AddSC_Level_NPC()
58
{
59
    new Level_NPC();
60
}