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

Core/Missings scripts #129

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 7 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- add wow token trinity string
DELETE FROM `trinity_string` WHERE `entry` IN (30007,30008,30009,30010);
INSERT INTO `trinity_string`(`entry`, `content_default`, `content_loc1`, `content_loc2`, `content_loc3`, `content_loc4`, `content_loc5`, `content_loc6`, `content_loc7`, `content_loc8`, `content_loc9`, `content_loc10`, `content_loc11`, `content_female`, `content_female_loc1`, `content_female_loc2`, `content_female_loc3`, `content_female_loc4`, `content_female_loc5`, `content_female_loc6`, `content_female_loc7`, `content_female_loc8`, `content_female_loc9`, `content_female_loc10`, `content_female_loc11`) VALUES
(30007, 'Thanks for helping the Pandaria 5.4.8 project, you just received donate coins: %f', NULL, NULL, NULL, '感谢帮助 Pandaria 5.4.8 项目,你刚获得了%f代币.', '感謝幫助 Pandaria 5.4.8 項目,你剛獲得了%f代幣.', NULL, NULL, 'Спасибо за помощь проекту Pandaria 5.4.8, вы только что получили очков пожертвования: %f', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(30008, 'You do not have the necessary token.', NULL, NULL, NULL, '你没有足够的代币.', '你沒有足夠的代幣.', NULL, NULL, 'У вас нет необходимого жетона.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(30009, 'You may not use this token whilst you are in combat or present in an arena or battleground.', NULL, NULL, NULL, '你无法在战斗中或者处于战场或竞技场中使用代币.', '你無法在戰鬥中或者處於戰場或競技場中使用代幣.', NULL, NULL, 'Вы не можете использовать этот жетон, пока находитесь в бою, на арене или поле боя.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(30010, 'Coins disabled.', NULL, NULL, NULL, '代币已禁用.', '代幣已禁用.', NULL, NULL, 'Жетоны отключены.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
83 changes: 83 additions & 0 deletions src/server/scripts/Custom/wow_token.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
* This file is part of the Pandaria 5.4.8 Project. See THANKS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "ScriptMgr.h"
#include "GridNotifiersImpl.h"
#include "DatabaseEnv.h"
#include "Chat.h"

enum BattlePayTokenTrinityStrings
{
BATTLEPAY_TOKEN_TRINITYSTRING_SUCCESS = 30007, // Thanks for helping the Pandaria 5.4.8 project, you just received donate coins: %f
BATTLEPAY_TOKEN_TRINITYSTRING_ERR_NOTENOUGH = 30008, // You do not have the necessary token.
BATTLEPAY_TOKEN_TRINITYSTRING_ERR_INBATTLE = 30009, // You may not use this token whilst you are in combat or present in an arena or battleground.
BATTLEPAY_TOKEN_TRINITYSTRING_ERR_DISABLED = 30010, // Coins disabled.
};

namespace BattlePay
{
enum Type:int64
{
Coins_1 = 10000,
Coins_2 = 20000,
Coins_5 = 50000,
Coins_10 = 100000
};
}

template<int64 Coins>
class battle_pay_token : public ItemScript
{
public:
battle_pay_token(const char *ScriptName) : ItemScript(ScriptName) { }

bool OnUse(Player *player, Item *item, const SpellCastTargets &)
{
if (player->IsInCombat() || player->InArena() || player->InBattleground())
{
ChatHandler(player->GetSession()).PSendSysMessage(player->GetSession()->GetTrinityString(BATTLEPAY_TOKEN_TRINITYSTRING_ERR_INBATTLE));
}
else if (!sWorld->getBoolConfig(CONFIG_WOW_TOKEN))
{
ChatHandler(player->GetSession()).PSendSysMessage(player->GetSession()->GetTrinityString(BATTLEPAY_TOKEN_TRINITYSTRING_ERR_DISABLED));
player->CastSpell(player, 27880, true);
}
else
{
if (player->HasItemCount(item->GetEntry(), 1, true))
{
player->AddDonateTokenCount(Coins);
player->DestroyItemCount(item->GetEntry(), 1, true);
ChatHandler(player->GetSession()).PSendSysMessage(player->GetSession()->GetTrinityString(BATTLEPAY_TOKEN_TRINITYSTRING_SUCCESS),Coins/10000);
player->SaveToDB();
}
else
{
ChatHandler(player->GetSession()).PSendSysMessage(player->GetSession()->GetTrinityString(BATTLEPAY_TOKEN_TRINITYSTRING_ERR_NOTENOUGH));
}
}
return true;
}
};

void AddSC_wow_token()
{
new battle_pay_token<BattlePay::Coins_1>("wow_token_1");
new battle_pay_token<BattlePay::Coins_2>("wow_token_2");
new battle_pay_token<BattlePay::Coins_5>("wow_token_5");
new battle_pay_token<BattlePay::Coins_10>("wow_token_10");
}