As the title is saying, does anyone know how to create a Global bank system so the player does not have to carry any gold to buy items from the NPC's?
i've tried this guys code
but it doesnt seem to work, anyone got any idea?
any input would be much appreciated.
i've tried this guys code
Code:
int LuaScriptInterface::luaPlayerRemoveMoney(lua_State* L)
{
// player:removeMoney(money)mon
Player* player = getUserdata<Player>(L, 1);
bool success = false;
if (player) {
uint64_t money = getNumber<uint64_t>(L, 2);
if (!g_game.removeMoney(player, money))
{
uint64_t playerTotal = player->getMoney() + player->getBankBalance();
if (playerTotal >= money)
{
money -= player->getMoney(); //discount player money
if (money < 0) money = 0;
g_game.removeMoney(player, player->getMoney()); //1
if (player->getMoney() < 0) money = 0;
// player money is 0, and its value is discounted. Now remove from balance the rest
playerTotal = player->getBankBalance() - money;
if (playerTotal < 0) playerTotal = 0;
player->setBankBalance(playerTotal);
std::ostringstream ss;
ss << "Paid " << money << " gold from bank account. Your account balance is now " << player->getBankBalance() << " gold.";
player->sendTextMessage(MESSAGE_INFO_DESCR, ss.str());
success = true;
}
}
else
{
success = true;
}
pushBoolean(L, success);
}
else {
lua_pushnil(L);
}
return 1;
}
but it doesnt seem to work, anyone got any idea?
any input would be much appreciated.