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

Bless

Dogrinha

New Member
Joined
Oct 6, 2019
Messages
206
Solutions
1
Reaction score
2
Hey Guys! My players even with all blesses they're losing items when they die. How do i fix it?
TFS 0.4
 
In your config.lua Blessings looks like this?
Lua:
   -- Blessings
   -- NOTE: blessingReduction* regards items/containers loss.
   -- eachBlessReduction is how much each bless reduces the experience/magic/skills loss.
  blessings = true
  blessingOnlyPremium = false
  blessingReductionBase = 30
  blessingReductionDecrement = 5
  eachBlessReduction = 8
Inside your DB/players the column blessings when you buy bless it shows value as 0 or 31?
 
They don't have blessings as it shows in DB its 0, Post your blessing script.
 
Post your NPC script and try with this Talkactions once tell me if you lose your items.
Lua:
function onSay(cid, words, param)
local fail = 0

    if getPlayerLevel(cid) < 31 then
        cost = 2000
    else
        cost = ((getPlayerLevel(cid) - 30) * 200) + 2000
    end
    
    if cost > 20000 then
        cost = 20000
    end

    for i = 1, 5 do
        if getPlayerBlessing(cid, i) then
            fail = fail + 1
        else
            if doPlayerRemoveMoney(cid, cost) == TRUE then
                doPlayerAddBlessing(cid, i)
                if i == 5 and not(fail == 5) then
                    doSendMagicEffect(getPlayerPosition(cid), CONST_ME_HOLYDAMAGE)
                end
            else
                doPlayerSendCancel(cid, "You do not have enough money to buy all the blessings!")
                break
            end
        end
    end
    if fail == 5 then
        doPlayerSendCancel(cid, "You already have all the blessings!")
    end
return TRUE
end
 
Lua:
eremo

local keywordHandler = KeywordHandler:new()
        local npcHandler = NpcHandler:new(keywordHandler)
        NpcSystem.parseParameters(npcHandler)
        
        
        
        -- OTServ event handling functions start
        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
        -- OTServ event handling functions end
        
        


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

function creatureSayCallback(cid, type, msg)

if(not npcHandler:isFocused(cid)) then

return false

end

local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid

local shopWindow = {}

local spells = {

{id=2269, buy = 2000, name = "Exevo Grav Vita", spell_name = "Wild Growth", vocations = {6}, level = 1},

{id=10555, buy = 2000, name = "Conjure Power Bolt", spell_name = "Conjure Power Bolt", vocations = {7}, level = 1},

{id=10563, buy = 2000, name = "Challenge", spell_name = "Challenge", vocations = {8}, level = 1},
}

local onBuy = function(cid, item, subType, amount, ignoreCap, inBackpacks)

if not getPlayerLearnedInstantSpell(cid, shopWindow[item].Words) then

if getPlayerLevel(cid) >= shopWindow[item].Level then

if isInArray(shopWindow[item].Vocs, getPlayerVocation(cid)) then

doPlayerRemoveMoney(cid, shopWindow[item].Price)
doSendMagicEffect(getCreaturePos(cid), 12)
doPlayerLearnInstantSpell(cid, shopWindow[item].Words)



npcHandler:say("You have learned new spell. "..shopWindow[item].Words, cid)

else

npcHandler:say("This spell is not for your vocation.", cid)

end

else

npcHandler:say("You need more level "..shopWindow[item].Level.." or more to buy spell.", cid)

end

else

npcHandler:say("You already know this spell..", cid)

end

return true

end

if msgcontains(msg, 'trade') or msgcontains(msg, 'spell') then

for var, item in pairs(spells) do

shopWindow[item.id] = {Level = item.level, Vocs = item.vocations, item_id = item.id, Price = item.buy, subType = 0, Words = item.spell_name, SpellName = item.name}

end

openShopWindow(cid, spells, onBuy, onSell)

end

return true

end       
        
