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

Npc Bug

jpkulik

New Member
Joined
Mar 15, 2008
Messages
208
Reaction score
2
Hello all!
Im tryin to make and NPC. He needs to buy corpses.
Bug when i open the TFS i receie the following error:
data/npc/lib/npc.lua:9: bad argument #1 to 'find' (string expected, got nil)
[23/03/2008 15:45:23] Warning: [NpcScript::NpcScript] Can not load script. data/npc/scripts/rook_corpses.lua
I dont know why..
There is the 2 scripts. (XML and LUA.)

Billy.xml
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Billy" script="data/npc/scripts/rook_corpses.lua" autowalk="1" floorchange="0">
<health now="100" max="100"/>
<look type="144" head="115" body="2" legs="114" feet="62" addons="1"/>
<parameters>
<parameter key="module_shop" value="1"/>
<parameter key="shop_sellable" value="rat,2813,2;dead rat,2813,2;wolf,2826,5;dead wolf,2826,5;rabbit,2992,2;dead rabbit,2992,2;dead rabbit,2992,2;minotaur leather,5878,12;bear paw,2992,10;spider,5896,3;dead spider,2992,3"/>
</parameters>
</npc>

Rook_corpses.LUA
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

if msgcontains(msg, 'help') or msgcontains(msg, 'offer') or msgcontains(msg, 'help') or msgcontains(msg, 'offer') then
npcHandler:say("Im buying Corpses.")
talkState = 0
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

I hope someone know how to fix that.
Heheh, the idia is:
When players say 'Help' or 'offer', the NPC say: Im buying Corpses.
Tankyou everybody.
Cya!

OBS: Script for TFS
 
Last edited:
Not working
Warning: [NpcScript::NpcScript] Can not load script. data/npc/scripts/rook_corpses.lua
[23/03/2008 22:12:51] data/npc/scripts/rook_corpses.lua:14: 'end' expected (to close 'function' at line 8) near '<eof>'
That is the error now
 
Last edited:
it should be

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

if msgcontains(msg, 'help') or msgcontains(msg, 'offer') or msgcontains(msg, 'help') or msgcontains(msg, 'offer') then
npcHandler:say("Im buying Corpses.")
talkState = 0
end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())



anywais

if u want that the npc buys the items use

Code:
<parameter key="shop_[COLOR="Red"]sell[/COLOR]able" value="rat,2813,2;dead rat,2813,2;wolf,2826,5;dead wolf,2826,5;rabbit,2992,2;dead rabbit,2992,2;dead rabbit,2992,2;minotaur leather,5878,12;bear paw,2992,10;spider,5896,3;dead spider,2992,3"/>

if u want him to sell the items to players use

Code:
<parameter key="shop_[COLOR="Red"]buy[/COLOR]able" value="rat,2813,2;dead rat,2813,2;wolf,2826,5;dead wolf,2826,5;rabbit,2992,2;dead rabbit,2992,2;dead rabbit,2992,2;minotaur leather,5878,12;bear paw,2992,10;spider,5896,3;dead spider,2992,3"/>
 
Last edited:
Hi, i have tryed it again, but i receive another error:
[23/03/2008 22:46:01] Warning: [NpcScript::NpcScript] Can not load script. data/npc/scripts/rook_corpses.lua
[23/03/2008 22:46:01] data/npc/scripts/rook_corpses.lua:14: '<eof>' expected near 'end'
Tankyou!
 
anywais i'v remade it fast the reason it was bugged was that i dident pay enough intension

.xml file

Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Billy" script="data/npc/scripts/rook_corpses.lua" autowalk="1" floorchange="0">
<health now="100" max="100"/>
<look type="144" head="115" body="2" legs="114" feet="62" addons="1"/>
<parameters>
<parameter key="module_shop" value="1"/>
<parameter key="shop_sellable" value="rat,2813,2;dead rat,2813,2;wolf,2826,5;dead wolf,2826,5;rabbit,2992,2;dead rabbit,2992,2;dead rabbit,2992,2;minotaur leather,5878,12;bear paw,2992,10;spider,5896,3;dead spider,2992,3"/>

<parameter key="module_keywords" value="1" />
		<parameter key="keywords" value="help;offer" />
		<parameter key="keyword_reply1" value="I\'\m buying Corpses." />
</parameters>
</npc>

lua file

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

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
It works perfectlly!
You are a really god scripter.
I aprecciate that.
Tankyou again.
Cya
Congratulations! :)
 
Last edited:
Back
Top