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

[0.3.2] Bless NPC

Mefiu

New Member
Joined
Mar 2, 2008
Messages
221
Reaction score
0
Hello.
Im using TFS 0.3.2 and i need asap working bless npc.
Mine doesnt respond when i say "first bless"

Code :
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

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(npcHandler.focus ~= cid) then
		return FALSE
	end

	if msgcontains(msg, 'blessing') or msgcontains(msg, 'blessings') or msgcontains(msg, 'help') or msgcontains(msg, 'offer') then
		selfSay("I can provide you with five blessings... the 'first bless', 'second bless', 'third bless', 'fourth bless' and the 'fifth bless', they cost 10000 gold coins each.")
		talkState = 0
	elseif msgcontains(msg, 'first bless') then
		selfSay("Do you want to buy the first blessing for 10000 gold?")
		talkState = 1
	elseif msgcontains(msg, 'second bless') then
		selfSay("Do you want to buy the second blessing for 10000 gold?")
		talkState = 2
	elseif msgcontains(msg, 'third bless') then
		selfSay("Do you want to buy the third blessing for 10000 gold?")
		talkState = 3
	elseif msgcontains(msg, 'fourth bless') then
		selfSay("Do you want to buy the fourth blessing for 10000 gold?")
		talkState = 4
	elseif msgcontains(msg, 'fifth bless') then
		selfSay("Do you want to buy the fifth blessing for 10000 gold?")
		talkState = 5
	elseif talkState > 0 then
		if msgcontains(msg, 'yes') then
			if getPlayerBlessing(cid, talkState) then
				selfSay("A god has already blessed you with this blessing.")
			elseif isPremium(cid) == TRUE then
				if doPlayerRemoveMoney(cid, 10000) == TRUE then
					doPlayerAddBlessing(cid, talkState)
					selfSay("You have been blessed by one of the five gods!")
				else
					selfSay("You don't have enough money.")
				end
			else
				selfSay("You need a premium account to buy blessings.")
			end
		elseif msgcontains(msg, 'no') then
			selfSay("Then not.")
		end
		talk_state = 0
	end
	return TRUE
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

!edit
No error in console.
 
Try this NPC:
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)


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 node1 = keywordHandler:addKeyword({'first bless'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the first blessing for 2000 (plus level depending amount) gold?'})
	node1:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, number = 1, premium = true, baseCost = 2000, levelCost = 200, startLevel = 30, endLevel = 120})
	node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})

local node2 = keywordHandler:addKeyword({'second bless'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the second blessing for 2000 (plus level depending amount) gold?'})
	node2:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, number = 2, premium = true, baseCost = 2000, levelCost = 200, startLevel = 30, endLevel = 120})
	node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})

local node3 = keywordHandler:addKeyword({'third bless'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the third blessing for 2000 (plus level depending amount) gold?'})
	node3:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, number = 3, premium = true, baseCost = 2000, levelCost = 200, startLevel = 30, endLevel = 120})
	node3:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})

local node4 = keywordHandler:addKeyword({'fourth bless'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the fourth blessing for 2000 (plus level depending amount) gold?'})
	node4:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, number = 4, premium = true, baseCost = 2000, levelCost = 200, startLevel = 30, endLevel = 120})
	node4:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})

local node5 = keywordHandler:addKeyword({'fifth bless'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the fifth blessing for 2000 (plus level depending amount) gold?'})
	node5:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, number = 5, premium = true, baseCost = 2000, levelCost = 200, startLevel = 30, endLevel = 120})
	node5:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})

npcHandler:addModule(FocusModule:new())
 
You could also use a bless talkaction that gives you all the bless's for a fixed ammount.

Code:
<talkaction words="!buybless" script="buybless.lua"/>

Code:
local bless = {1, 2, 3, 4, 5}
local cost = 50000 -- Cost in gp.function onSay(cid, words, param)  
function onSay(cid, words, param) 
 for i = 1, table.maxn(bless) do        
 if(getPlayerBlessing(cid, bless[i])) then            
 doPlayerSendCancel(cid, "You have already all blessings.")            
 return TRUE        
 end    
 end        
 if(doPlayerRemoveMoney(cid, cost) == TRUE) then       
  for i = 1, table.maxn(bless) do           
   doPlayerAddBlessing(cid, bless[i])        
   end        
   doPlayerSendCancel(cid, "You bought all blessing.")   
    else        
    doPlayerSendCancel(cid, "You don\'t have enough money.")    
    end   
     return TRUE
     end
 
Try this one (Im not sure about it)

Lua:
  local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)


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 node1 = keywordHandler:addKeyword({'first bless'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the first blessing for 10000 gold?'})
        node1:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, number = 1, premium = true, baseCost = 10000, levelCost = 0, startLevel = 1, endLevel = 1})
        node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})

local node2 = keywordHandler:addKeyword({'second bless'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the second blessing for 10000 gold?'})
        node2:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, number = 2, premium = true, baseCost = 10000, levelCost = 0, startLevel = 1, endLevel = 1})
        node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})

local node3 = keywordHandler:addKeyword({'third bless'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the third blessing for 10000 gold?'})
        node3:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, number = 3, premium = true, baseCost = 10000, levelCost = 0, startLevel = 1, endLevel = 1})
        node3:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})

local node4 = keywordHandler:addKeyword({'fourth bless'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the fourth blessing for 10000 gold?'})
        node4:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, number = 4, premium = true, baseCost = 10000, levelCost = 0, startLevel = 1, endLevel = 1})
        node4:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})

local node5 = keywordHandler:addKeyword({'fifth bless'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the fifth blessing for 10000 gold?'})
        node5:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, number = 5, premium = true, baseCost = 10000, levelCost = 0, startLevel = 1, endLevel = 1})
        node5:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})

npcHandler:addModule(FocusModule:new())
 
Back
Top