diff options
| author | Warpten <vertozor@gmail.com> | 2012-10-12 22:13:28 +0200 |
|---|---|---|
| committer | Warpten <vertozor@gmail.com> | 2012-10-12 22:13:28 +0200 |
| commit | c8c4291c6f57616489f7d511595c07a63bd230bc (patch) | |
| tree | a534146dfd43413fa2931de7532d70bc7421183a /src/server/scripts/Commands | |
| parent | b06e9cfd41e11b8efed8c1e8abb7899b91897b8d (diff) | |
Core/Commands: Allow .modify money to take another parameter structure:
Example uses:
* .modify money 325g 25s 12c is the same as .modify money 3252512
* .modify money -12g is the same as .modify money -120000
* .modify money -12g 45s is the same as .modify money -115500
* .modify money 25c 18g is the same as .modify money 18g 25c
Diffstat (limited to 'src/server/scripts/Commands')
| -rw-r--r-- | src/server/scripts/Commands/cs_modify.cpp | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/src/server/scripts/Commands/cs_modify.cpp b/src/server/scripts/Commands/cs_modify.cpp index a88c765c596..ff74ae83c20 100644 --- a/src/server/scripts/Commands/cs_modify.cpp +++ b/src/server/scripts/Commands/cs_modify.cpp @@ -1002,15 +1002,19 @@ public: if (handler->HasLowerSecurity(target, 0)) return false; - int32 addmoney = atoi((char*)args); + int32 moneyToAdd = 0; + if (strchr(args, 'g') || strchr(args, 's') || strchr(args, 'c')) + moneyToAdd = MoneyStringToMoney(std::string(args)); + else + moneyToAdd = atoi(args); - uint32 moneyuser = target->GetMoney(); + uint32 targetMoney = target->GetMoney(); - if (addmoney < 0) + if (moneyToAdd < 0) { - int32 newmoney = int32(moneyuser) + addmoney; + int32 newmoney = int32(targetMoney) + moneyToAdd; - sLog->outDebug(LOG_FILTER_GENERAL, handler->GetTrinityString(LANG_CURRENT_MONEY), moneyuser, addmoney, newmoney); + sLog->outDebug(LOG_FILTER_GENERAL, handler->GetTrinityString(LANG_CURRENT_MONEY), targetMoney, moneyToAdd, newmoney); if (newmoney <= 0) { handler->PSendSysMessage(LANG_YOU_TAKE_ALL_MONEY, handler->GetNameLink(target).c_str()); @@ -1024,25 +1028,25 @@ public: if (newmoney > MAX_MONEY_AMOUNT) newmoney = MAX_MONEY_AMOUNT; - handler->PSendSysMessage(LANG_YOU_TAKE_MONEY, abs(addmoney), handler->GetNameLink(target).c_str()); + handler->PSendSysMessage(LANG_YOU_TAKE_MONEY, abs(moneyToAdd), handler->GetNameLink(target).c_str()); if (handler->needReportToTarget(target)) - (ChatHandler(target)).PSendSysMessage(LANG_YOURS_MONEY_TAKEN, handler->GetNameLink().c_str(), abs(addmoney)); + (ChatHandler(target)).PSendSysMessage(LANG_YOURS_MONEY_TAKEN, handler->GetNameLink().c_str(), abs(moneyToAdd)); target->SetMoney(newmoney); } } else { - handler->PSendSysMessage(LANG_YOU_GIVE_MONEY, addmoney, handler->GetNameLink(target).c_str()); + handler->PSendSysMessage(LANG_YOU_GIVE_MONEY, moneyToAdd, handler->GetNameLink(target).c_str()); if (handler->needReportToTarget(target)) - (ChatHandler(target)).PSendSysMessage(LANG_YOURS_MONEY_GIVEN, handler->GetNameLink().c_str(), addmoney); + (ChatHandler(target)).PSendSysMessage(LANG_YOURS_MONEY_GIVEN, handler->GetNameLink().c_str(), moneyToAdd); - if (addmoney >=MAX_MONEY_AMOUNT) + if (moneyToAdd >= MAX_MONEY_AMOUNT) target->SetMoney(MAX_MONEY_AMOUNT); else - target->ModifyMoney(addmoney); + target->ModifyMoney(moneyToAdd); } - sLog->outDebug(LOG_FILTER_GENERAL, handler->GetTrinityString(LANG_NEW_MONEY), moneyuser, addmoney, target->GetMoney()); + sLog->outDebug(LOG_FILTER_GENERAL, handler->GetTrinityString(LANG_NEW_MONEY), targetMoney, moneyToAdd, target->GetMoney()); return true; } |
