Last active
October 8, 2020 16:09
-
-
Save mindsear/18f13248adea5024bfbadc555b303ab4 to your computer and use it in GitHub Desktop.
PayToChat is a core mod (for TrinityCore 3.3.5) that makes players pay in order to send a message.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/server/game/Handlers/ChatHandler.cpp b/src/server/game/Handlers/ChatHandler.cpp | |
index c9e69ba6c0..84d25c2014 100644 | |
--- a/src/server/game/Handlers/ChatHandler.cpp | |
+++ b/src/server/game/Handlers/ChatHandler.cpp | |
@@ -43,6 +43,7 @@ | |
#include "World.h" | |
#include "WorldPacket.h" | |
#include <algorithm> | |
+#include <Configuration\Config.h> | |
inline bool isNasty(uint8 c) | |
{ | |
@@ -291,7 +292,80 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData) | |
return; | |
} | |
- sender->Say(msg, Language(lang)); | |
+ const int PTC_Disabled = 0, Item = 1, Money = 2, Honor = 3, ArenaPoints = 4; | |
+ | |
+ switch (sWorld->getIntConfig(CONFIG_PTC_CHOOSE_CURRRENCY_ITEM_HONOR)) | |
+ { | |
+ case PTC_Disabled: | |
+ sender->Say(msg, Language(lang)); | |
+ break; | |
+ | |
+ case Item: | |
+ if (sender->HasItemCount(sWorld->getIntConfig(CONFIG_PTC_ITEM_ID), sWorld->getIntConfig(CONFIG_PTC_ITEM_COUNT))) | |
+ { | |
+ sender->DestroyItemCount(sWorld->getIntConfig(CONFIG_PTC_ITEM_ID), sWorld->getIntConfig(CONFIG_PTC_ITEM_COUNT), true); | |
+ std::string item_String_Ok = sConfigMgr->GetStringDefault("PTC.Item.String.OK", "You paid 1 Chat Token for your message"); | |
+ sender->GetSession()->SendAreaTriggerMessage(item_String_Ok.c_str()); | |
+ sender->Say(msg, Language(lang)); | |
+ } | |
+ else | |
+ { | |
+ std::string item_String_NotEnough = sConfigMgr->GetStringDefault("PTC.Item.String.NotEnough", "You don't have enough Chat Tokens to send a message"); | |
+ sender->GetSession()->SendNotification(item_String_NotEnough.c_str()); | |
+ } | |
+ | |
+ break; | |
+ | |
+ case Money: | |
+ if (sender->GetMoney() >= sWorld->getIntConfig(CONFIG_PTC_MONEY)) | |
+ { | |
+ sender->ModifyMoney(~(sWorld->getIntConfig(CONFIG_PTC_MONEY))+1); | |
+ std::string money_String_Ok = sConfigMgr->GetStringDefault("PTC.Money.String.OK", "You paid 1 copper for your message."); | |
+ sender->GetSession()->SendAreaTriggerMessage(money_String_Ok.c_str()); | |
+ sender->Say(msg, Language(lang)); | |
+ } | |
+ else | |
+ { | |
+ std::string money_String_NotEnough = sConfigMgr->GetStringDefault("PTC.Money.String.NotEnough", "You don't have enough gold to send a message"); | |
+ sender->GetSession()->SendNotification(money_String_NotEnough.c_str()); | |
+ } | |
+ break; | |
+ | |
+ case Honor: | |
+ if (sender->GetHonorPoints() >= sWorld->getIntConfig(CONFIG_PTC_HONOR)) | |
+ { | |
+ sender->ModifyHonorPoints(~(sWorld->getIntConfig(CONFIG_PTC_HONOR))+1); | |
+ std::string honor_String_Ok = sConfigMgr->GetStringDefault("PTC.HonorPoints.String.OK", "You paid 1 Honor Point for your message"); | |
+ sender->GetSession()->SendAreaTriggerMessage(honor_String_Ok.c_str()); | |
+ sender->Say(msg, Language(lang)); | |
+ } | |
+ else | |
+ { | |
+ std::string honor_String_NotEnough = sConfigMgr->GetStringDefault("PTC.HonorPoints.String.NotEnough", "You don't have enough Honor Points to send a message"); | |
+ sender->GetSession()->SendNotification(honor_String_NotEnough.c_str()); | |
+ } | |
+ | |
+ break; | |
+ | |
+ case ArenaPoints: | |
+ if (sender->GetArenaPoints() >= sWorld->getIntConfig(CONFIG_PTC_ARENA_POINTS)) | |
+ { | |
+ sender->ModifyArenaPoints(~(sWorld->getIntConfig(CONFIG_PTC_ARENA_POINTS))+1); | |
+ std::string arenaPoints_String_Ok = sConfigMgr->GetStringDefault("PTC.ArenaPoints.String.OK", "You paid 1 Arena Point for your message"); | |
+ sender->GetSession()->SendAreaTriggerMessage(arenaPoints_String_Ok.c_str()); | |
+ sender->Say(msg, Language(lang)); | |
+ } | |
+ else | |
+ { | |
+ std::string arenaPoints_String_NotEnough = sConfigMgr->GetStringDefault("PTC.ArenaPoints.String.NotEnough", "You don't have enough Arena Points to send a message"); | |
+ sender->GetSession()->SendNotification(arenaPoints_String_NotEnough.c_str()); | |
+ } | |
+ | |
+ break; | |
+ } | |
+ | |
+ | |
+ | |
break; | |
} | |
case CHAT_MSG_EMOTE: | |
diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp | |
index 15b2e89227..224b8dee6e 100644 | |
--- a/src/server/game/World/World.cpp | |
+++ b/src/server/game/World/World.cpp | |
@@ -673,6 +673,14 @@ void World::LoadConfigSettings(bool reload) | |
m_int_configs[CONFIG_CHAT_WHISPER_LEVEL_REQ] = sConfigMgr->GetIntDefault("ChatLevelReq.Whisper", 1); | |
m_int_configs[CONFIG_CHAT_EMOTE_LEVEL_REQ] = sConfigMgr->GetIntDefault("ChatLevelReq.Emote", 1); | |
m_int_configs[CONFIG_CHAT_SAY_LEVEL_REQ] = sConfigMgr->GetIntDefault("ChatLevelReq.Say", 1); | |
+ | |
+ m_int_configs[CONFIG_PTC_CHOOSE_CURRRENCY_ITEM_HONOR] = sConfigMgr->GetIntDefault("PTC.Choose.Item.Money.Honor", 0); | |
+ m_int_configs[CONFIG_PTC_ITEM_ID] = sConfigMgr->GetIntDefault("PTC.Item.ID", 49426); | |
+ m_int_configs[CONFIG_PTC_ITEM_COUNT] = sConfigMgr->GetIntDefault("PTC.Item.Count", 1); | |
+ m_int_configs[CONFIG_PTC_MONEY] = sConfigMgr->GetIntDefault("PTC.Money", 10000); | |
+ m_int_configs[CONFIG_PTC_HONOR] = sConfigMgr->GetIntDefault("PTC.Honor.Points", 1); | |
+ m_int_configs[CONFIG_PTC_ARENA_POINTS] = sConfigMgr->GetIntDefault("PTC.Arena.Points", 1); | |
+ | |
m_int_configs[CONFIG_CHAT_YELL_LEVEL_REQ] = sConfigMgr->GetIntDefault("ChatLevelReq.Yell", 1); | |
m_int_configs[CONFIG_PARTY_LEVEL_REQ] = sConfigMgr->GetIntDefault("PartyLevelReq", 1); | |
m_int_configs[CONFIG_TRADE_LEVEL_REQ] = sConfigMgr->GetIntDefault("LevelReq.Trade", 1); | |
diff --git a/src/server/game/World/World.h b/src/server/game/World/World.h | |
index 7727c24da8..a15d6150b6 100644 | |
--- a/src/server/game/World/World.h | |
+++ b/src/server/game/World/World.h | |
@@ -396,6 +396,12 @@ enum WorldIntConfigs | |
CONFIG_RESPAWN_DYNAMICMINIMUM_GAMEOBJECT, | |
CONFIG_RESPAWN_GUIDWARNING_FREQUENCY, | |
CONFIG_SOCKET_TIMEOUTTIME_ACTIVE, | |
+ CONFIG_PTC_CHOOSE_CURRRENCY_ITEM_HONOR, | |
+ CONFIG_PTC_ITEM_ID, | |
+ CONFIG_PTC_ITEM_COUNT, | |
+ CONFIG_PTC_MONEY, | |
+ CONFIG_PTC_HONOR, | |
+ CONFIG_PTC_ARENA_POINTS, | |
INT_CONFIG_VALUE_COUNT | |
}; | |
diff --git a/src/server/worldserver/worldserver.conf.dist b/src/server/worldserver/worldserver.conf.dist | |
index b364635214..b07f99a595 100644 | |
--- a/src/server/worldserver/worldserver.conf.dist | |
+++ b/src/server/worldserver/worldserver.conf.dist | |
@@ -4084,3 +4084,38 @@ Metric.OverallStatusInterval = 1 | |
# | |
################################################################################################### | |
+ | |
+################################################################################################### | |
+# PTC = Pay To Chat System | |
+# PTC.Choose.Item.Money.Honor = 1 (Default Item) | |
+# 0 = Disabled | |
+# 1 = Item | |
+# 2 = Money | |
+# 3 = Honor Points | |
+# 4 = Arena Points | |
+ | |
+PTC.Choose.Item.Money.Honor = 1 | |
+ | |
+# 49426 = Emblem Of Frost | |
+PTC.Item.ID = 49426 | |
+PTC.Item.Count = 1 | |
+PTC.Item.String.OK = "You paid 1 Chat Token for your message" | |
+PTC.Item.String.NotEnough = "You don't have enough Chat Tokens to send a message" | |
+ | |
+# PTC.Money = 10000 (= 1 gold, 00 silver, 00 copper) | |
+# 1 = 1 copper | |
+# 100 = 1 silver | |
+# 10000 = 1 gold | |
+ | |
+PTC.Money = 1 | |
+PTC.Money.String.OK = "You paid 1 copper for your message" | |
+PTC.Money.String.NotEnough = "You don't have enough gold to send a message" | |
+ | |
+PTC.Honor.Points = 1 | |
+PTC.HonorPoints.String.OK = "You paid 1 Honor Point for your message" | |
+PTC.HonorPoints.String.NotEnough = "You don't have enough Honor Points to send a message" | |
+ | |
+PTC.Arena.Points = 1 | |
+PTC.ArenaPoints.String.OK = "You paid 1 Arena Point for your message" | |
+PTC.ArenaPoints.String.NotEnough = "You don't have enough Arena Points to send a message" | |
+################################################################################################### | |
\ No newline at end of file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment