• 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!
  • If you're using Gesior 2012 or MyAAC, please review this thread for information about a serious security vulnerability and a fix.

TFS 1.X+ money goes from the bank straight to the npcs tfs 1.5 7.72

bpm91

Well-Known Member
Joined
May 23, 2019
Messages
609
Solutions
7
Reaction score
64
Location
Brazil
hello, my npcs like boat, rune shop, etc... all are withdrawing money from the player directly from the bank, but as it is an old version I would like the player to have the money in the backpack to do the actions. how do i remove?
 

Attachments

  • WhatsApp Image 2022-05-15 at 23.00.32.jpeg
    WhatsApp Image 2022-05-15 at 23.00.32.jpeg
    278.6 KB · Views: 11 · VirusTotal

mano368

Intermediate OT User
Joined
Sep 2, 2011
Messages
332
Solutions
35
Reaction score
132
Location
Brazil
hello, my npcs like boat, rune shop, etc... all are withdrawing money from the player directly from the bank, but as it is an old version I would like the player to have the money in the backpack to do the actions. how do i remove?
Go data/npc/lib/npcsystem/modules.lua

Change where is:
Lua:
player:removeTotalMoney

To
Lua:
player:removeMoney

Remember that talkactions like buypremium and buyhouse use the same function.
 
OP
OP
bpm91

bpm91

Well-Known Member
Joined
May 23, 2019
Messages
609
Solutions
7
Reaction score
64
Location
Brazil
it didn't work, besides I noticed that when I went to buy manafluid he didn't remove it from the bank (no message appeared, only for more expensive things)
 

mano368

Intermediate OT User
Joined
Sep 2, 2011
Messages
332
Solutions
35
Reaction score
132
Location
Brazil
it didn't work, besides I noticed that when I went to buy manafluid he didn't remove it from the bank (no message appeared, only for more expensive things)
You need to change one player:removeTotalMoney in npc.lua inside data/npc/lib, but it refer to container.

Changed all player:removeTotalMoney in modules.lua?
 
OP
OP
bpm91

bpm91

Well-Known Member
Joined
May 23, 2019
Messages
609
Solutions
7
Reaction score
64
Location
Brazil
yes
Post automatically merged:

I noticed that when the item is cheap it doesn't take money from the bank, so the person can buy infinite mana fluid
 
Last edited:
OP
OP
bpm91

bpm91

Well-Known Member
Joined
May 23, 2019
Messages
609
Solutions
7
Reaction score
64
Location
Brazil
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

function onCreatureAppear(cid)                npcHandler:onCreatureAppear(cid)            end
function onCreatureDisappear(cid)             npcHandler:onCreatureDisappear(cid)            end
function onCreatureSay(cid, type, msg)            npcHandler:onCreatureSay(cid, type, msg)        end
function onThink()                    npcHandler:onThink()                    end

local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)

shopModule:addBuyableItem({'spellbook'}, 2175, 150, 'spellbook')
shopModule:addBuyableItem({'magic lightwand'}, 2163, 400, 'magic lightwand')

shopModule:addBuyableItemContainer({'backpack of animate dead rune'}, 2001, 2316, 7520, 1, 'backpack of animate dead rune')
shopModule:addBuyableItem({'animate dead rune'}, 2316, 375, 1, 'animate dead rune')

shopModule:addBuyableItemContainer({'backpack of antidote rune'}, 2003, 2266, 1320, 1, 'backpack of antidote rune')
shopModule:addBuyableItem({'antidote rune'}, 2266, 65, 1, 'antidote rune')

shopModule:addBuyableItemContainer({'backpack of blank rune'}, 1988, 2260, 220, 1, 'backpack of blank rune')
shopModule:addBuyableItem({'blank rune'}, 2260, 10, 1, 'blank rune')

shopModule:addBuyableItemContainer({'backpack of chameleon rune'}, 1999, 2291, 4220, 1, 'backpack of chameleon rune')
shopModule:addBuyableItem({'chameleon rune'}, 2291, 210, 1, 'chameleon rune')

shopModule:addBuyableItemContainer({'backpack of convince creature rune'}, 1999, 2290, 1620, 1, 'backpack of convince creature rune')
shopModule:addBuyableItem({'convince creature rune'}, 2290, 80, 1, 'convince creature rune')

shopModule:addBuyableItemContainer({'backpack of desintegrate rune'}, 2001, 2310, 1620, 3, 'backpack of desintegrate rune')
shopModule:addBuyableItem({'desintegrate rune'}, 2310, 80, 3, 'disintegrate rune')