function amulet(cid, message, keywords, parameters, node)
   if(not npcHandler:isFocused(cid)) then
        return false
    end
    
    local player_gold     = getPlayerItemCount(cid,2148)
    local player_plat     = getPlayerItemCount(cid,2152)*100
    local player_crys     = getPlayerItemCount(cid,2160)*10000
    local player_money     = player_gold + player_plat + player_crys
    
         if player_money >= 50000 then
        if doPlayerRemoveMoney(cid,50000) then
            npcHandler:say('Here it is.', cid)
            doPlayerAddItem(cid,2173,1)
        end
        else
            npcHandler:say('Come back when you have enough money.', cid)
    end
end   

node1 = keywordHandler:addKeyword({'amulet of loss'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'To get the amulet of loss you need to give me 50000 gold coins, do you have them with you?.'})
node1:addChildKeyword({'yes'}, amulet, {})
node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Believe me, it\'s better for you that way.', reset = true})
        
        -- Don't forget npcHandler = npcHandler in the parameters. It is required for all StdModule functions!
    local travelNode = keywordHandler:addKeyword({'cormaya'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Should I teleport you back to Pemaret?'})
            travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = false, level = 1, cost = 0, destination = {x=33287, y=31956, z=7} })
            travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Maybe later.'})
            
    local travelNode = keywordHandler:addKeyword({'back'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Should I teleport you back to Pemaret?'})
            travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = false, level = 1, cost = 0, destination = {x=33287, y=31956, z=7} })
            travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Maybe later.'})
            
        
        keywordHandler:addKeyword({'job'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I teach some {spells}, provide one of the bless {solitude}, and sell some amulet. Ask me for a {trade} if you like.'})
        


    local node1 = keywordHandler:addKeyword({'fourth bless'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Here you may receive the blessing {Wisdom of Solitude}. But we must ask of you to sacrifice 10000 gold coins. Are you still interested?'})
    node1:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, number = 4, premium = false, baseCost = 10000, levelCost = 0, startLevel = 10, endLevel = 120})
    node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})
    
    local node2 = keywordHandler:addKeyword({'solitude'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Here you may receive the blessing {Wisdom of Solitude}. But we must ask of you to sacrifice 10000 gold coins. Are you still interested?'})
    node2:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, number = 4, premium = false, baseCost = 10000, levelCost = 0, startLevel = 10, endLevel = 120})
    node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Oh. You do not have enough money.'})
    

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())
 
Did you try my Talkactions? or you only read half of the sentence?
Post your data\npc\lib\npcsystem\modules.lua or only post this function from inside it.
function StdModule.bless(cid, message, keywords, parameters, node)
 
yes i try talkation and no work
Lua:
-- Advanced NPC System (Created by Jiddo),
-- Modified by Talaturen.

