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

Need a NPC Blesser 8.0!!

There is an example NPC in forgottenserver that sell blessings.
 
Please make this , it would be nice if some one could make it !

Hmm maby there is somting wron with your readin i'll make th text bigger so u can read it =), How nice of me eh?


There is already an blesser scripted in TheForgottenServer, just look good and you will find it.
Close thread plx0r
 
Code:
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

function creatureSayCallback(cid, type, msg)
	-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
	if(npcHandler.focus ~= cid) then
		return false
	end

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

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Code:
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

function creatureSayCallback(cid, type, msg)
	-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
	if(npcHandler.focus ~= cid) then
		return false
	end

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

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



i got that npc and it dont work, if i say "yes" with cash in bp and everything set. nothing happends :S i tested on XML thats maybe why
 
Back
Top