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

NPC FOR BLESS

_M4G0_

Well-Known Member
Joined
Feb 6, 2016
Messages
505
Solutions
16
Reaction score
98
someone can help me for add verification for buy all bless,
something that only add ones that are missing
TFS 1.2

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


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 player = Player(cid)
         local cost = (2000 + ((math.min(130, player:getLevel(cid)) - 30) * 200))

    --
    if msgcontains(msg, "all") then
        --if player:getBlessings() == 4 then
        npcHandler:say("Would you like to receive that protection for a sacrifice of "..cost.." gold, child?", cid)
        npcHandler.topic[cid] = 11
        elseif msgcontains(msg, "yes") and npcHandler.topic[cid] == 11 then
            if(player:removeMoney(cost)) then
                for b = 1,6 do
                player:addBlessing(b, 1)
                npcHandler:say(19, "You have been blessed by the gods!", cid)
                player:getPosition():sendMagicEffect(CONST_ME_HOLYAREA)
                end   
            else
                selfSay("You need "..cost.." gold coins to buy all blessings.", cid)   
            end
    --else                           
        selfSay("You have already been blessed by the gods.", cid)               
    --    end
    end
    --
    return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

BUMP
 
Last edited by a moderator:
Solution
This should only bless the players whit the missing blessings and should only take money for the missing blessings aswell
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local blesscount = {}
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 =...
This should only bless the players whit the missing blessings and should only take money for the missing blessings aswell
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local blesscount = {}
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 player = Player(cid)
   local cost = (2000 + ((math.min(130, player:getLevel(cid)) - 30) * 200))
   
   if msgcontains(msg, "all") then
       blesscount[cid] = 0
       for i=1, 6 then
           if not player:hasBlessing(i) then
               blesscount[cid] = blesscount[cid]+1
           end
       end
       if blesscount[cid] > 0 then
           cost = cost * blesscount[cid]
       end
       npcHandler:say("Would you like to receive that protection for a sacrifice of "..cost.." gold, child?", cid)
       talkState[cid] = 11
   elseif msgcontains(msg, "yes") and talkState[cid] == 11 then
       if blesscount[cid] > 0 then
           if player:getMoney() >= cost then
               if(player:removeMoney(cost)) then
                   for i = 1,6 do
                       if not player:hasBlessing(i) then
                           player:addBlessing(i)
                       end
                   end
                   npcHandler:say(19, "You have been blessed by the gods!", cid)
                   player:getPosition():sendMagicEffect(CONST_ME_HOLYAREA)
                   talkState[cid] = nil
                   blesscount[cid] = nil
               end
           else
               selfSay("You need "..cost.." gold coins to buy all blessings.", cid)
               talkState[cid] = nil
               blesscount[cid] = nil
           end
       else
           selfSay("You have already been blessed by the gods.", cid)
           talkState[cid] = nil
           blesscount[cid] = nil
       end
    end

    return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Last edited:
Solution
Back
Top