Skip to content

Commit

Permalink
chore(Misc) update module (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
pangolp authored Oct 26, 2024
1 parent 9e2cf42 commit 9f0c2ec
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 19 deletions.
10 changes: 5 additions & 5 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@
## For documentation

# Documents
*.doc diff=astextplain
*.DOC diff=astextplain
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain

## DOCUMENTATION
*.markdown text
Expand Down
2 changes: 1 addition & 1 deletion .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

- Latest build status with azerothcore:

[![Build Status](https://github.com/pangolp/mod-recruit-friend/workflows/core-build/badge.svg?branch=master&event=push)](https://github.com/pangolp/mod-recruit-friend)
[![Build Status](https://github.com/pangolp/mod-recruit-friend/actions/workflows/core-build.yml/badge.svg)](https://github.com/pangolp/mod-recruit-friend/actions)

[English](README.md) | [Español](README_ES.md)

Expand Down
2 changes: 1 addition & 1 deletion .github/README_ES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

- Último estado de compilación con azerothcore:

[![Build Status](https://github.com/pangolp/mod-recruit-friend/workflows/core-build/badge.svg?branch=master&event=push)](https://github.com/pangolp/mod-recruit-friend)
[![Build Status](https://github.com/pangolp/mod-recruit-friend/actions/workflows/core-build.yml/badge.svg)](https://github.com/pangolp/mod-recruit-friend/actions)

## Nota importante

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
SET @ENTRY:=35457;
DELETE FROM `acore_string` WHERE `entry` IN (@ENTRY+0, @ENTRY+1);
INSERT INTO `acore_string` (`entry`, `content_default`, `locale_koKR`, `locale_frFR`, `locale_deDE`, `locale_zhCN`, `locale_zhTW`, `locale_esES`, `locale_esMX`, `locale_ruRU`) VALUES
(@ENTRY+0, '[Recruit Friend] You must wait for %u sec. to use this command again.', '', '', '', '', '', '[Reclutar Amigo] Debes esperar %u seg para utilizar este comando nuevamente.', '[Reclutar Amigo] Debes esperar %u seg para utilizar este comando nuevamente.', ''),
(@ENTRY+0, '[Recruit Friend] You must wait for {} sec. to use this command again.', '', '', '', '', '', '[Reclutar Amigo] Debes esperar {} seg para utilizar este comando nuevamente.', '[Reclutar Amigo] Debes esperar {} seg para utilizar este comando nuevamente.', ''),
(@ENTRY+1, '[Recruit Friend] You haven\'t recruited anyone. Use the .recruit add command to do this.', '', '', '', '', '', '[Recruit Friend] No has reclutado a nadie. Utiliza el comando .recruit add para hacerlo.', '[Recruit Friend] No has reclutado a nadie. Utiliza el comando .recruit add para hacerlo.', '');
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SET @ENTRY:=35456;
DELETE FROM `acore_string` WHERE `entry`=@ENTRY+0;
INSERT INTO `acore_string` (`entry`, `content_default`, `locale_koKR`, `locale_frFR`, `locale_deDE`, `locale_zhCN`, `locale_zhTW`, `locale_esES`, `locale_esMX`, `locale_ruRU`) VALUES
(@ENTRY+0, '[Recruit Friend] Recruited character: %s', '', '', '', '', '', '[Recruit Friend] Personaje reclutado: %s', '[Recruit Friend] Personaje reclutado: %s', '');
(@ENTRY+0, '[Recruit Friend] Recruited character: {}', '', '', '', '', '', '[Recruit Friend] Personaje reclutado: {}', '[Recruit Friend] Personaje reclutado: {}', '');
File renamed without changes.
33 changes: 23 additions & 10 deletions src/RecruitCommand.cpp → src/recruit_commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@

enum RecruitFriendTexts
{
HELLO_RECRUIT_FRIEND = 35450,
RECRUIT_FRIEND_DISABLE,
RECRUIT_FRIEND_ALREADY_HAVE_RECRUITED,
RECRUIT_FRIEND_SUCCESS,
RECRUIT_FRIEND_RESET_SUCCESS,
RECRUIT_FRIEND_TARGET_ONESELF,
RECRUIT_FRIEND_NAMES,
RECRUIT_FRIEND_COOLDOWN,
RECRUIT_VIEW_EMPTY
HELLO_RECRUIT_FRIEND = 35450,
RECRUIT_FRIEND_DISABLE = 35451,
RECRUIT_FRIEND_ALREADY_HAVE_RECRUITED = 35452,
RECRUIT_FRIEND_SUCCESS = 35453,
RECRUIT_FRIEND_RESET_SUCCESS = 35454,
RECRUIT_FRIEND_TARGET_ONESELF = 35455,
RECRUIT_FRIEND_NAMES = 35456,
RECRUIT_FRIEND_COOLDOWN = 35457,
RECRUIT_VIEW_EMPTY = 35458
};

struct RecruitFriendStruct
Expand Down Expand Up @@ -51,16 +51,22 @@ class RecruitFriendAnnouncer : public PlayerScript
void registerQuery(ChatHandler* handler, const char* commandType)
{
uint32 myAccountId = handler->GetSession()->GetAccountId();

std::string accountName;

AccountMgr::GetName(myAccountId, accountName);

std::string characterName = handler->GetSession()->GetPlayerName();

std::string ipAccount = handler->GetSession()->GetRemoteAddress();

QueryResult info = LoginDatabase.Query("INSERT INTO `recruit_info` (`accountId`, `accountName`, `characterName`, `ip`, `command`) VALUES ({}, '{}', '{}', '{}', '{}')", myAccountId, accountName.c_str(), characterName.c_str(), ipAccount.c_str(), commandType);
}

void waitToUseCommand(ChatHandler* handler, uint32 myAccountId)
static void waitToUseCommand(ChatHandler* handler, uint32 myAccountId)
{
std::time_t currentTime = std::time(0);

uint32 delta = std::difftime(currentTime, recruitFriend.commandCooldown[myAccountId]);

if (delta <= (uint32)recruitFriend.cooldownValue / 1000)
Expand All @@ -76,6 +82,7 @@ void waitToUseCommand(ChatHandler* handler, uint32 myAccountId)
static void getTargetAccountIdByName(std::string& name, uint32& accountId)
{
QueryResult result = CharacterDatabase.Query("SELECT `account` FROM `characters` WHERE `name`='{}'", name);

accountId = (*result)[0].Get<int32>();
}

Expand Down Expand Up @@ -146,6 +153,7 @@ class RecruitCommandscript : public CommandScript
if (recruitFriend.cooldownEnabled)
{
waitToUseCommand(handler, myAccountId);

if (!recruitFriend.commandCooldown[myAccountId])
recruitFriend.commandCooldown[myAccountId] = std::time(0);
else
Expand All @@ -163,6 +171,7 @@ class RecruitCommandscript : public CommandScript
else if (targetAccountId != myAccountId)
{
result = LoginDatabase.Query("UPDATE `account` SET `recruiter`={} WHERE `id`={}", targetAccountId, myAccountId);

ChatHandler(handler->GetSession()).SendSysMessage(RECRUIT_FRIEND_SUCCESS);
}
else
Expand All @@ -185,14 +194,17 @@ class RecruitCommandscript : public CommandScript
if (recruitFriend.cooldownEnabled)
{
waitToUseCommand(handler, myAccountId);

if (!recruitFriend.commandCooldown[myAccountId])
recruitFriend.commandCooldown[myAccountId] = std::time(0);
else
return true;
}

registerQuery(handler, "reset");

QueryResult result = LoginDatabase.Query("UPDATE `account` SET `recruiter`=0 WHERE `id`={}", myAccountId);

ChatHandler(handler->GetSession()).SendSysMessage(RECRUIT_FRIEND_RESET_SUCCESS);

return true;
Expand All @@ -211,6 +223,7 @@ class RecruitCommandscript : public CommandScript
if (recruitFriend.cooldownEnabled)
{
waitToUseCommand(handler, myAccountId);

if (!recruitFriend.commandCooldown[myAccountId])
recruitFriend.commandCooldown[myAccountId] = std::time(0);
else
Expand Down

0 comments on commit 9f0c2ec

Please sign in to comment.