SHOW:
|
|
- or go back to the newest paste.
1 | #include "ScriptPCH.h" | |
2 | ||
3 | #define TOKEN 123123 // token entry here | |
4 | ||
5 | class CUSTOMIZE_NPC : public CreatureScript | |
6 | { | |
7 | public: | |
8 | CUSTOMIZE_NPC() : CreatureScript("CUSTOMIZE_NPC") { } | |
9 | ||
10 | bool OnGossipHello(Player* player, Creature* creature) | |
11 | { | |
12 | - | player->ADD_GOSSIP_ITEM( GOSSIP_ICON_CHAT, "Rename 1500 tokens", GOSSIP_SENDER_MAIN, RENAME ); |
12 | + | player->ADD_GOSSIP_ITEM( GOSSIP_ICON_CHAT, "Rename 1500 tokens", 1500, AT_LOGIN_RENAME ); |
13 | - | player->ADD_GOSSIP_ITEM( GOSSIP_ICON_CHAT, "Change appearance 1500 tokens", GOSSIP_SENDER_MAIN, APPEARANCE ); |
13 | + | player->ADD_GOSSIP_ITEM( GOSSIP_ICON_CHAT, "Change appearance 1500 tokens", 1500, AT_LOGIN_CUSTOMIZE ); |
14 | - | player->ADD_GOSSIP_ITEM( GOSSIP_ICON_CHAT, "Change race 1000 tokens", GOSSIP_SENDER_MAIN, RACE ); |
14 | + | player->ADD_GOSSIP_ITEM( GOSSIP_ICON_CHAT, "Change race 1000 tokens", 1000, AT_LOGIN_CHANGE_RACE ); |
15 | - | player->ADD_GOSSIP_ITEM( GOSSIP_ICON_CHAT, "Change faction 1000 tokens", GOSSIP_SENDER_MAIN, FACTION ); |
15 | + | player->ADD_GOSSIP_ITEM( GOSSIP_ICON_CHAT, "Change faction 1000 tokens", 1000, AT_LOGIN_CHANGE_FACTION ); |
16 | player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID()); | |
17 | return true; | |
18 | } | |
19 | ||
20 | - | bool OnGossipSelect(Player* player, Creature* creature, uint32 sender, uint32 action) |
20 | + | bool OnGossipSelect(Player* player, Creature* creature, uint32 tokens, uint32 action) |
21 | { | |
22 | player->PlayerTalkClass->ClearMenus(); | |
23 | - | if(sender == GOSSIP_SENDER_MAIN) |
23 | + | AtLoginFlags flag = (AtLoginFlags)action; |
24 | ||
25 | - | switch(action) |
25 | + | if(player->HasAtLoginFlag(flag)) |
26 | player->GetSession()->SendNotification("Already bought! Relog to use"); | |
27 | - | case RACE: |
27 | + | else if(!player->HasItemCount(TOKEN, tokens)) |
28 | - | if(!player->HasItemCount(TOKEN, 1500)) |
28 | + | player->GetSession()->SendNotification("Not enough tokens"); |
29 | - | player->GetSession()->SendNotification("Not enough tokens"); |
29 | + | else |
30 | - | else |
30 | + | |
31 | - | { |
31 | + | player->DestroyItemCount(TOKEN, tokens, true); |
32 | - | player->DestroyItemCount(TOKEN, 1500, true); |
32 | + | if(flag == AT_LOGIN_RENAME) |
33 | - | PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ADD_AT_LOGIN_FLAG); |
33 | + | player->SetAtLoginFlag(AT_LOGIN_RENAME); |
34 | - | stmt->setUInt16(0, uint16(AT_LOGIN_CHANGE_RACE)); |
34 | + | else |
35 | - | player->SetAtLoginFlag(AT_LOGIN_CHANGE_RACE); |
35 | + | |
36 | - | stmt->setUInt32(1, player->GetGUIDLow()); |
36 | + | PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ADD_AT_LOGIN_FLAG); |
37 | - | CharacterDatabase.Execute(stmt); |
37 | + | stmt->setUInt16(0, uint16(flag)); |
38 | - | player->GetSession()->SendAreaTriggerMessage("Relog to change race"); |
38 | + | player->SetAtLoginFlag(flag); |
39 | - | ChatHandler(player).PSendSysMessage("Relog to change race"); |
39 | + | stmt->setUInt32(1, player->GetGUIDLow()); |
40 | - | } |
40 | + | CharacterDatabase.Execute(stmt); |
41 | - | break; |
41 | + | |
42 | - | case FACTION: |
42 | + | char* msg = ""; |
43 | - | if(!player->HasItemCount(TOKEN, 1500)) |
43 | + | switch(flag) |
44 | - | player->GetSession()->SendNotification("Not enough tokens"); |
44 | + | |
45 | - | else |
45 | + | case AT_LOGIN_RENAME: msg = "Relog to change name"; break; |
46 | - | { |
46 | + | case AT_LOGIN_CUSTOMIZE: msg = "Relog to change appearance"; break; |
47 | - | player->DestroyItemCount(TOKEN, 1500, true); |
47 | + | case AT_LOGIN_CHANGE_RACE: msg = "Relog to change race"; break; |
48 | - | PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ADD_AT_LOGIN_FLAG); |
48 | + | case AT_LOGIN_CHANGE_FACTION: msg = "Relog to change faction"; break; |
49 | - | stmt->setUInt16(0, uint16(AT_LOGIN_CHANGE_FACTION)); |
49 | + | |
50 | - | player->SetAtLoginFlag(AT_LOGIN_CHANGE_FACTION); |
50 | + | player->GetSession()->SendAreaTriggerMessage(msg); |
51 | - | stmt->setUInt32(1, player->GetGUIDLow()); |
51 | + | ChatHandler(player).PSendSysMessage(msg); |
52 | - | CharacterDatabase.Execute(stmt); |
52 | + | |
53 | - | player->GetSession()->SendAreaTriggerMessage("Relog to change faction"); |
53 | + | |
54 | - | ChatHandler(player).PSendSysMessage("Relog to change faction"); |
54 | + | |
55 | - | } |
55 | + | |
56 | - | break; |
56 | + | |
57 | - | case APPEARANCE: |
57 | + | |
58 | - | if(!player->HasItemCount(TOKEN, 1000)) |
58 | + | |
59 | - | player->GetSession()->SendNotification("Not enough tokens"); |
59 | + | |
60 | - | else |
60 | + | |
61 | - | { |
61 | + |