Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add minimum level to send private #3689

Merged
merged 11 commits into from
Oct 9, 2021
Merged
2 changes: 2 additions & 0 deletions config.lua.dist
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ showScriptsLogInConsole = false
showOnlineStatusInCharlist = false
yellMinimumLevel = 2
yellAlwaysAllowPremium = false
minimumLevelToSendPrivate = 1
premiumToSendPrivate = false
forceMonsterTypesOnLoad = true
cleanProtectionZones = false
luaItemDesc = false
Expand Down
3 changes: 3 additions & 0 deletions data/XML/groups.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
<flag cannotbemuted="1" />
<flag isalwayspremium="1" />
<flag ignoreyellcheck="1" />
<flag ignoresendprivatecheck="1" />
This conversation was marked as resolved.
Show resolved Hide resolved
</flags>
</group>
<group id="5" name="community manager" access="1" maxdepotitems="0" maxvipentries="200">
Expand Down Expand Up @@ -97,6 +98,7 @@
<flag cannotbemuted="1" />
<flag isalwayspremium="1" />
<flag ignoreyellcheck="1" />
<flag ignoresendprivatecheck="1" />
This conversation was marked as resolved.
Show resolved Hide resolved
</flags>
</group>
<group id="6" name="god" access="1" maxdepotitems="0" maxvipentries="200">
Expand Down Expand Up @@ -139,6 +141,7 @@
<flag cannotbemuted="1" />
<flag isalwayspremium="1" />
<flag ignoreyellcheck="1" />
<flag ignoresendprivatecheck="1" />
This conversation was marked as resolved.
Show resolved Hide resolved
</flags>
</group>
</groups>
2 changes: 2 additions & 0 deletions src/configmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ bool ConfigManager::load()
boolean[SERVER_SAVE_SHUTDOWN] = getGlobalBoolean(L, "serverSaveShutdown", true);
boolean[ONLINE_OFFLINE_CHARLIST] = getGlobalBoolean(L, "showOnlineStatusInCharlist", false);
boolean[YELL_ALLOW_PREMIUM] = getGlobalBoolean(L, "yellAlwaysAllowPremium", false);
boolean[PREMIUM_TO_SEND_PRIVATE] = getGlobalBoolean(L, "premiumToSendPrivate", false);
boolean[FORCE_MONSTERTYPE_LOAD] = getGlobalBoolean(L, "forceMonsterTypesOnLoad", true);
boolean[DEFAULT_WORLD_LIGHT] = getGlobalBoolean(L, "defaultWorldLight", true);
boolean[HOUSE_OWNED_BY_ACCOUNT] = getGlobalBoolean(L, "houseOwnedByAccount", false);
Expand Down Expand Up @@ -286,6 +287,7 @@ bool ConfigManager::load()
integer[MAX_PACKETS_PER_SECOND] = getGlobalNumber(L, "maxPacketsPerSecond", 25);
integer[SERVER_SAVE_NOTIFY_DURATION] = getGlobalNumber(L, "serverSaveNotifyDuration", 5);
integer[YELL_MINIMUM_LEVEL] = getGlobalNumber(L, "yellMinimumLevel", 2);
integer[MINIMUM_LEVEL_TO_SEND_PRIVATE] = getGlobalNumber(L, "minimumLevelToSendPrivate", 1);
integer[VIP_FREE_LIMIT] = getGlobalNumber(L, "vipFreeLimit", 20);
integer[VIP_PREMIUM_LIMIT] = getGlobalNumber(L, "vipPremiumLimit", 100);
integer[DEPOT_FREE_LIMIT] = getGlobalNumber(L, "depotFreeLimit", 2000);
Expand Down
2 changes: 2 additions & 0 deletions src/configmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class ConfigManager
SERVER_SAVE_SHUTDOWN,
ONLINE_OFFLINE_CHARLIST,
YELL_ALLOW_PREMIUM,
PREMIUM_TO_SEND_PRIVATE,
FORCE_MONSTERTYPE_LOAD,
DEFAULT_WORLD_LIGHT,
HOUSE_OWNED_BY_ACCOUNT,
Expand Down Expand Up @@ -130,6 +131,7 @@ class ConfigManager
MAX_PACKETS_PER_SECOND,
SERVER_SAVE_NOTIFY_DURATION,
YELL_MINIMUM_LEVEL,
MINIMUM_LEVEL_TO_SEND_PRIVATE,
VIP_FREE_LIMIT,
VIP_PREMIUM_LIMIT,
DEPOT_FREE_LIMIT,
Expand Down
1 change: 1 addition & 0 deletions src/const.h
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,7 @@ enum PlayerFlags : uint64_t {
PlayerFlag_CannotBeMuted = static_cast<uint64_t>(1) << 36,
PlayerFlag_IsAlwaysPremium = static_cast<uint64_t>(1) << 37,
PlayerFlag_IgnoreYellCheck = static_cast<uint64_t>(1) << 38,
PlayerFlag_IgnoreSendPrivateCheck = static_cast<uint64_t>(1) << 39,
};