shopModule:addBuyableItemContainer({'backpack of destroy field rune'}, 2003, 2261, 920, 3, 'backpack of destroy field rune')
shopModule:addBuyableItem({'destroy field rune'}, 2261, 45, 3, 'destroy field rune')

shopModule:addBuyableItemContainer({'backpack of energybomb rune'}, 2002, 2262, 6520, 2, 'backpack of energybomb rune')
shopModule:addBuyableItem({'energy bomb rune'}, 2262, 325, 2, 'energy bomb rune')

shopModule:addBuyableItemContainer({'backpack of energy field rune'}, 2002, 2277, 2320, 3, 'backpack of energy field rune')
shopModule:addBuyableItem({'energy field rune'}, 2277, 115, 3, 'energy field rune')

shopModule:addBuyableItemContainer({'backpack of energy wall rune'}, 2002, 2279, 6820, 4, 'backpack of backpack of energy wall rune')
shopModule:addBuyableItem({'energy wall rune'}, 2279, 340, 4, 'energy wall rune')

shopModule:addBuyableItemContainer({'backpack of envenom rune'}, 1998, 2292, 2420, 1, 'backpack of envenom rune')
shopModule:addBuyableItem({'envenom rune'}, 2292, 120, 1, 'envenom rune')

shopModule:addBuyableItemContainer({'backpack of explosion rune'}, 2001, 2313, 3820, 3, 'backpack of explosion rune')
shopModule:addBuyableItem({'explosion rune'}, 2313, 190, 3, 'explosion rune')

shopModule:addBuyableItemContainer({'backpack of firebomb rune'}, 2000, 2305, 4720, 2, 'backpack of firebomb rune')
shopModule:addBuyableItem({'fire bomb rune'}, 2305, 235, 2, 'fire bomb rune')

shopModule:addBuyableItemContainer({'backpack of fire field rune'}, 2000, 2301, 1720, 3, 'backpack of fire field rune')
shopModule:addBuyableItem({'fire field rune'}, 2301, 85, 3, 'fire field rune')

shopModule:addBuyableItemContainer({'backpack of fire wall rune'}, 2000, 2303, 4920, 4, 'backpack of fire wall rune')
shopModule:addBuyableItem({'fire wall rune'}, 2303, 245, 4, 'fire wall rune')

shopModule:addBuyableItemContainer({'backpack of fireball'}, 2000, 2302, 3020, 2, 'backpack of fireball rune')
shopModule:addBuyableItem({'fireball rune'}, 2302, 150, 2, 'fireball rune')

shopModule:addBuyableItemContainer({'backpack of great fireball rune'}, 2000, 2304, 3620, 2, 'backpack of great fireball rune')
shopModule:addBuyableItem({'great fireball rune'}, 2304, 180, 2, 'great fireball rune')

shopModule:addBuyableItemContainer({'backpack of heavy magic missile rune'}, 2001, 2311, 2420, 5, 'backpack of heavy magic missile rune')
shopModule:addBuyableItem({'heavy magic missile rune'}, 2311, 120, 5, 'heavy magic missile rune')

shopModule:addBuyableItemContainer({'backpack of intense healing rune'}, 2003, 2265, 1920, 1, 'backpack of intense healing rune')
shopModule:addBuyableItem({'intense healing rune'}, 2265, 95, 1, 'intense healing rune')

shopModule:addBuyableItemContainer({'backpack of light magic missile rune'}, 1999, 2287, 820, 5, 'backpack of light magic missile rune')
shopModule:addBuyableItem({'light magic missile rune'}, 2287, 40, 5, 'light magic missile rune')

shopModule:addBuyableItemContainer({'backpack of magic wall rune'}, 2004, 2293, 7020, 3, 'backpack of magic wall rune')
shopModule:addBuyableItem({'magic wall rune'}, 2293, 350, 3, 'magic wall rune')

shopModule:addBuyableItemContainer({'backpack of paralyze rune'}, 2002, 2278, 14020, 1, 'backpack of paralyze rune')
shopModule:addBuyableItem({'paralyze rune'}, 2278, 700, 1, 'paralyze rune')

shopModule:addBuyableItemContainer({'backpack of poisonbomb rune'}, 1998, 2286, 3420, 2, 'backpack of poisonbomb rune')
shopModule:addBuyableItem({'poison bomb rune'}, 2286, 170, 2, 'poison bomb rune')

shopModule:addBuyableItemContainer({'backpack of poison field rune'}, 1998, 2285, 1320, 3, 'backpack of poison field rune')
shopModule:addBuyableItem({'poison field rune'}, 2285, 65, 3, 'poison field rune')

