added mod-mxwow-token module
This commit is contained in:
82
modules/mod-mxwow-token/src/mxwow_token.cpp
Normal file
82
modules/mod-mxwow-token/src/mxwow_token.cpp
Normal file
@@ -0,0 +1,82 @@
|
||||
//// MxWoW Official Module
|
||||
//// Token
|
||||
//// Dev: mikx
|
||||
//// Git: https://mxgit.ovh/MxWoW/mod_mxwow_token
|
||||
|
||||
#include "Configuration/Config.h"
|
||||
#include "ScriptMgr.h"
|
||||
#include "Player.h"
|
||||
#include "Chat.h"
|
||||
|
||||
class mxwow_token : public PlayerScript
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
mxwow_token() : PlayerScript("mxwow_token") { }
|
||||
|
||||
void OnLogin(Player* player) override
|
||||
{
|
||||
std::ostringstream ss;
|
||||
ChatHandler(player->GetSession()).SendSysMessage("This server is running the |cff4CFF00MxW Token |rmodule.");
|
||||
uint32 aId = player->GetSession()->GetAccountId();
|
||||
QueryResult queryPlayerTokenEntry = LoginDatabase.Query("SELECT * FROM mxw_account_token WHERE aid = {}", aId);
|
||||
if (!queryPlayerTokenEntry) {
|
||||
LoginDatabase.Execute("INSERT INTO mxw_account_token (aid, token) VALUES ({}, {})", aId, 0);
|
||||
}
|
||||
else {
|
||||
ss << "|cffabeeff[MxW] Vous avez un total de |cff00ff00%i|cffabeeff MxWToken.";
|
||||
uint32 tokenQty = (*queryPlayerTokenEntry)[1].Get<int>();
|
||||
ChatHandler(player->GetSession()).PSendSysMessage(ss.str().c_str(), tokenQty);
|
||||
}
|
||||
}
|
||||
|
||||
void OnCreatureKill(Player* player, Creature* boss)
|
||||
{
|
||||
if (sConfigMgr->GetOption<bool>("MxWoW_Token.Enabled", true)) {
|
||||
uint32 tokenQtyRaidHeroic = sConfigMgr->GetOption<int>("MxWoW_Token.Raid.Heroic", true);
|
||||
uint32 tokenQtyRaidNormal = sConfigMgr->GetOption<int>("MxWoW_Token.Raid.Normal", true);
|
||||
uint32 tokenQtyDungeonHeroic = sConfigMgr->GetOption<int>("MxWoW_Token.Dungeon.Heroic", true);
|
||||
uint32 tokenQtyDungeonNormal = sConfigMgr->GetOption<int>("MxWoW_Token.Dungeon.Normal", true);
|
||||
std::string bMap;
|
||||
if (boss->isWorldBoss()) {
|
||||
if (player->GetMap()->IsHeroic()) {
|
||||
GiveToken(player, tokenQtyRaidHeroic);
|
||||
}
|
||||
else {
|
||||
GiveToken(player, tokenQtyRaidNormal);
|
||||
}
|
||||
}
|
||||
else if (boss->IsDungeonBoss()) {
|
||||
if (player->GetMap()->IsHeroic()) {
|
||||
GiveToken(player, tokenQtyDungeonHeroic);
|
||||
}
|
||||
else {
|
||||
GiveToken(player, tokenQtyDungeonNormal);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GiveToken(const Player* player, const uint32 qty)
|
||||
{
|
||||
std::ostringstream ss;
|
||||
uint32 aId = player->GetSession()->GetAccountId();
|
||||
uint32 tQty = 0;
|
||||
uint32 ntQty = 0;
|
||||
QueryResult queryPlayerTokenQty = LoginDatabase.Query("SELECT * FROM mxw_account_token WHERE aid = {}", aId);
|
||||
if (queryPlayerTokenQty)
|
||||
{
|
||||
tQty = (*queryPlayerTokenQty)[1].Get<int>();
|
||||
ntQty = tQty + qty;
|
||||
LoginDatabase.Execute("UPDATE mxw_account_token SET token='{}' WHERE aid='{}'", ntQty, aId);
|
||||
ss << "|cffabeeff[MxW] Vous obtenez |cff00ff00%i|cffabeeff MxWToken. Vous avez un total de |cff00ff00%i|cffabeeff MxWToken.";
|
||||
ChatHandler(player->GetSession()).PSendSysMessage(ss.str().c_str(), qty, ntQty);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void AddMxWoWTokenScripts()
|
||||
{
|
||||
new mxwow_token();
|
||||
}
|
||||
11
modules/mod-mxwow-token/src/mxwow_token_loader.cpp
Normal file
11
modules/mod-mxwow-token/src/mxwow_token_loader.cpp
Normal file
@@ -0,0 +1,11 @@
|
||||
//// MxWoW Official Module
|
||||
//// Token
|
||||
//// Dev: mikx
|
||||
//// Git: https://mxgit.ovh/MxWoW/mod_mxwow_token
|
||||
|
||||
void AddMxWoWTokenScripts();
|
||||
|
||||
void Addmod_mxwow_tokenScripts()
|
||||
{
|
||||
AddMxWoWTokenScripts();
|
||||
}
|
||||
Reference in New Issue
Block a user