• 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 [Release] Bless Module

Piotrek1447

Member
Joined
Jun 1, 2007
Messages
658
Reaction score
16
Location
Rzeszów, Poland
Here is bless module written by me for my server because orginal bless man some times didn't work.^_^

In modules.lua

After this
Code:
	function StdModule.learnSpell(cid, message, keywords, parameters, node)
		local npcHandler = parameters.npcHandler
		if(npcHandler == nil) then
			error('StdModule.buySpell called without any npcHandler instance.')
		end
		if(cid ~= npcHandler.focus) then
			return false
		end
		if getPlayerLearnedInstantSpell(cid, parameters.spellName) == TRUE then
			npcHandler:say('You already know this spell.')
		elseif getPlayerLevel(cid) < parameters.level then
			npcHandler:say('You need to obtain a level of ' .. parameters.level .. ' or higher to be able to learn ' .. parameters.spellName .. '.')
		elseif parameters.premium == TRUE and getPlayerPremiumDays(cid) == 0 then
			npcHandler:say('You need a premium account in order to buy ' .. parameters.spellName .. '.')
		elseif getPlayerVocation(cid) ~= parameters.vocation and getPlayerVocation(cid) ~= parameters.vocation + 4 and vocation ~= 9 then
			npcHandler:say('This spell is not for your vocation')
		elseif doPlayerRemoveMoney(cid, parameters.price) == FALSE then
			npcHandler:say('You do not have enough money, this spell costs ' .. parameters.price .. ' gold.')
		else
			npcHandler:say('You have learned ' .. parameters.spellName .. '.')
			playerLearnInstantSpell(cid, parameters.spellName)	
		end
		npcHandler:resetNpc()
		return true
	end

Add this
Code:
	function StdModule.bless(cid, message, keywords, parameters, node)
		local npcHandler = parameters.npcHandler
		if(npcHandler == nil) then
			error('StdModule.buySpell called without any npcHandler instance.')
		end
		if(cid ~= npcHandler.focus) then
			return false
		end
		if getPlayerBlessing(cid, parameters.bless) then
			npcHandler:say("A god has already blessed you with this blessing.")
		elseif parameters.premium == TRUE and getPlayerPremiumDays(cid) == 0 then
			npcHandler:say("You need a premium account to buy blessings.")
		elseif doPlayerRemoveMoney(cid, parameters.cost) == FALSE then
			npcHandler:say("You don't have enough money.")
		else
			npcHandler:say("You have been blessed by one of the five gods!")
			doPlayerAddBlessing(cid, parameters.bless)
		end
		npcHandler:resetNpc()
		return true
	end

This is all, here is example NPC.
Code:
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, bless = 1, premium = true, cost = 10000})
	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, bless = 2, premium = true, cost = 10000})
	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, bless = 3, premium = true, cost = 10000})
	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, bless = 4, premium = true, cost = 10000})
	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, bless = 5, premium = true, cost = 10000})
	node5:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})	

npcHandler:addModule(FocusModule:new())

Yours,
Razer
 
Last edited:
Im using newest version tfs and its not working for me.

[13/05/2008 12:27:28] data/npc/scripts/bless.lua:10: attempt to index global 'keywordHandler' (a nil value)
[13/05/2008 12:27:28] Warning: [NpcScript::NpcScript] Can not load script. data/npc/scripts/bless.lua
 
nice and thanks for releasing it, it works fine for me!
 
Back
Top