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

Quest npc, question

Inteligentny

Im not.
Joined
Aug 2, 2008
Messages
485
Reaction score
0
Hello I would know if it is possible to make npc selling for example Ice rapier only if someone have done quest, I mean how to use here storage value?

Code:
<npc name="Zoger" script="data/npc/scripts/zoger.lua" autowalk="25" floorchange="0" access="5" level="1" maglevel="1">
    <health now="150" max="150"/>
    <look type="128" head="20" body="30" legs="40" feet="50" addons="0"/>
    <parameters>
        <parameter key="module_shop" value="1" />
        <parameter key="message_greet" value="Hello |PLAYERNAME|. I sell fishing rods(150gp) and i buy worms(1gp)." />
        
        <parameter key="shop_buyable" value="ice rapier,2396,2000" />
    </parameters>
</npc>
 
Try with my script (not tested)
PHP:
<npc name="Ice Rapier guy" script="data/npc/scripts/default.lua" autowalk="25" floorchange="0" access="5" level="1" maglevel="1">
    <health now="150" max="150"/>
    <look type="128" head="20" body="30" legs="40" feet="50" addons="0"/>
   
<interaction range="3" idletime="30" idleinterval="300" defaultpublic="0">
    <include file="npc.xml"/>

   <interact keywords="job">
      <response text="I am a ice rapier seller! say buy ice rapier to buy."/>
    </interact>

<interact keywords="buy ice rapier" topic="999">
          <response text="you are sure? i will check if you have my storage ;P?">
           <action name="script">
		  <![CDATA[
local price = 10000                  
local storage = getPlayerStorageValue(cid,yourstorage)
                  if(storage == -1) and doPlayerRemoveMoney(cid,price) then
                    selfSay("ok take it")
                  doPlayerAddItem(cid,Icerapier,1)
				  else
                    selfSay("You havent Storage!.")
                    _state.b1 = true
                  end
                ]]>

           </action>
				
			  </interact>

  </interaction>




	</npc>
 
Last edited:
It looks very nice, but I have this erros in console :/



probgj5.jpg
 
Change into donald.xml, "Autowalk" to "Walkinterval"

and edit the Xml file for this:
PHP:
<npc name="Ice Rapier guy" script="data/npc/scripts/default.lua" autowalk="25" floorchange="0" access="5" level="1" maglevel="1">
    <health now="150" max="150"/>
    <look type="128" head="20" body="30" legs="40" feet="50" addons="0"/>
   
<interaction range="3" idletime="30" idleinterval="300" defaultpublic="0">
    <include file="npc.xml"/>

   <interact keywords="job">
      <response text="I am a ice rapier seller! say buy ice rapier to buy."/>
    </interact>

<interact keywords="buy ice rapier" topic="999">
          <response text="you are sure? i will check if you have my storage ;P?"/>
           <action ="script">
          <![CDATA[
local price = 10000                  
local storage = getPlayerStorageValue(cid,yourstorage)
                  if(storage == -1) and doPlayerRemoveMoney(cid,price) then
                    selfSay("ok take it")
                  doPlayerAddItem(cid,Icerapier,1)
                  else
                    selfSay("You havent Storage!.")
                    _state.b1 = true
                  end
                ]]>

           </action>
                
              </interact>

  </interaction>



</npc>
 
Last edited:
Donald is other npc, I have still same error, im not talking about walkinterval error
when I try to summon it /s npc

prob2su0.jpg




please help someone ;P
 
Last edited:
lol thanks ;d I was blind :p


but now comes another problem, the npc won't answer to keywords :/ anyone know why?


Code:
13:15 Ice Rapier guy: Welcome, Me! I have been expecting you.
13:15 Me [375]: job
13:15 Me [375]: buy ice rapier
13:15 Me [375]: ice rapier
13:16 Ice Rapier guy: Good bye, Me!


:/
 
Last edited:
Try this one, made as fast as I can, not in XML. You had wrong npc file (in first post), cause it will sell ice rapiers to EVERYONE by trade window. I don't like this XML scripting, it doesn't make a difference if you are using NPCs written in XML or LUA...

this goes to /npc/scripts/ice_rapier.lua
Code:
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 price = 10000                  
	local storage = getPlayerStorageValue(cid,52525)

	if(msgcontains(msg, 'ice rapier') or msgcontains(msg, 'mission')) then
		selfSay('I can offer you this new, shiny ice rapier, but you need to have storage value of 52525', cid)
		talkState[talkUser] = 1
	elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
		if(storage == 1) then
			if(doPlayerRemoveMoney(cid, price) == TRUE) then
				doPlayerAddItem(cid,2396,1)
				selfSay('Here you are.', cid)
			else
				selfSay('Sorry, you don\'t have enough gold.', cid)
			end
		else
		selfSay('Sorry, you don\'t have storage value of 52525.', cid)
		end
	elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then
		talkState[talkUser] = 0
		selfSay('Ok then.', cid)
	end

	return true
end

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

and

this goes to /npc/Name.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Name" script="data/npc/scripts/ice_rapier.lua" walkinterval="2000" floorchange="0">
	<health now="100" max="100"/>
	<look type="128" head="17" body="54" legs="114" feet="0" addons="2"/>
	<parameters>
		<parameter key="message_greet" value="Hello |PLAYERNAME|, I am reselling my new versions of {ice rapier}! The deadliest weapon in the universe!"/>
	</parameters>
</npc>
 
But I think there is one mistake in code. Try to talk with NPC this way:

- hi
- ice rapier
- yes
- yes
- yes
- yes

Will NPC give you 4 ice rapiers or one?

If NPC given you 4 items instead of one, add
Code:
		talkState[talkUser] = 0
under
Code:
				selfSay('Here you are.', cid)

I you received one item, don't change anything.

Regards,
Hermes
 

Similar threads

Back
Top