shopModule:addBuyableItemContainer({'backpack of poison wall rune'}, 1998, 2289, 4220, 4, 'backpack of poison wall rune')
shopModule:addBuyableItem({'poison wall rune'}, 2289, 210, 4, 'poison wall rune')

shopModule:addBuyableItemContainer({'backpack of soulfire rune'}, 2000, 2308, 2820, 2, 'backpack of soulfire rune')
shopModule:addBuyableItem({'soulfire rune'}, 2308, 140, 2, 'soulfire rune')

shopModule:addBuyableItemContainer({'backpack of sudden death rune'}, 2003, 2268, 6520, 1, 'backpack of sudden death rune')
shopModule:addBuyableItem({'sudden death rune'}, 2268, 325, 1, 'sudden death rune')

shopModule:addBuyableItemContainer({'backpack of ultimate healing rune'}, 2002, 2273, 3520, 1, 'backpack of ultimate healing rune')
shopModule:addBuyableItem({'utlimate healing rune'}, 2273, 175, 1, 'ultimate healing rune')


shopModule:addBuyableItem({'wand of dragonbreath'}, 2191, 1000, 1, 'wand of dragonbreath')
shopModule:addBuyableItem({'wand of plague'}, 2188, 5000, 1, 'wand of plague')
shopModule:addBuyableItem({'wand of cosmic energy', 'cosmic energy'}, 2189, 10000, 1, 'wand of cosmic energy')
shopModule:addBuyableItem({'wand of inferno'}, 2187, 15000, 1, 'wand of inferno')
shopModule:addBuyableItem({'wand of vortex'}, 2190, 500, 1, 'wand of vortex')


shopModule:addBuyableItem({'snakebite rod'}, 2182, 500, 1, 'snakebite rod')
shopModule:addBuyableItem({'moonlight rod'}, 2186, 1000, 1, 'moonlight rod')
shopModule:addBuyableItem({'quagmire rod'}, 2181, 10000, 1, 'quagmire rod')
shopModule:addBuyableItem({'tempest rod'}, 2183, 15000, 1, 'tempest rod')


shopModule:addBuyableItemContainer({'backpack of oil'}, 1988, 2006, 320, 11, 'backpack of oil')
shopModule:addBuyableItem({'vial of oil'}, 2006, 15, 11, 'vial of oil')
shopModule:addBuyableItemContainer({'backpack of blood'}, 2000, 2006, 320, 2, 'backpack of blood')
shopModule:addBuyableItem({'vial of blood'}, 2006, 15, 2, 'vial of blood')
shopModule:addBuyableItemContainer({'backpack of lifefluid'}, 2000, 2006, 1220, 10, 'backpack of lifefluid')
shopModule:addBuyableItem({'lifefluid'}, 2006, 60, 10, 'lifefluid')
shopModule:addBuyableItemContainer({'backpack of manafluid'}, 2001, 2006, 2020, 7, 'backpack of manafluid')
shopModule:addBuyableItem({'vial of manafluid'}, 2006, 100, 7, 'vial of manafluid')


npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Post automatically merged:

modules
Post automatically merged:

if the item is very cheap, it doesn't charge money from the bank or from the character's hand, so it's buying at no cost
 

Attachments

Last edited:

mano368

Intermediate OT User
Joined
Sep 2, 2011
Messages
332
Solutions
35
Reaction score
132
Location
Brazil
Post automatically merged:

modules
Post automatically merged:

if the item is very cheap, it doesn't charge money from the bank or from the character's hand, so it's buying at no cost
its your modules.lua after modification or without modifications about player:removeMoney?
 
OP
OP
bpm91

bpm91

Well-Known Member
Joined
May 23, 2019
Messages
609
Solutions
7
Reaction score
64
Location
Brazil
I found out that the price above 200 gold it says I have no money, below 201 it gives me the item without charging anything
so i need to know how to fix this and get the money to withdraw direct from the bank
Post automatically merged:

its your modules.lua after modification or without modifications about player:removeMoney?
no modification, i back to original script
 

mano368

Intermediate OT User
Joined
Sep 2, 2011
Messages
332
Solutions
35
Reaction score
132
Location
Brazil
I found out that the price above 200 gold it says I have no money, below 201 it gives me the item without charging anything
so i need to know how to fix this and get the money to withdraw direct from the bank
Post automatically merged:


no modification, i back to original script
ok, here we go!

first, do as told in the first reply

in data/npc/lib/npcsystem, open modules.lua

change all
Lua:
player:removeTotalMoney

for
Lua:
player:removeMoney

after

change all
Lua:
player:getTotalMoney

for
Lua:
player:getMoney

do the same in data/npc/lib, open npc.lua
 
OP
OP
bpm91

bpm91