enum ReloadTypes_t : uint8_t {
Expand Down
15 changes: 15 additions & 0 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3559,6 +3559,21 @@ bool Game::playerSpeakTo(Player* player, SpeakClasses type, const std::string& r
type = TALKTYPE_PRIVATE_FROM;
}

if (!player->isAccessPlayer() && !player->hasFlag(PlayerFlag_IgnoreSendPrivateCheck)) {
uint32_t minimumLevel = g_config.getNumber(ConfigManager::MINIMUM_LEVEL_TO_SEND_PRIVATE);
if (player->getLevel() < minimumLevel) {
if (g_config.getBoolean(ConfigManager::PREMIUM_TO_SEND_PRIVATE)) {
if (!player->isPremium()) {
player->sendTextMessage(MESSAGE_STATUS_SMALL, fmt::format("You may not send private unless you have reached level {:d} or have a premium account.", minimumLevel));
ramon-bernardo marked this conversation as resolved.
Show resolved Hide resolved
return false;
}
} else {
player->sendTextMessage(MESSAGE_STATUS_SMALL, fmt::format("You may not send private unless you have reached level {:d}.", minimumLevel));
ramon-bernardo marked this conversation as resolved.
Show resolved Hide resolved
return false;
}
}
}

toPlayer->sendPrivateMessage(player, type, text);
toPlayer->onCreatureSay(player, type, text);

Expand Down
3 changes: 2 additions & 1 deletion src/groups.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ const std::unordered_map<std::string, PlayerFlags> ParsePlayerFlagMap = {
{"ignoreweaponcheck", PlayerFlag_IgnoreWeaponCheck},
{"cannotbemuted", PlayerFlag_CannotBeMuted},
{"isalwayspremium", PlayerFlag_IsAlwaysPremium},
{"ignoreyellcheck", PlayerFlag_IgnoreYellCheck}
{"ignoreyellcheck", PlayerFlag_IgnoreYellCheck},
{"ignoresendprivatecheck", PlayerFlag_IgnoreSendPrivateCheck}
};

bool Groups::load()
Expand Down
2 changes: 2 additions & 0 deletions src/luascript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1621,7 +1621,9 @@ void LuaScriptInterface::registerFunctions()
registerEnum(PlayerFlag_IgnoreWeaponCheck)
registerEnum(PlayerFlag_CannotBeMuted)
registerEnum(PlayerFlag_IsAlwaysPremium)
registerEnum(PlayerFlag_IgnoreSendPrivateCheck)
registerEnum(PlayerFlag_IgnoreYellCheck)
registerEnum(PlayerFlag_IgnoreSendPrivateCheck)

registerEnum(PLAYERSEX_FEMALE)
registerEnum(PLAYERSEX_MALE)
Expand Down