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

Blessing NPC

/data/npcs/create file blesser.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Blesser" script="data/npc/scripts/bless.lua" walkinterval="2000" speed="1" floorchange="0" access="5" level="1" maglevel="1">
	<health now="150" max="150"/>
	<look type="57" head="115" body="113" legs="31" feet="38"/>
	<parameters>
	<parameter key="message_greet" value="Hello,  |PLAYERNAME|. I sell 'first', 'second', 'third', 'fourth' and 'fifth' bless for 10.000 gold coins each." />	
	</parameters>
</npc>
/data/npc/scripts/bless.lua
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({'1'}, 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 = false, cost = 10000})
	node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})

local node2 = keywordHandler:addKeyword({'2'}, 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 = false, cost = 10000})
	node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})

local node3 = keywordHandler:addKeyword({'3'}, 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 = false, cost = 10000})
	node3:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})

local node4 = keywordHandler:addKeyword({'4'}, 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 = false, cost = 10000})
	node4:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})

local node5 = keywordHandler:addKeyword({'5'}, 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 = false, cost = 10000})
	node5:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})
	
	local node6 = keywordHandler:addKeyword({'first bless'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the first blessing for 10000 gold?'})
	node6:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, bless = 1, premium = true, cost = 10000})
	node6:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})

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

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

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

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

npcHandler:addModule(FocusModule:new())
 
Just created, not tested:
XML:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Oliver" floorchange="0" walkinterval="0">
	<health now="150" max="150"/>
	<look type="128" head="77" body="65" legs="59" feet="116" addons="1"/>

  <interaction range="3" idletime="30">

    <interact keywords="hi" focus="1">
      <!--These are the keywords will trigger this interaction-->
      <keywords>hello</keywords>
      <keywords>greet</keywords>
	  <keywords>hei</keywords>

      <response>
        <action name="script">
		local bless1 = getPlayerBlessing(cid, 1)
		local bless2 = getPlayerBlessing(cid, 2)
		local bless3 = getPlayerBlessing(cid, 3)
		local bless4 = getPlayerBlessing(cid, 4)
		local bless5 = getPlayerBlessing(cid, 5)
		
		if bless1 == true then
		local bless11 = 1
		else
		local bless11 = 0
		end
		if bless2 == true then
		local bless22 = 1
		else
		local bless22 = 0
		end
		if bless3 == true then
		local bless33 = 1
		else
		local bless33 = 0
		end
		if bless4 == true then
		local bless44 = 1
		else
		local bless44 = 0
		end
		if bless5 == true then
		local bless55 = 1
		else
		local bless55 = 0
		end
		
		local blesstot = bless11 + bless22 + bless33 + bless44 + bless55
		
			selfSay("Hello there, you currently have "..blesstot.." blessings. Just type {first blessing} to buy first blessing, second, third and so on...", cid)
        </action>
      </response>
  </interact>

   <interact keywords="first">
	<response>
		<action name="script">
		if doPlayerRemoveMoney(cid, 10000) == true then
            doPlayerAddBlessing(cid, 1)		
			selfSay('You got the first blessing!', cid)
			doSendMagicEffect(getPlayerPosition(cid), CONST_ME_HOLYDAMAGE)
		else
			selfSay('You need 10k for this blessing!', cid)
		end
        </action>
	</response>
   </interact>
   
   <interact keywords="second">
	<response>
		<action name="script">
		if doPlayerRemoveMoney(cid, 10000) == true then
            doPlayerAddBlessing(cid, 2)		
			selfSay('You got the second blessing!', cid)
			doSendMagicEffect(getPlayerPosition(cid), CONST_ME_HOLYDAMAGE)
		else
			selfSay('You need 10k for this blessing!', cid)
		end
        </action>
	</response>
   </interact>
   
   <interact keywords="third">
	<response>
		<action name="script">
		if doPlayerRemoveMoney(cid, 10000) == true then
            doPlayerAddBlessing(cid, 3)		
			selfSay('You got the third blessing!', cid)
			doSendMagicEffect(getPlayerPosition(cid), CONST_ME_HOLYDAMAGE)
		else
			selfSay('You need 10k for this blessing!', cid)
		end
        </action>
	</response>
   </interact>
   
   <interact keywords="fourth">
	<response>
		<action name="script">
		if doPlayerRemoveMoney(cid, 10000) == true then
            doPlayerAddBlessing(cid, 4)		
			selfSay('You got the fourth blessing!', cid)
			doSendMagicEffect(getPlayerPosition(cid), CONST_ME_HOLYDAMAGE)
		else
			selfSay('You need 10k for this blessing!', cid)
		end
        </action>
	</response>
   </interact>
   
   <interact keywords="fifth">
	<response>
		<action name="script">
		if doPlayerRemoveMoney(cid, 10000) == true then
            doPlayerAddBlessing(cid, 5)		
			selfSay('You got the fifth blessing!', cid)
			doSendMagicEffect(getPlayerPosition(cid), CONST_ME_HOLYDAMAGE)
		else
			selfSay('You need 10k for this blessing!', cid)
		end
        </action>
	</response>
   </interact>
	
	<interact keywords="bye" focus="0">
      <keywords>farewell</keywords>
		<response>
			<action name="script">
				selfSay('Farewell! Good luck to you!', cid)
			</action>
		</response>
    </interact>
  
