• 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!

Promotion money

firenzie

New Member
Joined
Nov 15, 2017
Messages
16
Solutions
2
Reaction score
0
Hey guys!

While traveling with boat, the boat NPCs charge money from either your inventory or from your bank balance.
But when I want to buy promotion they only accept money from the inventory.
Could anyone help me make the promotion NPCs use bank money if the player doesnt have enough money in their backpack?

Thanks in advance :)
 
Solution
After reading your comment I thought I would be able to fix the problem really easy, but Im still having a challenge here..
I cant find anywhere to why the boat NPCs can use my bank balance and its driving me crazy :p

I made the function you recommended in my "customModules.lua"
C:\xxx\data\npc\lib\npcsystem\customModules.lua

and named the "yourFunction" to "bankBalance"
But this is the step im not sure about, where to I type "bankBalance" for this to work with the promotion NPCs?

Sorry i've only been doing this for a short period of time and im trying to learn as fast as possible ^^

Problem Solved!

All I had to do was change a line in modules.lua

this:

elseif not player:removeMoney(parameters.cost) then

to...
You can create it as a function and put in a lib or something to make it easier to use, you should already have that(as a function or not) as the boat NPC is doing the same thing, so you can change the function doPlayerRemoveMoney from the promotion npc to something similar to what is happening in the boat npc.

Function code example for that:
Lua:
function yourFunction(cid, money)
    local player = Player(cid)
    if player == nil then
        return false
    end

    if player:removeMoney(money) then
        return true
    end
 
    local balance = player:getBankBalance()
    if balance >= money then
        player:setBankBalance(balance - money)
        return true
    end
 
    return false
end
 
Last edited:
After reading your comment I thought I would be able to fix the problem really easy, but Im still having a challenge here..
I cant find anywhere to why the boat NPCs can use my bank balance and its driving me crazy :p

I made the function you recommended in my "customModules.lua"
C:\xxx\data\npc\lib\npcsystem\customModules.lua

and named the "yourFunction" to "bankBalance"
But this is the step im not sure about, where to I type "bankBalance" for this to work with the promotion NPCs?

Sorry i've only been doing this for a short period of time and im trying to learn as fast as possible ^^

Problem Solved!

All I had to do was change a line in modules.lua

this:

elseif not player:removeMoney(parameters.cost) then

to:

elseif not player:removeMoneyNpc(parameters.cost) then
 
Last edited by a moderator:
Solution
Ye thats exactly how mine looked, hence I was able to type

elseif not player:removeMoneyNpc(parameters.cost) then

instead of

elseif not player:removeMoney(parameters.cost) then

;D

But I have met a new problem, even after putting "elseif not player:removeMoneyNpc(parameters.cost) then"
on blessings, im not able to buy bless with my bank balance, any ideas?
 
Last edited by a moderator:
That's weird, it's supposed to work, check if your bless npc is using the module that you changed for bless.
 
This is what it says on StdModule.bless

elseif not player:removeMoneyNpc(type(parameters.cost) == "string" and npcHandler:parseMessage(parameters.cost, parseInfo) or parameters.cost) then

And Norf, which im trying to buy bless from, uses "Stdmodule.bless"

I also tried changing

elseif not player:removeMoneyNpc(type(parameters.cost) == "string" and npcHandler:parseMessage(parameters.cost, parseInfo) or parameters.cost) then

to

elseif not player:removeMoneyNpc(parameters.cost) then

but with no success
 
function StdModule.bless(cid, message, keywords, parameters, node)
local npcHandler = parameters.npcHandler
if npcHandler == nil then
error("StdModule.bless called without any npcHandler instance.")
end

if not npcHandler:isFocused(cid) then
return false
end

local player = Player(cid)
local parseInfo = {[TAG_BLESSCOST] = getBlessingsCost(player:getLevel()), [TAG_PVPBLESSCOST] = getPvpBlessingCost(player:getLevel())}
if player:hasBlessing(parameters.bless) then
npcHandler:say("You already possess this blessing.", cid)
elseif parameters.bless == 4 and player:getStorageValue(Storage.KawillBlessing) ~= 1 then
npcHandler:say("You need the blessing of the great geomancer first.", cid)
elseif parameters.bless == 1 then
npcHandler:say("This blessing is disabled.", cid)
elseif not player:removeMoneyNpc(type(parameters.cost) == "string" and npcHandler:parseMessage(parameters.cost, parseInfo) or parameters.cost) then
npcHandler:say("Oh. You do not have enough money.", cid)
else
npcHandler:say(parameters.text or "You have been blessed by one of the five gods!", cid)
if parameters.bless == 4 then
player:setStorageValue(Storage.KawillBlessing, 0)
end
player:addBlessing(parameters.bless)
player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
end
npcHandler:resetNpc(cid)
return true
end


With the current text, the Bless NPC asks if I want to buy the blessing, but when I say yes, he says nothing, and nothing happends
and when I remove "Npc" from "removeMoneyNpc"
The Bless NPC tell me I dont have enough gold.
Also when I tried your link, the same happends as when I use "removeMoneyNpc"
Any idea?
 
With the current text, the Bless NPC asks if I want to buy the blessing, but when I say yes, he says nothing, and nothing happends

Do you have getBlessingsCost and getPvpBlessingCost functions? You should use them in the script to get the money that you wanna remove and put in
player:removeMoneyNpc(money)

If you'll use from the function you can use the cost parameter just as a default value or something.

Otherwise you should just use it as player:removeMoneyNpc(parameters.cost)

I also tried changing

elseif not player:removeMoneyNpc(type(parameters.cost) == "string" and npcHandler:parseMessage(parameters.cost, parseInfo) or parameters.cost) then

to

elseif not player:removeMoneyNpc(parameters.cost) then

but with no success

Is cost a set parameter in the NPC script?
 
Last edited:
Yes I do, it looks like this
blessKeyword:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, text = 'So receive the shielding of your spirit, pilgrim.', cost = '|BLESSCOST|', bless = 5})
and comes from this i think?
local parseInfo = {[TAG_PLAYERNAME] = player:getName(), [TAG_TIME] = getTibianTime(), [TAG_BLESSCOST] = getBlessingsCost(player:getLevel())}
 
Yes I do, it looks like this
Have the function? The parseInfo gets the price from getBlessingsCost and the pvp one, would be used to display the msg and it doesn't seems to work, idk how you are using the pvp bless.

I did a sample code for the getBlessingsCost function:
Lua:
local function getBlessingsCost(level)
    local finalCost = 20000
    if level <= 30 then
        finalCost = 2000
    elseif level > 30 and level < 120 then
        finalCost = 200 * (level - 20)
    end
    return finalCost
end
 
Last edited:
You mean this?

function StdModule.bless(cid, message, keywords, parameters, node)
local npcHandler = parameters.npcHandler
if npcHandler == nil then
error("StdModule.bless called without any npcHandler instance.")
end

The calculation of the price seem to be correct, on a level 106, the price of 1 blessing is 17200.

16:50 Norf: Welcome, pilgrim. How may I help you? Are you in need of healing?
16:50 Testtest [106]: spiritual
16:50 Norf: Here in the whiteflower temple you may receive the blessing of spiritual shielding. But we must ask of you to sacrifice 17200 gold. Are you still interested?
16:50 Testtest [106]: yes


With money in the bank nothing happends, and with money in my backpack nothing happends either
 
Back
Top