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

[solved] Little help with this npc..

brendan2

Sensation black
Joined
Feb 19, 2009
Messages
507
Reaction score
1
Ok This npc does not talk back when i say mining or help or anything whats wrong and can someone fix please

Script
PHP:
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 

function creatureSayCallback(cid, type, msg) 
    if(npcHandler.focus ~= cid) then 
        return false 
    end 
     
    if msgcontains(msg,'spells') or msgcontains(msg,'help') then 
            selfSay('Hello i can teach you mining for free. If you would like to learn mining please say mining') 

    elseif msgcontains(msg,'mining') then 
            setPlayerStorageValue(cid,40001,1) 
            setPlayerStorageValue(cid,40002,1) 
            setPlayerStorageValue(cid,40003,1) 
            setPlayerStorageValue(cid,40004,1) 
            npcHandler:say('Here you go!') 
    end 
end 
  
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) 
npcHandler:addModule(FocusModule:new())

Npc
PHP:
<?xml version="1.0" encoding="UTF-8"?> 
<npc name="Mining dwarf" script="data/npc/scripts/mining.lua" autowalk="1" floorchange="0"> 
<health now="100" max="100"/> 
<look type="69"/> 
<parameters> 
    if msgcontains(msg,'spells') or msgcontains(msg,'help') then 
            selfSay('Hello i can teach you mining for free. If you would like to learn mining please say mining') 

    elseif msgcontains(msg,'mining') then 
            setPlayerStorageValue(cid,40001,1) 
            setPlayerStorageValue(cid,40002,1) 
            setPlayerStorageValue(cid,40003,1) 
            setPlayerStorageValue(cid,40004,1) 
            npcHandler:say('Here you go!') 
</parameters> 
</npc>

when I say hi he says

09:21 Mining dwarf: Welcome, Killzon Thirtytwo! I have been expecting you.

Then he does not say anything else or do anything else.
I want him to give me mining skill:( please can someone help.
Tfs 0.3.6
 
Last edited:
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

function creatureSayCallback(cid, type, msg)
	if(not npcHandler:isFocused(cid)) then
		return false
	elseif msgcontains(msg, "spell") or msgcontains(msg, "help") then
		npcHandler:say("Hello, I can teach you mining for free. If you would like to learn mining please say mining.", cid)
	elseif msgcontains(msg,"mining") then
		setPlayerStorageValue(cid,40001,1)
		setPlayerStorageValue(cid,40002,1)
		setPlayerStorageValue(cid,40003,1)
		setPlayerStorageValue(cid,40004,1)
		npcHandler:say("Here you go!", cid)
	end
	return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Code:
<npc name="Mining Dwarf" script="data/npc/scripts/mining.lua" walkinterval="2000"> 
<look type="69"/>
</npc>
 
I get this error

[02/02/2010 09:33:25] [Error - LuaScriptInterface::loadFile] data/npc/scripts/mining.lua:26: unexpected symbol near ')'
[02/02/2010 09:33:25] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/mining.lua
[02/02/2010 09:33:25] data/npc/scripts/mining.lua:26: unexpected symbol near ')'
 
Back
Top