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

Assistance with NPC script

kelto

New Member
Joined
Aug 11, 2007
Messages
11
Reaction score
0
Hello guys, ive been working on an NPC script for afew days now and i have no idea whats wrong with it. For now its just a simple script where you have 2 lines of conversation before an NPC teleports you to a new location (i will be adding more interactivity later).

Here is what i have so far..

Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Percy" floorchange="0" walkinterval="2000">
	<health now="150" max="150"/>
<look type="134" head="57" body="59" legs="40" feet="76" corpse="2212"/>

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

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

      <response>
        <action name="script">
          <!--
          if(getPlayerVocation(cid) ~= 0) then
            selfSay("You do not require my assistance.")
            _state.isidle = true
            return
          end
          -->

          if(getPlayerLevel(cid)) >= 8 then
            selfSay(getCreatureName(cid) .. ", are you ready to take your journey into the unknown?")
            _state.topic = 1
          else
            selfSay("You are not yet ready to begin your travels!")
            _state.isidle = true
          end
        </action>
      </response>

      </interact>

    <interact keywords="yes" topic="1">

      <!--Normal account-->
      <response text="Are you certian you are ready?">
        <action name="topic" value="2"/>
          _state.n1 = 1
          _state.topic = 2
      </response>
    </interact>


    <interact keywords="yes" topic="2">
      <response>
        <!--n1: 1 = yes, 2 = yes, 3 = thais, 4 = venore-->
        <action name="script">
          local pos = 0
          if(_state.n1 == 1) then
            pos = {x=99, y=235, z=7}
          else
            selfSay("My hearing is bad, what did you say?!")
            return
          end

          selfSay("Here we go!")
          doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)

          if(doTeleportThing(cid, pos) == 0) then
            doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
          end

        </action>
        <action name="idle" value="1"/>
      </response>
    </interact>

    <interact keywords="bye" focus="0">
      <keywords>farewell</keywords>
      <response text="Good bye. Recommend us, if you were satisfied with our service."/>
    </interact>

    <!--
    If the event onBusy exists, the npc will make a queue like Tibia, if the event is removed
    the npc will be able to talk to all customers at the same time without problems.
    -->

    <interact event="onBusy">
      <response text="WAIT UNTIL IT IS YOUR TURN!">
        <action name="addqueue" value="|PLAYER|"/>
      </response>
    </interact>

    <!--This event triggers if the player goes to far away from the npc/logout/idle timeout-->
    <interact event="onPlayerLeave" focus="0">
      <response text="What a nice young fellow!"/>
    </interact>

  </interaction>

</npc>

I am currently using the latest version of TFS (cryingdamson 3.4 pl2 i believe it is called) and any help would be very appreciated. :p
 
ok, im still on the same problem, ive read tutorials, and attempted it once again. this time it wont even import into the map editor. can anyone have a look at see whats wrong with this script please? :]

Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Dezeul" script="Data/npc/scripts/Dezeul.lua" walkinterval="2000" floorchange="0">
	<health="150" max="150"/>
	<look type="150" head="78" body="68" legs="39" feet="76"  addons="0" corpse="2212"/>
	<parameters>
        <parameter key="message_greet" value="Hello, |PLAYERNAME|... What brings you here?"/>
        <parameter key="message_farewell" value="Good bye, |PLAYERNAME|."/>
		<parameter key="module_keywords" value="1" />
		<parameter key="keywords" value="isles of solis;temple;training;king raidas;arcadia;" />
		<parameter key="keyword_reply1" value="This is the peaceful Isle of Solis, right now you are situated at the Temple. There is a small village based here for training purposes, under the order of King Raidas of Arcadia." />
		<parameter key="keyword_reply2" value="This is the Temple of Solis, if you  are brought to your death on your journey you will be reborn here!" />
		<parameter key="keyword_reply3" value="Once you have advanced to Level 8 you will have completed your training here, you will then be able to take the boat at the Docks to the South to the main continent of Arcadia. On your way you will come to the Island of Elmos you will have to choose your Vocation there!" />
		<parameter key="keyword_reply4" value="King Raidas is the Ruler of the continent of Arcadia, since he took the throne after his fathers mysterious death there has been a lot of suspicious activities and rumours." />
		<parameter key="keyword_reply5" value="Arcadia is the main continent of  [Server Name]." />
	</parameters>
</npc>

here is the .LUA for the npc

Code:
--BOAT
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
keywordHandler:addKeyword({'destination'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can take you to  For just a small fee.'})
npcHandler:addModule(FocusModule:new())
 
Back
Top