if(NpcSystem == nil) then
    -- Loads the underlying classes of the npcsystem.
    dofile(getDataDir() .. 'npc/lib/npcsystem/keywordhandler.lua')
    dofile(getDataDir() .. 'npc/lib/npcsystem/queue.lua')
    dofile(getDataDir() .. 'npc/lib/npcsystem/npchandler.lua')
    dofile(getDataDir() .. 'npc/lib/npcsystem/modules.lua')

    -- Global npc constants:

    -- Keyword nestling behavior. For more information look at the top of keywordhandler.lua
    KEYWORD_BEHAVIOR = BEHAVIOR_NORMAL_EXTENDED

    -- Greeting and unGreeting keywords. For more information look at the top of modules.lua
    FOCUS_GREETWORDS = {'hi', 'hello', 'hey'}
    FOCUS_FAREWELLWORDS = {'bye', 'farewell', 'cya'}

    -- The word for requesting trade window. For more information look at the top of modules.lua
    SHOP_TRADEREQUEST = {'offer', 'trade'}

    -- The word for accepting/declining an offer. CAN ONLY CONTAIN ONE FIELD! For more information look at the top of modules.lua
    SHOP_YESWORD = {'yes'}
    SHOP_NOWORD = {'no'}

    -- Pattern used to get the amount of an item a player wants to buy/sell.
    PATTERN_COUNT = '%d+'

    -- Talkdelay behavior. For more information, look at the top of npchandler.lua.
    NPCHANDLER_TALKDELAY = TALKDELAY_ONTHINK

    -- Conversation behavior. For more information, look at the top of npchandler.lua.
    NPCHANDLER_CONVBEHAVIOR = CONVERSATION_PRIVATE

    -- Constant strings defining the keywords to replace in the default messages.
    --    For more information, look at the top of npchandler.lua...
    TAG_PLAYERNAME = '|PLAYERNAME|'
    TAG_ITEMCOUNT = '|ITEMCOUNT|'
    TAG_TOTALCOST = '|TOTALCOST|'
    TAG_ITEMNAME = '|ITEMNAME|'
    TAG_QUEUESIZE = '|QUEUESIZE|'

    NpcSystem = {}

    -- Gets an npcparameter with the specified key. Returns nil if no such parameter is found.
    function NpcSystem.getParameter(key)
        local ret = getNpcParameter(tostring(key))
        if((type(ret) == 'number' and ret == 0) or ret == nil) then
            return nil
        else
            return ret
        end
    end

    -- Parses all known parameters for the npc. Also parses parseable modules.
    function NpcSystem.parseParameters(npcHandler)
        local ret = NpcSystem.getParameter('idletime')
        if(ret ~= nil) then
            npcHandler.idleTime = tonumber(ret)
        end
        local ret = NpcSystem.getParameter('talkradius')
        if(ret ~= nil) then
            npcHandler.talkRadius = tonumber(ret)
        end
        local ret = NpcSystem.getParameter('message_greet')
        if(ret ~= nil) then
            npcHandler:setMessage(MESSAGE_GREET, ret)
        end
        local ret = NpcSystem.getParameter('message_farewell')
        if(ret ~= nil) then
            npcHandler:setMessage(MESSAGE_FAREWELL, ret)
        end
        local ret = NpcSystem.getParameter('message_decline')
        if(ret ~= nil) then
            npcHandler:setMessage(MESSAGE_DECLINE, ret)
        end
        local ret = NpcSystem.getParameter('message_needmorespace')
        if(ret ~= nil) then
            npcHandler:setMessage(MESSAGE_NEEDMORESPACE, ret)
        end
        local ret = NpcSystem.getParameter('message_needspace')
        if(ret ~= nil) then
            npcHandler:setMessage(MESSAGE_NEEDSPACE, ret)
        end
        local ret = NpcSystem.getParameter('message_sendtrade')
        if(ret ~= nil) then
            npcHandler:setMessage(MESSAGE_SENDTRADE, ret)
        end
        local ret = NpcSystem.getParameter('message_noshop')
        if(ret ~= nil) then
            npcHandler:setMessage(MESSAGE_NOSHOP, ret)
        end
        local ret = NpcSystem.getParameter('message_oncloseshop')
        if(ret ~= nil) then
            npcHandler:setMessage(MESSAGE_ONCLOSESHOP, ret)
        end
        local ret = NpcSystem.getParameter('message_onbuy')
        if(ret ~= nil) then
            npcHandler:setMessage(MESSAGE_ONBUY, ret)
        end
        local ret = NpcSystem.getParameter('message_onsell')
        if(ret ~= nil) then
            npcHandler:setMessage(MESSAGE_ONSELL, ret)
        end
        local ret = NpcSystem.getParameter('message_missingmoney')
        if(ret ~= nil) then
            npcHandler:setMessage(MESSAGE_MISSINGMONEY, ret)
        end
        local ret = NpcSystem.getParameter('message_needmoney')
        if(ret ~= nil) then
            npcHandler:setMessage(MESSAGE_NEEDMONEY, ret)
        end
        local ret = NpcSystem.getParameter('message_missingitem')
        if(ret ~= nil) then
            npcHandler:setMessage(MESSAGE_MISSINGITEM, ret)
        end
        local ret = NpcSystem.getParameter('message_needitem')
        if(ret ~= nil) then
            npcHandler:setMessage(MESSAGE_NEEDITEM, ret)
        end
        local ret = NpcSystem.getParameter('message_idletimeout')
        if(ret ~= nil) then
            npcHandler:setMessage(MESSAGE_IDLETIMEOUT, ret)
        end
        local ret = NpcSystem.getParameter('message_walkaway')
        if(ret ~= nil) then
            npcHandler:setMessage(MESSAGE_WALKAWAY, ret)
        end
        local ret = NpcSystem.getParameter('message_alreadyfocused')
        if(ret ~= nil) then
            npcHandler:setMessage(MESSAGE_ALREADYFOCUSED, ret)
        end
        local ret = NpcSystem.getParameter('message_placedinqueue')
        if(ret ~= nil) then
            npcHandler:setMessage(MESSAGE_PLACEDINQUEUE, ret)
        end
        local ret = NpcSystem.getParameter('message_buy')
        if(ret ~= nil) then
            npcHandler:setMessage(MESSAGE_BUY, ret)
        end
        local ret = NpcSystem.getParameter('message_sell')
        if(ret ~= nil) then
            npcHandler:setMessage(MESSAGE_SELL, ret)
        end
        local ret = NpcSystem.getParameter('message_bought')
        if(ret ~= nil) then
            npcHandler:setMessage(MESSAGE_BOUGHT, ret)
        end
        local ret = NpcSystem.getParameter('message_sold')
        if(ret ~= nil) then
            npcHandler:setMessage(MESSAGE_SOLD, ret)
        end

        -- Parse modules.
        for parameter, module in pairs(Modules.parseableModules) do
            local ret = NpcSystem.getParameter(parameter)
            if(ret ~= nil) then
                local number = tonumber(ret)
                if(number ~= 0 and module.parseParameters ~= nil) then
                    local instance = module:new()
                    npcHandler:addModule(instance)
                    instance:parseParameters()
                end
            end
        end
    end