Well-Known Member
Joined
May 23, 2019
Messages
609
Solutions
7
Reaction score
64
Location
Brazil
i found other functions on npc.lua

Lua:
-- Including the Advanced NPC System
dofile('data/npc/lib/npcsystem/npcsystem.lua')

function msgcontains(message, keyword)
    local message, keyword = message:lower(), keyword:lower()
    if message == keyword then
        return true
    end

    return message:find(keyword) and not message:find('(%w+)' .. keyword)
end

function doNpcSellItem(cid, itemid, amount, subType, ignoreCap, inBackpacks, backpack)
    local amount = amount or 1
    local subType = subType or 0
    local item = 0
    if ItemType(itemid):isStackable() then
        if inBackpacks then
            stuff = Game.createItem(backpack, 1)
            item = stuff:addItem(itemid, math.min(100, amount))
        else
            stuff = Game.createItem(itemid, math.min(100, amount))
        end
        return Player(cid):addItemEx(stuff, ignoreCap) ~= RETURNVALUE_NOERROR and 0 or amount, 0
    end

    local a = 0
    if inBackpacks then
        local container, b = Game.createItem(backpack, 1), 1
        for i = 1, amount do
            local item = container:addItem(itemid, subType)
            if table.contains({(ItemType(backpack):getCapacity() * b), amount}, i) then
                if Player(cid):addItemEx(container, ignoreCap) ~= RETURNVALUE_NOERROR then
                    b = b - 1
                    break
                end

                a = i
                if amount > i then
                    container = Game.createItem(backpack, 1)
                    b = b + 1
                end
            end
        end
        return a, b
    end

    for i = 1, amount do -- normal method for non-stackable items
        local item = Game.createItem(itemid, subType)
        if Player(cid):addItemEx(item, ignoreCap) ~= RETURNVALUE_NOERROR then
            break
        end
        a = i
    end
    return a, 0
end

local func = function(cid, text, type, e, pcid)
    if Player(pcid):isPlayer() then
        local creature = Creature(cid)
        creature:say(text, type, false, pcid, creature:getPosition())
        e.done = true
    end
end

function doCreatureSayWithDelay(cid, text, type, delay, e, pcid)
    if Player(pcid):isPlayer() then
        e.done = false
        e.event = addEvent(func, delay < 1 and 1000 or delay, cid, text, type, e, pcid)
    end
end

function doPlayerSellItem(cid, itemid, count, cost)
    local player = Player(cid)
    if player:removeItem(itemid, count) then
        if not player:addMoney(cost) then
            error('Could not add money to ' .. player:getName() .. '(' .. cost .. 'gp)')
        end
        return true
    end
    return false
end

function doPlayerBuyItemContainer(cid, containerid, itemid, count, cost, charges)
    local player = Player(cid)
    if not player:removeTotalMoney(cost) then
        return false
    end

    for i = 1, count do
        local container = Game.createItem(containerid, 1)
        for x = 1, ItemType(containerid):getCapacity() do
            container:addItem(itemid, charges)
        end

        if player:addItemEx(container, true) ~= RETURNVALUE_NOERROR then
            return false
        end
    end
    return true
end

function getCount(string)
    local b, e = string:find("%d+")
    local tonumber = tonumber(string:sub(b, e))
    if tonumber > 2 ^ 32 - 1 then
        print("Warning: Casting value to 32bit to prevent crash\n"..debug.traceback())
    end
    return b and e and math.min(2 ^ 32 - 1, tonumber) or -1
end

function Player.getTotalMoney(self)
    return self:getMoney() + self:getBankBalance()
end

function isValidMoney(money)
    return isNumber(money) and money > 0
end

function getMoneyCount(string)
    local b, e = string:find("%d+")
    local tonumber = tonumber(string:sub(b, e))
    if tonumber > 2 ^ 32 - 1 then
        print("Warning: Casting value to 32bit to prevent crash\n"..debug.traceback())
    end
    local money = b and e and math.min(2 ^ 32 - 1, tonumber) or -1
    if isValidMoney(money) then
        return money
    end
    return -1
end

function getMoneyWeight(money)
    local weight, currencyItems = 0, Game.getCurrencyItems()
    for index = #currencyItems, 1, -1 do
        local currency = currencyItems[index]
        local worth = currency:getWorth()
        local currencyCoins = math.floor(money / worth)
        if currencyCoins > 0 then
            money = money - (currencyCoins * worth)
            weight = weight + currency:getWeight(currencyCoins)
        end
    end
    return weight
end

1652716363487.png
Post automatically merged:

right, with the original function it removes 100 gp from the bank, now i need to make him stop pulling from the bank and pulling from the player
 
Last edited:
Top