void TreasuryManager::bankTipOnline(int32 amount, PlayerObject* playerObject, PlayerObject* targetObject ) { //check if we have enough money int32 surcharge = (int32)((amount/100)*5); if((amount+surcharge) > dynamic_cast<Inventory*>(playerObject->getEquipManager()->getEquippedObject(CreatureEquipSlot_Inventory))->getCredits()) { BString s; s = targetObject->getFirstName(); s.convert(BSTRType_Unicode16); gMessageLib->SendSystemMessage(::common::OutOfBand("base_player", "prose_tip_nsf_cash", L"", s.getUnicode16(), L"", amount), playerObject); return; } Bank* playerBank = dynamic_cast<Bank*>(playerObject->getEquipManager()->getEquippedObject(CreatureEquipSlot_Bank)); Bank* targetBank = dynamic_cast<Bank*>(targetObject->getEquipManager()->getEquippedObject(CreatureEquipSlot_Bank)); playerBank->setCredits(playerBank->getCredits() - (amount+surcharge)); targetBank->setCredits(targetBank->getCredits() + amount); saveAndUpdateBankCredits(playerObject); saveAndUpdateBankCredits(targetObject); gMessageLib->SendSystemMessage(::common::OutOfBand("base_player", "prose_tip_pass_self", 0, targetObject->getId(), 0, amount), playerObject); gMessageLib->SendSystemMessage(::common::OutOfBand("base_player", "prose_tip_pass_target", 0, playerObject->getId(), 0, amount), targetObject); gMessageLib->sendBanktipMail(playerObject,targetObject,amount); }
void MissionManager::missionComplete(PlayerObject* player, MissionObject* mission) { wchar_t sm[100]; swprintf(sm,100, L"","mission/mission_generic",L"success_w_amount",mission->getReward()); gMessageLib->sendSystemMessage(player,sm); //remove mission gMessageLib->sendSetWaypointActiveStatus(mission->getWaypoint(),false,player); gMessageLib->sendDestroyObject(mission->getId(),player); //Give the player the credit reward gMessageLib->sendPlayMusicMessage(2501,player); //sound/music_mission_complete.snd gMessageLib->sendMissionComplete(player); Bank* bank = dynamic_cast<Bank*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_Bank)); bank->setCredits(bank->getCredits() + mission->getReward()); gTreasuryManager->saveAndUpdateBankCredits(player); return; }
void TreasuryManager::handleDatabaseJobComplete(void* ref,DatabaseResult* result) { TreasuryManagerAsyncContainer* asynContainer = (TreasuryManagerAsyncContainer*)ref; switch(asynContainer->mQueryType) { case TREMQuery_BankTipgetId: { if(!result->getRowCount()) { gMessageLib->SendSystemMessage(L"You may only /tip or /tip bank to other players.", asynContainer->player); return; } uint64 id; DataBinding* binding = mDatabase->CreateDataBinding(1); binding->addField(DFT_uint64,0,8); result->GetNextRow(binding,&id); //ok we just established that our target exists //we now need to update the bank on the db side TreasuryManagerAsyncContainer* asyncContainer = new TreasuryManagerAsyncContainer(TREMQuery_BankTipTransaction,asynContainer->player->getClient()); asyncContainer->amount = asynContainer->amount; asyncContainer->surcharge = asynContainer->surcharge; asyncContainer->player = asynContainer->player; asyncContainer->targetId = id; asyncContainer->targetName = asynContainer->targetName; //======================================================= //now remind the other player of the surcharge gUIManager->createNewMessageBox(this,"","@base_player:tip_wire_title","@base_player:tip_wire_prompt",asynContainer->player, SUI_Window_Trade_BankTip_ConfirmSurcharge, SUI_MB_OKCANCEL,asyncContainer); break; } break; case TREMQuery_BankTipTransaction: { uint32 error; DataBinding* binding = mDatabase->CreateDataBinding(1); binding->addField(DFT_uint32,0,4); result->GetNextRow(binding,&error); if (error == 0) { Bank* bank = dynamic_cast<Bank*>(asynContainer->player->getEquipManager()->getEquippedObject(CreatureEquipSlot_Bank)); //update our own bankaccount bank->setCredits(bank->getCredits() - asynContainer->amount); gMessageLib->sendBankCreditsUpdate(asynContainer->player); gMessageLib->sendBankTipDustOff(asynContainer->player,asynContainer->targetId,asynContainer->amount,asynContainer->targetName); //notify the chatserver for the EMails and the off zone accounts int8 sql[1024]; //CAVE galaxy id is hardcoded!!!!!!1 int8 galaxyId = 2; sprintf(sql, "CALL sp_GalaxyAccountDepositCredits(%u, %u, %"PRIu64",%u",galaxyId, Account_TipSurcharge, asynContainer->player, asynContainer->surcharge); TreasuryManagerAsyncContainer* asyncContainer = new TreasuryManagerAsyncContainer(TREMQuery_BankTipUpdateGalaxyAccount,0); mDatabase->ExecuteProcedureAsync(this,asyncContainer,sql); } else { gMessageLib->SendSystemMessage(::common::OutOfBand("error_message", "bank_error"), asynContainer->player); } } break; case TREMQuery_BankTipUpdateGalaxyAccount: { uint32 error; DataBinding* binding = mDatabase->CreateDataBinding(1); binding->addField(DFT_uint32,0,4); result->GetNextRow(binding,&error); if (error > 0) { gLogger->log(LogManager::DEBUG,"TreasuryManager::Account_TipSurcharge: error %u", error); } } break; case TREMQuery_NULL: { } break; default: break; } delete(asynContainer); }