</interaction>
</npc>
 
Replace:
Lua:
 <action name="script">
		local bless1 = getPlayerBlessing(cid, 1)
		local bless2 = getPlayerBlessing(cid, 2)
		local bless3 = getPlayerBlessing(cid, 3)
		local bless4 = getPlayerBlessing(cid, 4)
		local bless5 = getPlayerBlessing(cid, 5)
 
		if bless1 == true then
		local bless11 = 1
		else
		local bless11 = 0
		end
		if bless2 == true then
		local bless22 = 1
		else
		local bless22 = 0
		end
		if bless3 == true then
		local bless33 = 1
		else
		local bless33 = 0
		end
		if bless4 == true then
		local bless44 = 1
		else
		local bless44 = 0
		end
		if bless5 == true then
		local bless55 = 1
		else
		local bless55 = 0
		end
 
		local blesstot = bless11 + bless22 + bless33 + bless44 + bless55
 
			selfSay("Hello there, you currently have "..blesstot.." blessings. Just type {first blessing} to buy first blessing, second, third and so on...", cid)
        </action>

with:
Lua:
 <action name="script"> 
			selfSay("Hello there, I sell blessings. Just type {first blessing} to buy first blessing, second, third and so on...", cid)
        </action>

Its not an important function, it was a bad attempt to make the NPC count how many blessings you have.

edit: Nevermind, wait a bit. I will redo whole script.

edit2: Done. Try this:
XML:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Oliver" floorchange="0" walkinterval="0">
	<health now="150" max="150"/>
	<look type="128" head="77" body="65" legs="59" feet="116" addons="1"/>

  <interaction range="3" idletime="30">

    <interact keywords="hi" focus="1">
      <!--These are the keywords will trigger this interaction-->
      <keywords>hello</keywords>
      <keywords>greet</keywords>
	  <keywords>hei</keywords>

      <response>
        <action name="script">
		selfSay("Hello there, I sell blessings. Just type {first blessing} to buy first blessing, second, third and so on...", cid)
        </action>
      </response>
  </interact>

   <interact keywords="first">
	<response>
		<action name="script">
		if getPlayerBlessing(cid, 1) then
			selfSay('You already have this blessing.', cid)
		else
			if doPlayerRemoveMoney(cid, 10000) == true then
				doPlayerAddBlessing(cid, 1)		
				selfSay('You got the first blessing!', cid)
				doSendMagicEffect(getPlayerPosition(cid), CONST_ME_HOLYDAMAGE)
			else
				selfSay('You need 10k for this blessing!', cid)
			end
		end
        </action>
	</response>
   </interact>
   
   <interact keywords="second">
	<response>
		<action name="script">
		if getPlayerBlessing(cid, 2) then
			selfSay('You already have this blessing.', cid)
		else
			if doPlayerRemoveMoney(cid, 10000) == true then
				doPlayerAddBlessing(cid, 2)		
				selfSay('You got the second blessing!', cid)
				doSendMagicEffect(getPlayerPosition(cid), CONST_ME_HOLYDAMAGE)
			else
				selfSay('You need 10k for this blessing!', cid)
			end
		end
        </action>
	</response>
   </interact>
   
   <interact keywords="third">
	<response>
		<action name="script">
		if getPlayerBlessing(cid, 3) then
			selfSay('You already have this blessing.', cid)
		else
			if doPlayerRemoveMoney(cid, 10000) == true then
				doPlayerAddBlessing(cid, 3)		
				selfSay('You got the third blessing!', cid)
				doSendMagicEffect(getPlayerPosition(cid), CONST_ME_HOLYDAMAGE)
			else
				selfSay('You need 10k for this blessing!', cid)
			end
		end
        </action>
	</response>
   </interact>
   
   <interact keywords="fourth">
	<response>
		<action name="script">
		if getPlayerBlessing(cid, 4) then
			selfSay('You already have this blessing.', cid)
		else
			if doPlayerRemoveMoney(cid, 10000) == true then
				doPlayerAddBlessing(cid, 4)		
				selfSay('You got the fourth blessing!', cid)
				doSendMagicEffect(getPlayerPosition(cid), CONST_ME_HOLYDAMAGE)
			else
				selfSay('You need 10k for this blessing!', cid)
			end
		end
        </action>
	</response>
   </interact>
   
   <interact keywords="fifth">
	<response>
		<action name="script">
		if getPlayerBlessing(cid, 5) then
			selfSay('You already have this blessing.', cid)
		else
			if doPlayerRemoveMoney(cid, 10000) == true then
				doPlayerAddBlessing(cid, 5)		
				selfSay('You got the fifth blessing!', cid)
				doSendMagicEffect(getPlayerPosition(cid), CONST_ME_HOLYDAMAGE)
			else
				selfSay('You need 10k for this blessing!', cid)
			end
		end
        </action>
	</response>
   </interact>
	
	<interact keywords="bye" focus="0">
      <keywords>farewell</keywords>
		<response>
			<action name="script">
				selfSay('Farewell! Good luck to you!', cid)
			</action>
		</response>
    </interact>
  
</interaction>
</npc>
 
Last edited:
Back
Top