• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Windows Anybody knows how to make a global bank system?

trustjah

Newbie
Joined
Jan 22, 2009
Messages
124
Solutions
6
Reaction score
14
Location
Belgium
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

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.
 
Solution
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

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...
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

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.
https://otland.net/threads/npc-working-with-balance.245690/
 
Solution
Back
Top