end
 
But when I buy all the blessings, the item that shows the blessings I own says I own, so I don't believe the problem is npc, but the blessing itself. because your talkaction didn't work either
 
You showed above your DB/players blessings its written 0 instead of 31 that means the place isn't even added to the player so your script doesn't work.
 
should i change the rook sample to blessing 31?
Or do you want me to change the npc system, buy the bless, and see if the database will change?
 
Change the NPC modules as the one I posted above then buy blessing and check if your DB/players blessings value change from 0 to 31 or not, Also buy bless with the talkaction I posted above and tell me if it changed to 31 or still 0.
Edit : If you are still losing items after changing modules and testing with Talkactions/NPC then try this
Add data\creaturescripts\creaturescripts.xml
XML:
<event type="preparedeath" name="BlessDeath" event="script" value="blessingdeath.lua"/>
Then data\creaturescripts\scripts\login.lua add
Lua:
registerCreatureEvent(cid, "BlessDeath")
and create data\creaturescripts\scripts\ blessdeath.lua
Lua:
function onPrepareDeath(cid)
for i = 1,5 do
  if getPlayerBlessing(cid, i) then
        doCreatureSetDropLoot(cid, false)
        doPlayerSetLossPercent(cid, PLAYERLOSS_ITEMS, 0)
    doPlayerSetLossPercent(cid, PLAYERLOSS_CONTAINERS, 0)
    end
end
return true
end
 
Last edited:
I did a new test and found that
1 - player with full bless without aol and die for player, loses all items.

2- the player of bless full and aol if he dies pvp does not lose aol.

3 player bless full die for monster, lose all items too
 
I did a new test and found that
1 - player with full bless without aol and die for player, loses all items.

2- the player of bless full and aol if he dies pvp does not lose aol.

3 player bless full die for monster, lose all items too
try to change
Code:
blessings = true
to
Code:
blessings = false
then use M0ustafa's scripts to see if it works or not because i assume the problem from the main blessing at the config.
Also i see M0ustafa's scripts gives another values that's why the reason is...
 
Last edited:
Last edited:
Back
Top