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

Lua NPC script help

Jfrye

Mapper, trying to learn scripting
Joined
Jan 8, 2009
Messages
366
Solutions
5
Reaction score
86
Location
Mexico Missouri
I am trying to make it to where the players have to learn the spells from NPCs.

Using the info from this thread https://otland.net/threads/release-spell-npcs.2237/

I added it to an existing NPC file, and now I get an error saying "[Warning-NpcScript::NpcScript]Can not load script: data/npc/scripts/Gregor.lua cannot open data/npc/scripts/data/npc/scripts/Gregor.lua: No such file or directory." <I know that it has too many data/npc/scripts, but this is exactly how it is coming from the console.

Here is Gregor.xml
Code:
<npc name="Gregor" script="data/npc/scripts/Gregor.lua" walkinterval="2000" floorchange="0">
<health now="100" max="100"/>
<look type="134" head="57" body="59" legs="40" feet="76" corpse="2212"/>
<parameters>
<parameter key="message_greet" value="Hello |PLAYERNAME|, For which level would you like to learn spells 8, 9, 10, 13, 14, 15, 20, 30, 33, 35 or 70?" />
<parameter key="module_keywords" value="1" />
<parameter key="keywords" value="70;35;33;30;20;15;14;13;10;9;8;spells" />

<parameter key="keyword_reply1" value="I can teach you, Fierce berserk." />
<parameter key="keyword_reply2" value="I can teach you, Berserk." />
<parameter key="keyword_reply3" value="I can teach you, Groundshaker" />
<parameter key="keyword_reply4" value="I can teach you, wound cleansing." />
<parameter key="keyword_reply5" value="I can teach you, Challenge." />
<parameter key="keyword_reply6" value="I can teach you, Whirlwind throw." />
<parameter key="keyword_reply7" value="I can teach you, Haste." />
<parameter key="keyword_reply8" value="I can teach you, Great light." />
<parameter key="keyword_reply9" value="I can teach you, Antidote." />
<parameter key="keyword_reply10" value="I can teach you, light healing." />
<parameter key="keyword_reply11" value="I can teach you, light and find person." />
<parameter key="keyword_reply12" value="For which level would you like to learn spells 8, 9, 10 or 13?" />
</parameters>
</npc>

Gregor.lua is here http://pastebin.com/YaYbhSs5
 
Last edited by a moderator:
Post here the content and your TFS version too.

Change for this in xml:
Code:
<npc name="Gregor" script="Gregor.lua" walkinterval="2000" floorchange="0">
 
this was my error
<npc name="Gregor" script="data/npc/scripts/Gregor.lua"

it sholdve said
<npc name="Gregor" script="Gregor.lua"

Now that I fixed that, it says Line 171 'end' expected (to close to 'function' at line 20) near 'elseif'


I am using TFS 1.1. and the scripts are listed above for both lua and xml files
 
You can use my files..

Gregor.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Gregor" script="Gregor.lua" walkinterval="2000" floorchange="0">
    <health now="100" max="100" />
    <look type="131" head="38" body="38" legs="38" feet="38" addons="3" />
</npc>

Gregor.lua
http://pastebin.com/JqS6uix0
 
When I used your Gregor.lua, it says I dont have addSpellKeyword as a function, and something about talkactions/scripts/place_npc.lua

But if I use the script, I posted, it will talk to any vocation, and also says you need a premium to buy spells.
 
That gave all types of errors. The Npc seems to be working with the script I listed, but now no one can buy spells. Any vocation can try to buy spells, but when you say yes, he says "19:05 Gregor: You need a premium account in order to buy light."



19:12 Gregor: For which level would you like to learn spells 8, 9, 10 or 13?
Code:
    elseif msgcontains(msg,'spells') then
        if getPlayerVocation(cid) == 4 or getPlayerVocation(cid) == 8 then
            selfSay('For which level would you like to learn spells, 8, 9, 10, 13, 14, 15, 20, 33, 35 or 70?')
        else
            selfSay('Sorry, I only sell spells to knights.')
        end
        npcHandler.topic[cid] = 0
    end
 
Still having issues with this script. They will only sell Premium spells. Non premium spells cannot be bought. They say you need a premium account to purchase spell.

Gregor.lua
http://pastebin.com/yTB0Habr

Gregor.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Gregor" script="Gregor.lua" walkinterval="2000" floorchange="0">
<health now="100" max="100"/>
<look type="134" head="57" body="59" legs="40" feet="76" corpse="2212"/>
<parameters>
    <parameter key="message_greet" value="Hello |PLAYERNAME|, For which level would you like to learn spells 8, 9, 10, 13, 14, 15, 20, 30, 33, 35 or 90?" />
    <parameter key="module_keywords" value="1" />
    <parameter key="keywords" value="90;35;33;30;20;15;14;13;10;9;8;" />

    <parameter key="keyword_reply1" value="I can teach you, {Fierce Berserk}." />
    <parameter key="keyword_reply2" value="I can teach you, {Berserk}." />
    <parameter key="keyword_reply3" value="I can teach you, {Groundshaker}." />
    <parameter key="keyword_reply4" value="I can teach you, {Wound Cleansing}." />
    <parameter key="keyword_reply5" value="I can teach you, {Challenge}." />
    <parameter key="keyword_reply6" value="I can teach you, {Whirlwind Throw}." />
    <parameter key="keyword_reply7" value="I can teach you, {Haste}." />
    <parameter key="keyword_reply8" value="I can teach you, {Great Light}." />
    <parameter key="keyword_reply9" value="I can teach you, {Antidote}." />
    <parameter key="keyword_reply10" value="I can teach you, {Magic Rope}." />
    <parameter key="keyword_reply11" value="I can teach you, {Light}, {Find Person} and {Wound Cleansing}." />

</parameters>
</npc>
 
Back
Top