Likes: 3
Results 1 to 2 of 2
Thread: Grumbo'z VIP System
-
14-02-16, 11:48 PM #1
Grumbo'z VIP System
Register to remove this adGrumbo'z VIP Engine
--Built Tested and Approved for TrinityCore C++--
This is just the VIP Engine with basic features:
- This allows for an adjustable Max VIP level (default 6).
- VIP can be increased by a one-time-use item.
- VIP can also be increased by Voting if set.
- An item that displays a players VIP stats.
- Includes commands `.vip`,
- 3 different teleports
- 2 mall teleports.(pre-stored)
- 1 player stored teleport.(player storeable)
- repair command (Requires VIP Token) included,
- race, faction and char customizing commands.
- extra levels per VIP rank.
- Can be turned on/off in the conf.
- Items can require a minimum VIP rank to use.
- easy to edit config's.
- 3 different teleports
First edit your `auth.account` DB Table and add these 3 columns:
Code:ALTER TABLE `account` ADD COLUMN `vip` TINYINT(3) UNSIGNED NOT NULL DEFAULT '1' AFTER `activation`, ADD COLUMN `mg` MEDIUMINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `vip`, ADD COLUMN `votes` MEDIUMINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `mg`;
Code:ALTER TABLE `item_template` ADD COLUMN `vip` TINYINT(3) UNSIGNED NOT NULL DEFAULT '1' AFTER `VerifiedBuild`,
Then add these 2 files to your `\src\server\game\Entities\Player\` folder.
Grumboz_VIP_Core.cpp:
Code:#include "AccountMgr.h" #include "chat.h" #include "Config.h" #include "Grumboz_VIP_Core.h" #include "Language.h" #include "player.h" #include "RBAC.h" #include "ScriptPCH.h" #include <unordered_map> // color definitions since i hate yellow.. std::string green = "|cff00cc00"; std::string red = "|cffFF0000"; std::string white = "|cffFFFFFF"; std::string blue = "|cff3333FF"; std::string black = "|cff000000"; uint32 VIP_TOKEN_ID; std::string VIP_TOKEN_NAME; uint32 VIP_STONE_ID; uint32 VIP_MG_ID; uint8 VIP_MAX; bool VIP_VOTE_ENABLE; uint32 VIP_VOTE_COUNT; float VIP_OFFSET; uint8 VIP_TP_BONUS; bool VIP_LEVEL_BONUS_ENABLE; uint8 VIP_LEVEL_BONUS; uint8 max_level; std::unordered_map<uint32, VipElements> Vip; std::unordered_map<uint32, ItemVIP> ItemVip; std::unordered_map<uint8, VipMallGPS> MALL; std::unordered_map<uint8, VipHomeGPS> HOME; std::unordered_map<uint32, VipHearthStoneGPS> HearthStone; VIP::VIP() { } VIP::~VIP() { } std::string ConvertNumberToString(uint64 numberX) { auto number = numberX; std::stringstream convert; std::string number32_to_string; convert << number; number32_to_string = convert.str(); return number32_to_string; }; void AnnounceLoggingToWorld(Player* player, uint8 type) { std::string pName = player->GetName(); uint32 acct_id = player->GetSession()->GetAccountId(); uint8 PlayerLogInVip = VIP::GetVIP(acct_id); SessionMap sessions = sWorld->GetAllSessions(); // GetPlayersInWorld for (SessionMap::iterator itr = sessions.begin(); itr != sessions.end(); ++itr) { if (!itr->second) continue; uint8 ItrVip = VIP::GetVIP(itr->second->GetAccountId()); if (PlayerLogInVip <= ItrVip) // if target is same as or higher. won't announce to lower vip's. { std::string msg = "[" + green + "VIP" + ConvertNumberToString(PlayerLogInVip) + "|r]:"; msg = msg + pName + green + " has logged"; if (type == 0) { msg = msg + " out.|r"; }; if (type == 1) { msg = msg + " in.|r"; }; ChatHandler(itr->second->GetPlayer()->GetSession()).PSendSysMessage(msg.c_str()); } } }; class VIP_Load_Conf : public WorldScript { public: VIP_Load_Conf() : WorldScript("VIP_Load_Conf"){ }; virtual void OnConfigLoad(bool /*reload*/) { TC_LOG_INFO("server.loading", "- Grumbo'z VIP Engine Loading -"); QueryResult VIPItemQery = WorldDatabase.Query("SELECT entry, vip FROM item_template;"); if (VIPItemQery) { do { Field* fields = VIPItemQery->Fetch(); uint32 item_id = fields[0].GetUInt32(); uint32 vip = fields[1].GetUInt8(); ItemVIP& data1 = ItemVip[item_id]; // Save the DB values to the MyData object data1.item_id = item_id; data1.vip = vip; } while (VIPItemQery->NextRow()); } QueryResult gpsQery = WorldDatabase.Query("SELECT * FROM hearthstone;"); if (gpsQery) { do { // unpacks the results of `result` into fields and appoint data to variable. Field* fields = gpsQery->Fetch(); uint32 guid = fields[0].GetUInt32(); uint32 map_id = fields[1].GetUInt32(); float x = fields[2].GetFloat(); float y = fields[3].GetFloat(); float z = fields[4].GetFloat(); float o = fields[5].GetFloat(); VipHearthStoneGPS& data2 = HearthStone[guid]; // Save the DB values to the MyData object data2.guid = guid; data2.map_id = map_id; data2.x = x; data2.y = y; data2.z = z; data2.o = o; } while (gpsQery->NextRow()); } VipMallGPS& data3 = MALL[0]; // Save the DB values to the MyData object data3.map_id = 530; data3.x = -1800.3104f; data3.y = 5315.0424f; data3.z = -12.4276f; data3.o = 2.1062f; VipMallGPS& data4 = MALL[1]; // like Lua table VIP[acctId].vip // Save the DB values to the MyData object data4.map_id = 530; data4.x = -1921.8005f; data4.y = 5546.6264f; data4.z = -12.4278f; data4.o = 5.2321f; VipHomeGPS& data5 = HOME[0]; // like Lua table VIP[acctId].vip // Save the DB values to the MyData object data5.map_id = 0; data5.x = -4906.3911f; data5.y = -970.9063f; data5.z = 501.4540f; data5.o = 2.3338f; VipHomeGPS& data6 = HOME[1]; // like Lua table VIP[acctId].vip // Save the DB values to the MyData object data6.map_id = 1; data6.x = 1604.4882f; data6.y = -4394.3603f; data6.z = 9.9671f; data6.o = 3.5517f; VIP_TOKEN_ID = sWorld->getIntConfig(CONFIG_VIP_TOKEN); VIP_STONE_ID = sWorld->getIntConfig(CONFIG_VIP_STONE); VIP_MG_ID = sWorld->getIntConfig(CONFIG_VIP_MAGIC_GOLD_ID); VIP_MAX = sWorld->getIntConfig(CONFIG_VIP_MAX_LEVEL); VIP_VOTE_ENABLE = sWorld->getBoolConfig(CONFIG_VIP_VOTE_ENABLE); VIP_VOTE_COUNT = sWorld->getIntConfig(CONFIG_VIP_VOTE_COUNT); VIP_OFFSET = sWorld->getFloatConfig(CONFIG_VIP_OFFSET); VIP_TP_BONUS = sWorld->getIntConfig(CONFIG_VIP_TP_BONUS); VIP_LEVEL_BONUS_ENABLE = sWorld->getBoolConfig(CONFIG_VIP_LEVEL_BONUS_ENABLE); VIP_LEVEL_BONUS = sWorld->getIntConfig(CONFIG_VIP_LEVEL_BONUS); max_level = sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL); VIP_TOKEN_NAME = sObjectMgr->GetItemTemplate(uint32(VIP_STONE_ID))->Name1; TC_LOG_INFO("server.loading", "- Grumbo'z VIP Engine Loaded -"); }; }; uint8 VIP::GetVIPMAX() { return VIP_MAX; }; bool VIP::GetVIPVOTE_ENABLE() { return VIP_VOTE_ENABLE; } uint32 VIP::GetVIPVOTECOUNT() { return VIP_VOTE_COUNT; }; uint32 VIP::GetVIPCOINID() { return VIP_TOKEN_ID; }; uint32 VIP::GetVIPSTONEID() { return VIP_STONE_ID; }; uint32 VIP::GetVIPMGID() { return VIP_MG_ID; }; float VIP::GetVIPOFFSET() { return VIP_OFFSET; }; uint8 VIP::GetTALENTBONUS() { return VIP_TP_BONUS; }; bool VIP::GetLEVELBONUS_ENABLE() { return VIP_LEVEL_BONUS_ENABLE; }; uint8 VIP::GetLEVELBONUS() { return VIP_LEVEL_BONUS; }; void VIP::SetVIP(uint32 acct_id, uint8 pvip) { // you must update votes first for the dead mans check if (VIP_VOTE_ENABLE) { uint32 pvotes = Vip[acct_id].votes; pvip = uint8(pvotes / VIP_VOTE_COUNT); // dead mans check auto-calibrater if (pvotes < VIP_VOTE_COUNT) { pvip = 1; } if (pvotes >(VIP_VOTE_COUNT * VIP_MAX)) { pvip = VIP_MAX; } } Vip[acct_id].vip = pvip; PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SET_VIP); stmt->setUInt8(0, pvip); stmt->setUInt32(1, acct_id); LoginDatabase.Execute(stmt); }; void VIP::SetMG(uint32 acct_id, uint32 pmg) { PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SET_MG); stmt->setUInt32(0, pmg); stmt->setUInt32(1, acct_id); LoginDatabase.Execute(stmt); Vip[acct_id].mg = pmg; }; void VIP::SetVOTES(uint32 acct_id, uint32 pvotes) { PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SET_VOTES); stmt->setUInt32(0, pvotes); stmt->setUInt32(1, acct_id); LoginDatabase.Execute(stmt); Vip[acct_id].votes = pvotes; }; uint8 VIP::GetItemVIP(uint32 item_id) { return ItemVip[item_id].vip; }; uint8 VIP::GetVIP(uint32 acct_id) { return Vip[acct_id].vip; }; uint32 VIP::GetMG(uint32 acct_id) { return Vip[acct_id].mg; }; uint32 VIP::GetVOTES(uint32 acct_id) { return Vip[acct_id].votes; }; void VIP::SetHearthStone(uint32 guid, uint32 map_id, float x, float y, float z, float o) { WorldDatabase.PExecute("UPDATE `hearthstone` SET `map_id`='%u', `x`='%f', `y`='%f', `z`='%f', `o`='%f' WHERE guid=%u;", map_id, x, y, z, o, guid); VipHearthStoneGPS& data = HearthStone[guid]; // Save the DB values to the MyData object data.guid = guid; data.map_id = map_id; data.x = x; data.y = y; data.z = z; data.o = o; } class Grumboz_VIP_Account_Engine : public AccountScript { public: Grumboz_VIP_Account_Engine() : AccountScript("Grumboz_VIP_Account_Engine"){ }; virtual void OnAccountLogout(uint32 accountId) { TC_LOG_INFO("server.loading", "ACCOUNT::LOGOUT ID:%u VIP:%u", accountId, Vip[accountId].vip); Vip.erase(accountId); }; virtual void OnAccountLogin(uint32 accountId) { if (accountId > 0) { PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_LOAD_VIP); stmt->setUInt32(0, accountId); PreparedQueryResult result = LoginDatabase.Query(stmt); if (!result) { TC_LOG_INFO("server.loading", "XX ERROR Loading a VIP table ID %u XX", accountId); }; if (result) { // unpacks the results of `result` into fields and appoint data to variable. Field* fields = result->Fetch(); uint8 pvip = fields[0].GetUInt8(); uint32 pmg = fields[1].GetUInt32(); uint32 pvotes = fields[2].GetUInt32(); VipElements& data = Vip[accountId]; // like Lua table VIP[acctId].vip // Save the DB values to the MyData object data.vip = pvip; data.mg = pmg; data.votes = pvotes; VIP::SetVIP(accountId, pvip); TC_LOG_INFO("server.loading", "ACCOUNT::LOGIN ID:%u VIP:%u", accountId, Vip[accountId].vip); } } } }; class Grumboz_VIP_Player_Engine : public PlayerScript { public: Grumboz_VIP_Player_Engine() : PlayerScript("Grumboz_VIP_Player_Engine"){ }; virtual void OnLogout(Player* player) { AnnounceLoggingToWorld(player, 0); }; virtual void OnLogin(Player* player, bool firstLogin) { AnnounceLoggingToWorld(player, 1); uint32 guid = player->GetGUIDLow(); uint32 acct_id = player->GetSession()->GetAccountId(); uint8 Pvip = VIP::GetVIP(acct_id); bool lvl_enable = VIP::GetLEVELBONUS_ENABLE(); uint8 xtra_levels = VIP::GetLEVELBONUS(); uint8 Plvl = player->getLevel(); uint8 VIP_level_cap = max_level + (xtra_levels * Pvip); ChatHandler(player->GetSession()).PSendSysMessage("Welcome %s, you are VIP %u.", player->GetName().c_str(), Vip[acct_id].vip); ChatHandler(player->GetSession()).PSendSysMessage("%stype `.vip` for a list of VIP commands.", green.c_str()); if (HearthStone[guid].guid != guid) { WorldDatabase.PExecute("REPLACE INTO hearthstone SET `guid`='%u';", guid); VIP::SetHearthStone(guid, player->GetMapId(), player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetOrientation()); } if (Plvl != VIP_level_cap) { if (lvl_enable) { player->SetLevel(VIP_level_cap); } } }; }; class VIP_commands : public CommandScript { public: VIP_commands() : CommandScript("VIP_commands") { } ChatCommand* GetCommands() const { static ChatCommand vipCommandChangeTable[] = { { "race", 1, false, &HandleChangeRaceCommand, "allows the player to change there race during next login.", NULL }, { "faction", 1, false, &HandleChangeFactionCommand, "allows the player to change there faction during next login.", NULL }, { "custom", 1, false, &HandleCustomizeCommand, "allows the player to re-costumize there character during next login.", NULL }, { NULL, 0, false, NULL, "", NULL } }; static ChatCommand vipCommandSetTable[] = { { "hearthstone", 1, false, &HandleVipSetHearthstoneCommand, "stores players current gps to VIP hearthstone command.", NULL }, // go all the way with something . populate those help entries! { NULL, 0, false, NULL, "", NULL } }; std::string repair_info = "repairs all the players items. Requires the player to possess a " + VIP_TOKEN_NAME + "."; static ChatCommand vipCommandTable[] = { { "mall", 1, false, &HandleVipMallCommand, "teleports the player to a VIP mall", NULL }, // go all the way with something . populate those help entries! { "home", 1, false, &HandleHomeCommand, "Teleports the player to there faction home mall.", NULL }, { "repair", 1, false, &HandleRepairCommand, repair_info, NULL }, { "hearthstone", 1, false, &HandleHearthStoneCommand, "Teleports a player to there custom pre-set location.", NULL }, { "set", 1, true, NULL, "", vipCommandSetTable }, { "change", 1, true, NULL, "", vipCommandChangeTable }, { NULL, 0, false, NULL, "", NULL } }; static ChatCommand commandTable[] = { { "vip", 1, true, NULL, "custom VIP commands by Grumbo. Some commands may require player has an item.", vipCommandTable }, { NULL, 0, false, NULL, "", NULL } }; return commandTable; } static bool HandleVipMallCommand(ChatHandler* handler, const char* args) { Player* player = handler->GetSession()->GetPlayer(); auto team_id = player->GetTeamId(); if (player->IsInCombat()) { handler->SendSysMessage(LANG_YOU_IN_COMBAT); handler->SetSentErrorMessage(true); return false; } // stop flight if need if (player->IsInFlight()) { player->GetMotionMaster()->MovementExpired(); player->CleanupAfterTaxiFlight(); } // save only in non-flight case else player->SaveRecallPosition(); player->TeleportTo(MALL[team_id].map_id, MALL[team_id].x, MALL[team_id].y, MALL[team_id].z, MALL[team_id].o); return true; } static bool HandleChangeRaceCommand(ChatHandler* handler, const char* args) { Player* player = handler->GetSession()->GetPlayer(); player->SetAtLoginFlag(AT_LOGIN_CHANGE_RACE); handler->PSendSysMessage("Relog to change race of your character."); return true; } static bool HandleChangeFactionCommand(ChatHandler* handler, const char* args) { Player* player = handler->GetSession()->GetPlayer(); player->SetAtLoginFlag(AT_LOGIN_CHANGE_FACTION); handler->PSendSysMessage("Relog to change faction of your character."); return true; } static bool HandleCustomizeCommand(ChatHandler* handler, const char* args) { Player* player = handler->GetSession()->GetPlayer(); player->SetAtLoginFlag(AT_LOGIN_CUSTOMIZE); handler->PSendSysMessage("Relog to customize your character."); return true; } static bool HandleHomeCommand(ChatHandler* handler, const char* args) { Player* player = handler->GetSession()->GetPlayer(); auto team_id = player->GetTeamId(); if (player->IsInCombat()) { handler->SendSysMessage(LANG_YOU_IN_COMBAT); handler->SetSentErrorMessage(true); return false; } // stop flight if need if (player->IsInFlight()) { player->GetMotionMaster()->MovementExpired(); player->CleanupAfterTaxiFlight(); } // save only in non-flight case else player->SaveRecallPosition(); player->TeleportTo(HOME[team_id].map_id, HOME[team_id].x, HOME[team_id].y, HOME[team_id].z, HOME[team_id].o); return true; } static bool HandleRepairCommand(ChatHandler* handler, const char* args) { Player* player = handler->GetSession()->GetPlayer(); if (!player->HasItemCount(VIP_TOKEN_ID, 1, false)) { handler->PSendSysMessage("You must have a %s to use this command.", VIP_TOKEN_NAME.c_str()); return false; } if (player->HasItemCount(VIP_TOKEN_ID, 1, false)) { player->DurabilityRepairAll(0, 0, false); handler->PSendSysMessage("Done."); return true; } return true; } static bool HandleVipSetHearthstoneCommand(ChatHandler* handler, const char* args) { Player* player = handler->GetSession()->GetPlayer(); auto team_id = player->GetTeamId(); if (player->IsInCombat()) { handler->SendSysMessage(LANG_YOU_IN_COMBAT); handler->SetSentErrorMessage(true); return false; } // stop flight if need if (player->IsInFlight()) { player->GetMotionMaster()->MovementExpired(); player->CleanupAfterTaxiFlight(); } // save only in non-flight case else player->SaveRecallPosition(); VIP::SetHearthStone(player->GetGUIDLow(), player->GetMapId(), player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetOrientation()); handler->PSendSysMessage("%s, your location has been stored.", player->GetName().c_str()); return true; } static bool HandleHearthStoneCommand(ChatHandler* handler, const char* args) { Player* player = handler->GetSession()->GetPlayer(); uint32 guid = player->GetGUIDLow(); if (player->IsInCombat()) { handler->SendSysMessage(LANG_YOU_IN_COMBAT); handler->SetSentErrorMessage(true); return false; } // stop flight if need if (player->IsInFlight()) { player->GetMotionMaster()->MovementExpired(); player->CleanupAfterTaxiFlight(); } if (HearthStone[guid].guid != guid) { WorldDatabase.PExecute("REPLACE INTO hearthstone SET `guid`='%u';", guid); VIP::SetHearthStone(guid, player->GetMapId(), player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetOrientation()); handler->PSendSysMessage("You must store a location first to be able to use this command."); handler->PSendSysMessage("Default location is your current location."); return false; } if (HearthStone[guid].guid == guid) { // save only in non-flight case and a location is stored player->SaveRecallPosition(); player->TeleportTo(HearthStone[guid].map_id, HearthStone[guid].x, HearthStone[guid].y, HearthStone[guid].z, HearthStone[guid].o); return true; } return true; } }; class VIP_Coin_Script : public ItemScript { public: VIP_Coin_Script() : ItemScript("VIP_Coin_Script"){ }; virtual bool OnUse(Player* player, Item* item, SpellCastTargets const& targets) { uint32 acct_id = player->GetSession()->GetAccountId(); uint8 pVip = VIP::GetVIP(acct_id); uint32 pMg = VIP::GetMG(acct_id); uint32 pVotes = VIP::GetVOTES(acct_id); std::string Votes_Required_Ann; bool voting = VIP::GetVIPVOTE_ENABLE(); ChatHandler(player->GetSession()).PSendSysMessage("%s**********************************", green.c_str()); ChatHandler(player->GetSession()).PSendSysMessage("%sYou are VIP:%s%u%s of %s%u.", green.c_str(), white.c_str(), pVip, green.c_str(), white.c_str(), VIP_MAX); ChatHandler(player->GetSession()).PSendSysMessage("%sYou have %s%u %smg's", green.c_str(), white.c_str(), pMg, green.c_str()); if (pVotes <= 10){ ChatHandler(player->GetSession()).PSendSysMessage("%sYou have Voted %s%u%s time's.", green.c_str(), white.c_str(), pVotes, green.c_str()); }; if (pVotes > 10){ ChatHandler(player->GetSession()).PSendSysMessage("%sThank you for voting %s%u%s time's.", green.c_str(), white.c_str(), pVotes, green.c_str()); }; ChatHandler(player->GetSession()).PSendSysMessage("%sYou recieve a %s%u%s %sstat increase.", green.c_str(), white.c_str(), uint8(VIP_OFFSET * 100)*pVip, "%", green.c_str()); if (voting) { if (pVip < VIP_MAX) { uint32 Votes_Required = ((pVip + 1) * VIP_VOTE_COUNT) - pVotes; ChatHandler(player->GetSession()).PSendSysMessage("%sYou need %s%u%s more votes to reach the next VIP rank:%s%u%s.", green.c_str(), white.c_str(), Votes_Required, green.c_str(), white.c_str(), (pVip + 1), green.c_str()); ChatHandler(player->GetSession()).PSendSysMessage("%s**********************************", green.c_str()); return true; } } ChatHandler(player->GetSession()).PSendSysMessage("%s**********************************", green.c_str()); return true; } }; void RemoveItem(uint32 id, Player* player) { player->DestroyItemCount(uint32(id), 1, true); ChatHandler(player->GetSession()).PSendSysMessage("%s+1 VIP.", green.c_str()); }; class VIP_Stone_Script : public ItemScript { public: VIP_Stone_Script() : ItemScript("VIP_Stone_Script"){ }; virtual bool OnUse(Player* player, Item* item, SpellCastTargets const& targets) { uint32 acct_id = player->GetSession()->GetAccountId(); uint8 pVip = VIP::GetVIP(acct_id); uint32 pMg = VIP::GetMG(acct_id); uint32 pVotes = VIP::GetVOTES(acct_id); if (pVip >= VIP_MAX) { ChatHandler(player->GetSession()).PSendSysMessage("%sYou are allready the maximum VIP rank:%s%u.", red.c_str(), white.c_str(), VIP_MAX); } if (pVip < VIP_MAX) { VIP::SetVOTES(acct_id, pVotes + VIP_VOTE_COUNT); // must be first for the dead mans check VIP::SetVIP(acct_id, pVip + 1); RemoveItem(VIP_STONE_ID, player); return true; } return true; } }; class VIP_MG_BANKER : public CreatureScript { public: VIP_MG_BANKER() : CreatureScript("VIP_MG_BANKER"){ } bool OnGossipHello(Player* player, Creature* creature) { uint32 accountId = player->GetSession()->GetAccountId(); uint8 pVIP = VIP::GetVIP(accountId); uint32 MG = VIP::GetMG(accountId); uint32 itemId = VIP::GetVIPMGID(); uint32 pMg = player->GetItemCount(itemId); uint32 pVotes = VIP::GetVOTES(accountId); std::string itemName = sObjectMgr->GetItemTemplate(itemId)->Name1; std::string currency_inBank; std::string deposit_amt; if (pMg == 1){ deposit_amt = "Total:" + ConvertNumberToString(pMg) + " " + itemName; }; if (pMg == 0 || pMg > 1){ deposit_amt = "Total:" + ConvertNumberToString(pMg) + " " + itemName + "'s"; }; std::string withdraw10 = "Withdraw 10 " + itemName + "'s. Fee:0 " + itemName + "'s."; std::string withdraw100 = "Withdraw 100 " + itemName + "'s. Fee:1 " + itemName + "."; std::string withdraw1000 = "Withdraw 1,000 " + itemName + "'s. Fee:10 " + itemName + "'s."; std::string withdraw10000 = "Withdraw 10,000 " + itemName + "'s. Fee:100 " + itemName + "'s."; std::string withdraw100000 = "Withdraw 100,000 " + itemName + "'s. Fee:1,000 " + itemName + "'s."; if (MG == 1) currency_inBank = "Balance:" + ConvertNumberToString(MG) + " " + itemName; else { currency_inBank = "Balance:" + ConvertNumberToString(MG) + " " + itemName + "'s."; }; std::string current_VOTES = "Votes:" + ConvertNumberToString(pVotes); std::string current_VIP = "VIP:" + ConvertNumberToString(pVIP); if (pMg > 0) { player->ADD_GOSSIP_ITEM(10, "-----------------------", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2000); player->ADD_GOSSIP_ITEM(10, "-Deposit-", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2000); player->ADD_GOSSIP_ITEM(10, "-----------------------", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2000); player->ADD_GOSSIP_ITEM(10, "Deposit all my custom currency.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2001); player->ADD_GOSSIP_ITEM(10, deposit_amt.c_str(), GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2001); player->ADD_GOSSIP_ITEM(10, "-----------------------", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2000); } if (MG >= 10) { player->ADD_GOSSIP_ITEM(10, "-----------------------", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2000); player->ADD_GOSSIP_ITEM(10, "-WithDrawl-", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2000); player->ADD_GOSSIP_ITEM(10, "-----------------------", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2000); player->ADD_GOSSIP_ITEM(10, withdraw10.c_str(), GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2002); if (MG >= 101){ player->ADD_GOSSIP_ITEM(10, withdraw100.c_str(), GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2003); }; if (MG >= 1010){ player->ADD_GOSSIP_ITEM(10, withdraw1000.c_str(), GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2004); }; if (MG >= 10100){ player->ADD_GOSSIP_ITEM(10, withdraw10000.c_str(), GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2005); }; if (MG >= 101000){ player->ADD_GOSSIP_ITEM(10, withdraw100000.c_str(), GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2006); }; } player->ADD_GOSSIP_ITEM(10, "-----------------------", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2000); player->ADD_GOSSIP_ITEM(10, "-----------------------", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2000); player->ADD_GOSSIP_ITEM(10, "-Bank Balance-", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2000); player->ADD_GOSSIP_ITEM(10, currency_inBank.c_str(), GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2000); player->ADD_GOSSIP_ITEM(10, current_VOTES.c_str(), GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2000); player->ADD_GOSSIP_ITEM(10, current_VIP.c_str(), GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2000); player->ADD_GOSSIP_ITEM(10, "-----------------------", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2000); player->SEND_GOSSIP_MENU(1, creature->GetGUID()); return true; }; bool OnGossipSelect(Player* player, Creature* creature, uint32 /* sender */, uint32 actions) { TC_LOG_INFO("server.loading", "MG_BANKER::OnSelect :%u", actions); uint32 accountId = player->GetSession()->GetAccountId(); uint8 pVIP = VIP::GetVIP(accountId); uint32 MG = VIP::GetMG(accountId); uint32 itemId = VIP::GetVIPMGID(); uint32 pMg = player->GetItemCount(itemId); uint32 pVotes = VIP::GetVOTES(accountId); switch (actions) { case GOSSIP_ACTION_INFO_DEF + 2000: // loopbacks player->PlayerTalkClass->ClearMenus(); player->CLOSE_GOSSIP_MENU(); OnGossipHello(player, creature); break; case GOSSIP_ACTION_INFO_DEF + 2001: // Deposit all player->DestroyItemCount(itemId, pMg, true); if (player->GetItemCount(itemId) == 0) { VIP::SetMG(accountId, MG + pMg); }; player->PlayerTalkClass->ClearMenus(); player->CLOSE_GOSSIP_MENU(); OnGossipHello(player, creature); break; case GOSSIP_ACTION_INFO_DEF + 2002: // Withdraw 10 player->PlayerTalkClass->ClearMenus(); if (player->AddItem(itemId, 10)) { VIP::SetMG(accountId, MG - 10); player->CLOSE_GOSSIP_MENU(); } break; case GOSSIP_ACTION_INFO_DEF + 2003: // Withdraw 100 player->PlayerTalkClass->ClearMenus(); if (player->AddItem(itemId, 100)) { VIP::SetMG(accountId, MG - 101); player->CLOSE_GOSSIP_MENU(); } OnGossipHello(player, creature); break; case GOSSIP_ACTION_INFO_DEF + 2004: // Withdraw 1,000 player->PlayerTalkClass->ClearMenus(); if (player->AddItem(itemId, 1000)) { VIP::SetMG(accountId, MG - 1010); player->CLOSE_GOSSIP_MENU(); } OnGossipHello(player, creature); break; case GOSSIP_ACTION_INFO_DEF + 2005: // Withdraw 10,000 player->PlayerTalkClass->ClearMenus(); if (player->AddItem(itemId, 10000)) { VIP::SetMG(accountId, MG - 10100); player->CLOSE_GOSSIP_MENU(); } OnGossipHello(player, creature); break; case GOSSIP_ACTION_INFO_DEF + 2006: // Withdraw 100,000 player->PlayerTalkClass->ClearMenus(); if (player->AddItem(itemId, 100000)) { VIP::SetMG(accountId, MG - 101000); player->CLOSE_GOSSIP_MENU(); } OnGossipHello(player, creature); break; } return true; }; }; void AddSC_Grumboz_VIP_Core() { new VIP_Load_Conf; new Grumboz_VIP_Account_Engine; new Grumboz_VIP_Player_Engine; new VIP_commands; new VIP_Coin_Script; new VIP_Stone_Script; new VIP_MG_BANKER; }
Code:#ifndef GRUMBOZ_VIP_CORE_H #define GRUMBOZ_VIP_CORE_H struct VipElements { uint8 vip; uint32 mg; uint32 votes; }; struct ItemVIP { uint32 item_id; uint8 vip; }; struct VipMallGPS { uint32 map_id; float x; float y; float z; float o; }; struct VipHomeGPS { uint32 map_id; float x; float y; float z; float o; }; struct VipHearthStoneGPS { uint32 guid; uint32 map_id; float x; float y; float z; float o; }; class VIP { public: VIP(); ~VIP(); // Getterz static uint8 GetVIPMAX(); static bool GetVIPVOTE_ENABLE(); static uint32 GetVIPVOTECOUNT(); static uint32 GetVIPCOINID(); static uint32 GetVIPSTONEID(); static uint32 GetVIPMGID(); static float GetVIPOFFSET(); static uint8 GetTALENTBONUS(); static bool GetLEVELBONUS_ENABLE(); static uint8 GetLEVELBONUS(); static uint8 GetItemVIP(uint32 item_id); static uint8 GetVIP(uint32 acct_id); static uint32 GetMG(uint32 acct_id); static uint32 GetVOTES(uint32 acct_id); // Setterz static void SetVIP(uint32 acct_id, uint8 pvip); static void SetMG(uint32 acct_id, uint32 pmg); static void SetVOTES(uint32 acct_id, uint32 pvotes); static void SetHearthStone(uint32 guid, uint32 map_id, float x, float y, float z, float o); private: void RemoveItem(uint32 id, Player* player); }; #endif // GRUMBOZ_GUILD_WARZ_H_INCLUDED
Code:CREATE TABLE IF NOT EXISTS `hearthstone` ( `guid` mediumint(9) NOT NULL, `map_id` mediumint(9) NOT NULL, `x` float NOT NULL, `y` float NOT NULL, `z` float NOT NULL, `o` float NOT NULL, PRIMARY KEY (`guid`), UNIQUE KEY `guid` (`guid`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Then open `\src\server\game\Scripting\ScriptLoader.cpp` around line 40 under "//Commands" and add:
Code:void AddSC_Grumboz_VIP_Core();
and add:
Code:AddSC_Grumboz_VIP_Core();
Add this to your worldserver.conf file:
Code:################################################################################################### # Grumbo'z VIP System # # These settings provide a flexibility to the system. # # # # VIP.TOKEN # Description: Item id used for the players perk token # Default: 44209 aka magic gold. # # # VIP.TOKEN = 63020 # # # # VIP.STONE # Description: Item id used for increasing a players VIP level. # Default: 63021 aka VIP Stone. # # # VIP.STONE = 63021 # # VIP.MAGIC.GOLD # Description: just custom currency # Default: 44209 # VIP.MAGIC_GOLD = 44209 # # VIP.MAX # Description: Max VIP Level for VIP System. max Uint32 value. # Default: 6 # VIP.MAX = 6 # VIP.VOTE.ENABLE # Description: Votes can earn higher vip ranks. # Default: 1 . 0 off // 1 on. # VIP.VOTE_ENABLE = 1 # VIP.OFFSETA # Description: float multiplier for each vip rank. # Default: 0.05f 5% muliplier per rank # VIP.OFFSET = 0.05 # # VIP.VOTE.COUNT # Description: how many Votes to earn each level of VIP. # Default: 125 votes per. # VIP.VOTE_COUNT = 125 # # VIP.TP.BONUS # Description: how many extra TP's to award per VIP level. # Default: # VIP.TP_BONUS = 14 # VIP.LEVEL_BONUS_ENABLE # Description: players can reach higher levels per VIP.. # Default: 1 . 0 off // 1 on. # VIP.LEVEL_BONUS_ENABLE = 1 # # # VIP.LEVEL_BONUS # Description: how many extra level's a player can reach per VIP level. # Default: 1 # VIP.LEVEL_BONUS = 1 # ##################################################################################################
Edit your LoginDatabase.cpp and add these lines around line 120 .. at the bottom
Code:PrepareStatement(LOGIN_LOAD_VIP, "SELECT vip, mg, votes FROM account WHERE id = ?", CONNECTION_SYNCH); PrepareStatement(LOGIN_SET_VIP, "UPDATE account SET `vip`=? WHERE `id`=?", CONNECTION_ASYNC); PrepareStatement(LOGIN_SET_MG, "UPDATE account SET `mg`=? WHERE `id`=?", CONNECTION_ASYNC); PrepareStatement(LOGIN_SET_VOTES, "UPDATE account SET `votes`=? WHERE `id`=?", CONNECTION_ASYNC);
LoginDatabase.h
Code:LOGIN_LOAD_VIP, LOGIN_SET_VIP, LOGIN_SET_MG, LOGIN_SET_VOTES,
Edit your World.cpp and add these lines around line 1200:
Code:// Grumbo'z VIP Core m_bool_configs[CONFIG_VIP_VOTE_ENABLE] = sConfigMgr->GetBoolDefault("VIP.VOTE_ENABLE", true); m_int_configs[CONFIG_VIP_TOKEN] = sConfigMgr->GetIntDefault("VIP.TOKEN", 63020); m_int_configs[CONFIG_VIP_STONE] = sConfigMgr->GetIntDefault("VIP.STONE", 63021); m_int_configs[CONFIG_VIP_MAGIC_GOLD_ID] = sConfigMgr->GetIntDefault("VIP.MAGIC_GOLD", 44209); m_int_configs[CONFIG_VIP_MAX_LEVEL] = sConfigMgr->GetIntDefault("VIP.MAX", 6); m_int_configs[CONFIG_VIP_VOTE_COUNT] = sConfigMgr->GetIntDefault("VIP.VOTE_COUNT", 125); m_int_configs[CONFIG_VIP_TP_BONUS] = sConfigMgr->GetIntDefault("VIP.TP_BONUS", 14); m_bool_configs[CONFIG_VIP_LEVEL_BONUS_ENABLE] = sConfigMgr->GetBoolDefault("VIP.LEVEL_BONUS_ENABLE", true); m_int_configs[CONFIG_VIP_LEVEL_BONUS] = sConfigMgr->GetIntDefault("VIP.LEVEL_BONUS", 1); m_float_configs[CONFIG_VIP_OFFSET] = sConfigMgr->GetFloatDefault("VIP.OFFSET", 0.05f);
bool
Code:CONFIG_VIP_VOTE_ENABLE, CONFIG_VIP_LEVEL_BONUS_ENABLE,
float
Code:CONFIG_VIP_OFFSET,
int
Code:CONFIG_VIP_TOKEN, CONFIG_VIP_STONE, CONFIG_VIP_MAGIC_GOLD_ID, CONFIG_VIP_MAX_LEVEL, CONFIG_VIP_VOTE_COUNT, CONFIG_VIP_TP_BONUS, CONFIG_VIP_LEVEL_BONUS,
Add these items/npc to your world DB:
Code:REPLACE INTO `item_template` (`entry`, `class`, `subclass`, `SoundOverrideSubclass`, `name`, `displayid`, `Quality`, `Flags`, `FlagsExtra`, `BuyCount`, `BuyPrice`, `SellPrice`, `InventoryType`, `AllowableClass`, `AllowableRace`, `ItemLevel`, `maxcount`, `stackable`, `ContainerSlots`, `spellid_1`, `spelltrigger_1`, `spellcharges_1`, `spellppmRate_1`, `spellcooldown_1`, `spellcategory_1`, `spellcategorycooldown_1`, `bonding`, `description`, `lockid`, `Material`, `sheath`, `RandomProperty`, `RandomSuffix`, `ScriptName`) VALUES (44209, 10, 0, -1, 'Magic Gold', 32282, 1, 64, 0, 1, 0, 0, 0, -1, -1, 0, 0, 2147483647, 0, 0, 0, -1, 0, -1, 0, -1, 0, 'custom currency earned all over', 0, 1, 0, 0, 0, ''), (63020, 15, 0, -1, 'VIP Coin', 32282, 1, 64, 0, 1, 0, 0, 0, -1, -1, 1, 1, 1, 0, 13567, 0, 0, 0, -1, 0, -1, 1, 'A MUST HAVE item for all your VIP needs.', 0, 0, 0, 0, 0, 'VIP_Coin_Script'), (63021, 15, 0, -1, 'VIP Stone', 32282, 1, 64, 0, 1, 0, 0, 0, -1, -1, 1, 1, 1, 0, 13567, 0, 0, 0, -1, 0, -1, 1, '!!Wooooohooooooo!!\r\n!!ClickMe!!!ClickMe!!\r\n!!VIP+1!!SuperFun!!', 0, 1, 0, 0, 0, 'VIP_Stone_Script'); REPLACE INTO `creature_template` (`entry`, `modelid1`, `name`, `subname`, `IconName`, `gossip_menu_id`, `minlevel`, `maxlevel`, `exp`, `faction`, `npcflag`, `speed_walk`, `speed_run`, `scale`, `rank`, `dmgschool`, `BaseAttackTime`, `RangeAttackTime`, `BaseVariance`, `RangeVariance`, `unit_class`, `unit_flags`, `unit_flags2`, `dynamicflags`, `family`, `trainer_type`, `trainer_spell`, `trainer_class`, `trainer_race`, `type`, `type_flags`, `lootid`, `pickpocketloot`, `skinloot`, `resistance1`, `resistance2`, `resistance3`, `resistance4`, `resistance5`, `resistance6`, `spell1`, `spell2`, `spell3`, `spell4`, `spell5`, `spell6`, `spell7`, `spell8`, `PetSpellDataId`, `VehicleId`, `mingold`, `maxgold`, `AIName`, `MovementType`, `InhabitType`, `HoverHeight`, `HealthModifier`, `ManaModifier`, `ArmorModifier`, `DamageModifier`, `ExperienceModifier`, `questItem1`, `movementId`, `RegenHealth`, `mechanic_immune_mask`, `flags_extra`, `ScriptName`) VALUES (50001, 31048, 'World Trades Banker', 'Custom Banking', 'Buy', 0, 80, 80, 0, 35, 1, 1, 1.14286, 3.5, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '', 0, 3, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 'VIP_MG_BANKER');
Item Require a minimum VIP rank:
src/server/game/entities/player/player.cpp
line 11584 inside at the start of `InventoryResult Player::CanEquipItem()
Code:// item VIP level 0 or 1 = all players can equip. uint32 acctId = GetSession()->GetAccountId(); uint8 Pvip = VIP::GetVIP(acctId); uint8 Ivip = VIP::GetItemVIP(pItem->GetEntry()); if (Pvip < Ivip) { ChatHandler(GetSession()).PSendSysMessage("|cffFF0000You Must be VIP%u or higher to equip this item.|r", Ivip); return EQUIP_ERR_ITEM_CANT_BE_EQUIPPED; }
Credits : slp13at420
› See More: Grumbo'z VIP System
-
02-11-17, 09:12 PM #2
Register to remove this adI also have some other nice works. since we closed our doors @ EmuDev's I moved my Eluna scripts to GetMangos forums and my TrinityCore CPP scripts to TrinityCore forums.
I also made :
ArcEmu ALE Guild Plot System
TC/Mangos Eluna Guild Plot System
TC/Mangos Eluna VIP System
TrinityCore CPP VIP System
TrinityCore CPP Premium System
TrinityCore CPP Guild Plot System
TrinityCore CPP Capture the flag
And Thank You for the Credits @Wise
If you wish, you may use the updated thread from TrinityCore forum . it lists all the features rather than just raw code lol
here is a link to the GitHub repo for access to the latest versions:
>> Grumbo'z VIP Engine <<
Last edited by slp13at420; 17-03-18 at 02:28 PM.
-
Post Thanks / Like - 2 Likes