Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions conf/mod_starterguild.conf.dist
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ StarterGuild.Level = 0
# StarterGuild.HordeWelcomeText
# StarterGuild.AllianceWelcomeText
# Description: Welcome text sent to the player in chat when he is added to the guild. Can be set to not notify, by setting this config to an empty string.
# Default HordeWelcomeText: "Lok’tar ogar! Welcome to the horde starter guild <GUILD> <PLAYER>."
# Default AllianceWelcomeText: "Welcome to the alliance starter guild <GUILD> <PLAYER>. For the Alliance!"
# Value: Any String, using either <GUILD> or <PLAYER> in your string will cause them to be replaced with the starter guilds name or characters name respectivly.
# Default HordeWelcomeText: "Lok’tar ogar! Welcome to the horde starter guild {GUILD} {PLAYER}."
# Default AllianceWelcomeText: "Welcome to the alliance starter guild {GUILD} {PLAYER}. For the Alliance!"
# Value: Any String, using either {GUILD} or {PLAYER} in your string will cause them to be replaced with the starter guilds name or characters name respectivly.
#
StarterGuild.HordeWelcomeText = "Lok’tar ogar! Welcome to the horde starter guild <GUILD> <PLAYER>."
StarterGuild.AllianceWelcomeText = "Welcome to the alliance starter guild <GUILD> <PLAYER>. For the Alliance!"
StarterGuild.HordeWelcomeText = "Lok’tar ogar! Welcome to the horde starter guild {GUILD} {PLAYER}."
StarterGuild.AllianceWelcomeText = "Welcome to the alliance starter guild {GUILD} {PLAYER}. For the Alliance!"
15 changes: 9 additions & 6 deletions src/mod_starterguild.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "mod_starterguild.h"
#include <regex>
#include <fmt/format.h>

void StarterGuild::OnPlayerLogin(Player* player)
{
Expand Down Expand Up @@ -30,8 +30,8 @@ void StarterGuild::addPlayerToGuild(Player* player)
const uint32 GUILD_ID_HORDE = sConfigMgr->GetOption<uint32>("StarterGuild.Horde", 1);
const uint32 GUILD_ID_ALLIANCE = sConfigMgr->GetOption<uint32>("StarterGuild.Alliance", 2);

const std::string GUILD_WELCOME_TEXT_HORDE = sConfigMgr->GetOption<std::string>("StarterGuild.HordeWelcomeText", "Lok’tar ogar! Welcome to the horde starter guild <GUILD> <PLAYER>.");
const std::string GUILD_WELCOME_TEXT_ALLIANCE = sConfigMgr->GetOption<std::string>("StarterGuild.AllianceWelcomeText", "Welcome to the alliance starter guild <GUILD> <PLAYER>. For the Alliance!");
const std::string GUILD_WELCOME_TEXT_HORDE = sConfigMgr->GetOption<std::string>("StarterGuild.HordeWelcomeText", "Lok’tar ogar! Welcome to the horde starter guild {GUILD} {PLAYER}.");
const std::string GUILD_WELCOME_TEXT_ALLIANCE = sConfigMgr->GetOption<std::string>("StarterGuild.AllianceWelcomeText", "Welcome to the alliance starter guild {GUILD} {PLAYER}. For the Alliance!");

Guild* guild = sGuildMgr->GetGuildById(player->GetTeamId() == TEAM_ALLIANCE ? GUILD_ID_ALLIANCE : GUILD_ID_HORDE);

Expand All @@ -45,10 +45,13 @@ void StarterGuild::addPlayerToGuild(Player* player)
// Inform the player they have joined the guild
std::string welcome_text = player->GetTeamId() == TEAM_ALLIANCE ? GUILD_WELCOME_TEXT_ALLIANCE : GUILD_WELCOME_TEXT_HORDE;

welcome_text = std::regex_replace(welcome_text, std::regex("<GUILD>"), player->GetGuildName());
welcome_text = std::regex_replace(welcome_text, std::regex("<PLAYER>"), player->GetName());
welcome_text = fmt::format(
fmt::runtime(welcome_text),
fmt::arg("GUILD", player->GetGuildName()),
fmt::arg("PLAYER", player->GetPlayerName())
);

ChatHandler(player->GetSession()).SendSysMessage(welcome_text.c_str());
ChatHandler(player->GetSession()).SendSysMessage(welcome_text);
}
else
ChatHandler(player->GetSession()).SendSysMessage("The brotherhood has exceeded its membership limit.");
Expand Down
Loading