- Joined
- Aug 6, 2007
- Messages
- 1,767
- Reaction score
- 36
Hello,
Today we are starting with an new Tutorial, I will teach YOU how to creat an Boat Npc and i will explain what eatch function does.
Message for the Mods: Do not add Code Tags i have an good reason for it
====================Start=================
The first line is alwais the Npc information sutch as Name,access,flourchange etc..
We will first start with an .XML file
<npc name="Captain Steven" --The name of the Npc
script="data/npc/scripts/travel.lua" --Where is the .Lua file located
autowalk="1" ------Do u allow the npc to walk? 1= yes 0=no
floorchange="0" ----Do u allow the npc to use stairs? 1=Yes 0=No
access="5" ---Do u allow the npc to use commands that u added in the script? If no Lower the access but there will be an change that players are able to kill the npc, The npc wont respawn only with an restart.
level="1" ---- You can set the lvl of the npc for example if it's an guard
maglevel="1"> ---- You can set the lvl of the npc for example if it's an guard
Line 2 and 3 in the .xml file
<health now="150" max="150"/> ---The Hp of the npc ofcourse
<look type="133" head="20" body="120" legs="75" feet="13" corpse="2212"/> --How the npc should look like
Npc parameters the parameters are for the responce of the npc
<parameters>
<parameter key="module_travel" value="1" /> ----What for function is it, since we are maiking an travel npc it will be module_travel
<parameter key="travel_destinations" ---Dont edit this line
value="derelin,1294,429,6,119;farda,865,251,6,123" /> ----The place where the player should travel. this is an example how to make it work.
derelin,1294,429,6,119
Cityname,X,Y,Z,Price to travel.
If you want to add more city's simply add ";" example
derelin,1294,429,6,119;farda,865,251,6,123
<parameter key="module_keywords" value="1" /> ---Dont edit this line
<parameter key="keywords" value="job;name;offer" /> ---This is on what commands the npc reacts, if you want to add more just add ; just dont forget to add lines with the number
<parameter key="keyword_reply1" value="This if for job" />
<parameter key="keyword_reply2" value="this is for name" />
<parameter key="keyword_reply3" value="this is for offer" />
</parameters>
</npc>
the .xml should look somting like this
The .Lua file
I cant say mutch about this script since it's an basic script, This script redirects lines to global.lua so the npc will respond when u say/hi/bye/ and more things
I made this Tutorial as an request i know it's not the best but it will explain a bit, Ofcourse i will make more but the would be complex so keep learning =)
Yours,
Mokerhamer
Today we are starting with an new Tutorial, I will teach YOU how to creat an Boat Npc and i will explain what eatch function does.
Message for the Mods: Do not add Code Tags i have an good reason for it
====================Start=================
The first line is alwais the Npc information sutch as Name,access,flourchange etc..
We will first start with an .XML file
<npc name="Captain Steven" --The name of the Npc
script="data/npc/scripts/travel.lua" --Where is the .Lua file located
autowalk="1" ------Do u allow the npc to walk? 1= yes 0=no
floorchange="0" ----Do u allow the npc to use stairs? 1=Yes 0=No
access="5" ---Do u allow the npc to use commands that u added in the script? If no Lower the access but there will be an change that players are able to kill the npc, The npc wont respawn only with an restart.
level="1" ---- You can set the lvl of the npc for example if it's an guard
maglevel="1"> ---- You can set the lvl of the npc for example if it's an guard
Line 2 and 3 in the .xml file
<health now="150" max="150"/> ---The Hp of the npc ofcourse
<look type="133" head="20" body="120" legs="75" feet="13" corpse="2212"/> --How the npc should look like
Npc parameters the parameters are for the responce of the npc
<parameters>
<parameter key="module_travel" value="1" /> ----What for function is it, since we are maiking an travel npc it will be module_travel
<parameter key="travel_destinations" ---Dont edit this line
value="derelin,1294,429,6,119;farda,865,251,6,123" /> ----The place where the player should travel. this is an example how to make it work.
derelin,1294,429,6,119
Cityname,X,Y,Z,Price to travel.
If you want to add more city's simply add ";" example
derelin,1294,429,6,119;farda,865,251,6,123
<parameter key="module_keywords" value="1" /> ---Dont edit this line
<parameter key="keywords" value="job;name;offer" /> ---This is on what commands the npc reacts, if you want to add more just add ; just dont forget to add lines with the number
<parameter key="keyword_reply1" value="This if for job" />
<parameter key="keyword_reply2" value="this is for name" />
<parameter key="keyword_reply3" value="this is for offer" />
</parameters>
</npc>
the .xml should look somting like this
Code:
<npc name="Captain Steven" script="data/npc/scripts/travel.lua" autowalk="1" floorchange="0" access="5" level="1" maglevel="1">
<health now="150" max="150"/>
<look type="133" head="20" body="120" legs="75" feet="13" corpse="2212"/>
<parameters>
<parameter key="module_travel" value="1" />
<parameter key="travel_destinations" value="derelin,1294,429,6,119;farda,865,251,6,123;taqinata,868,690,6,134" />
<parameter key="module_keywords" value="1" />
<parameter key="keywords" value="job;name;offer" />
<parameter key="keyword_reply1" value="this is for job" />
<parameter key="keyword_reply2" value="this is for offer name" />
<parameter key="keyword_reply3" value="this is for offer" />
</parameters>
</npc>
The .Lua file
I cant say mutch about this script since it's an basic script, This script redirects lines to global.lua so the npc will respond when u say/hi/bye/ and more things
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
-- Makes sure the npc reacts when you say hi, bye etc.
npcHandler:addModule(FocusModule:new())
I made this Tutorial as an request i know it's not the best but it will explain a bit, Ofcourse i will make more but the would be complex so keep learning =)
Yours,
Mokerhamer