• 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 Script dont work

Hitsugaya

New Member
Joined
Mar 28, 2008
Messages
90
Reaction score
0
Location
Poland, Łódź, RTK
Hello :) I need help with this script.

Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

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
    end

    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid


    if msgcontains(msg, 'mission') then
	if getPlayerStorageValue(cid, 30045) == 1 then
		npcHandler:say('I lost my baby seal dool in my home, can you help me the found dool?', cid)
		talkState[talkUser] = 1
         elseif getPlayerStorageValue(cid, 30046) == 2 then
                npcHandler:say('Own. you have a baby seal from me?', cid)
                talkState[talkUser] = 2
        elseif getPlayerStorageValue(cid, 30046) == 3 then
                npcHandler:say('Sorry...but you already have complete my service. Good Bye', cid)
                talkState[talkUser] = 3
        end
        
    elseif talkState[talkUser] == 1 then
        if msgcontains(msg, 'yes') then
                npcHandler:say('Great. you have acess to enter in my home, report your mission afterwards..', cid)
                setPlayerStorageValue(cid,30045,1)
		        local chave = doCreateItemEx(2092, 1)
		        doSetItemActionId(chave, 4849)
		        doPlayerAddItemEx(cid, chave, 1)
                talkState[talkUser] = 2
                else
                selfSay('You already have the service. Come back have them...', cid)
        end

    elseif talkState[talkUser] == 2 then
        if msgcontains(msg, 'yes') then
                npcHandler:say('Thank you! now you have acess to enter in my Training Room.', cid)
	            if doPlayerRemoveItem(cid,7183,1) == TRUE then
                setPlayerStorageValue(cid,30046,2)
                setPlayerStorageValue(cid,60034,1)
                talkState[talkUser] = 3
                else
                npcHandler:say('Sorry...but you dont have item. Come back have them', cid)
            end
            end
            end
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Code:
19:44 Anica [452]: hi
19:44 Dufi: Welcome, Anica! Say trade and I can help you.
19:44 Anica [452]: mission
19:44 Dufi: I lost my baby seal dool in my home, can you help me the found dool?
19:44 Anica [452]: yes
19:44 Dufi: Great. you have acess to enter in my home, report your mission afterwards..

He give my key with ActionID 4849. I give ActionID 4849 door Itemid 1255 and.. The key does not match.
ok. I make seal.

Code:
19:51 Anica [452]: hi
19:51 Dufi: Welcome, Anica! Say trade and I can help you.
19:51 Anica [452]: yes
19:51 Dufi: Thank you! now you have acess to enter in my Training Room.
19:51 Dufi: Sorry...but you dont have item. Come back have them

:confused::confused: Please help with this script :(

PS. Sorry for my english.
 
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local Topic = {}

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 greetCallback(cid)
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
	Topic[talkUser] = 0
	return true
end

function creatureSayCallback(cid, type, msg)
	if(not npcHandler:isFocused(cid)) then
		return false
	end
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
	if msgcontains(msg, "mission") or msgcontains(msg, "quest") then
		local str = getPlayerStorageValue(cid, 30045)
		npcHandler:say((str < 1 and "I lost my baby seal doll in my home, can you help me the find doll?") or (str == 1 and "Have you found my baby seal doll?") or (str == 2 and "You have already completed your task."), cid)
		Topic[talkUser] = str < 2 and str or 0
	elseif Topic[talkUser] == 1 then
		if msgcontains(msg, "yes") then
			npcHandler:say("Great, you can enter my home now. Report to me about your {mission} afterwards.", cid)
			setPlayerStorageValue(cid,30045,1)
			local chave = doCreateItemEx(2092, 1)
			doSetItemActionId(chave, 4849)
			doPlayerAddItemEx(cid, chave, 1)
		else
			selfSay("Alright, I'll be here in case you change your mind.", cid)
		end
		Topic[talkUser] = 0
	elseif Topic[talkUser] == 2 then
		if msgcontains(msg, "yes") then
			if doPlayerRemoveItem(cid,7183,1) == TRUE then
				npcHandler:say("Thank you! You are now allowed to enter the Training Room.", cid)
				setPlayerStorageValue(cid,30045,2)
				setPlayerStorageValue(cid,60034,1)
			else
				npcHandler:say("No, you don't have it.", cid)
			end
		else
			npcHandler:say("Then go and look for it!", cid)
		end
		Topic[talkUser] = 0
	end
	return true
end

npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Last edited:
I write hi and :

Code:
[11/11/2009 14:25:03] Lua Script Error: [Npc interface] 
[11/11/2009 14:25:03] data/npc/scripts/postmanquest.lua:onCreatureSay

[11/11/2009 14:25:03] data/npc/scripts/postmanquest.lua:13: table index is nil
[11/11/2009 14:25:03] stack traceback:
[11/11/2009 14:25:03] 	data/npc/scripts/postmanquest.lua:13: in function 'callback'
[11/11/2009 14:25:03] 	data/npc/lib/npcsystem/npchandler.lua:333: in function 'greet'
[11/11/2009 14:25:03] 	data/npc/lib/npcsystem/npchandler.lua:499: in function 'onGreet'
[11/11/2009 14:25:03] 	data/npc/lib/npcsystem/modules.lua:224: in function 'callback'
[11/11/2009 14:25:03] 	data/npc/lib/npcsystem/keywordhandler.lua:40: in function 'processMessage'
[11/11/2009 14:25:03] 	data/npc/lib/npcsystem/keywordhandler.lua:168: in function 'processNodeMessage'
[11/11/2009 14:25:03] 	data/npc/lib/npcsystem/keywordhandler.lua:122: in function 'processMessage'
[11/11/2009 14:25:03] 	data/npc/lib/npcsystem/npchandler.lua:380: in function 'onCreatureSay'
[11/11/2009 14:25:03] 	data/npc/scripts/postmanquest.lua:9: in function <data/npc/scripts/postmanquest.lua:9>


PS. TFS 3.5 pl1
 
I write hi and :

Code:
[11/11/2009 14:25:03] Lua Script Error: [Npc interface] 
[11/11/2009 14:25:03] data/npc/scripts/postmanquest.lua:onCreatureSay

[11/11/2009 14:25:03] data/npc/scripts/postmanquest.lua:13: table index is nil
[11/11/2009 14:25:03] stack traceback:
[11/11/2009 14:25:03] 	data/npc/scripts/postmanquest.lua:13: in function 'callback'
[11/11/2009 14:25:03] 	data/npc/lib/npcsystem/npchandler.lua:333: in function 'greet'
[11/11/2009 14:25:03] 	data/npc/lib/npcsystem/npchandler.lua:499: in function 'onGreet'
[11/11/2009 14:25:03] 	data/npc/lib/npcsystem/modules.lua:224: in function 'callback'
[11/11/2009 14:25:03] 	data/npc/lib/npcsystem/keywordhandler.lua:40: in function 'processMessage'
[11/11/2009 14:25:03] 	data/npc/lib/npcsystem/keywordhandler.lua:168: in function 'processNodeMessage'
[11/11/2009 14:25:03] 	data/npc/lib/npcsystem/keywordhandler.lua:122: in function 'processMessage'
[11/11/2009 14:25:03] 	data/npc/lib/npcsystem/npchandler.lua:380: in function 'onCreatureSay'
[11/11/2009 14:25:03] 	data/npc/scripts/postmanquest.lua:9: in function <data/npc/scripts/postmanquest.lua:9>


PS. TFS 3.5 pl1
whops xd fixed, copy again
 
Code:
17:19 Anica [452]: mission
17:19 Dufi: Have you found my baby seal doll?
17:19 Anica [452]: yes
17:19 Dufi: Great, you can enter my home now. Report to me about your mission afterwards.

I back with seal and

Code:
17:20 Dufi: Welcome, Anica! Say trade and I can help you.
17:20 Anica [452]: mission
17:20 Dufi: Have you found my baby seal doll?

:(
 
Code:
17:19 Anica [452]: mission
17:19 Dufi: Have you found my baby seal doll?
17:19 Anica [452]: yes
17:19 Dufi: Great, you can enter my home now. Report to me about your mission afterwards.

I back with seal and

Code:
17:20 Dufi: Welcome, Anica! Say trade and I can help you.
17:20 Anica [452]: mission
17:20 Dufi: Have you found my baby seal doll?

:(
Try it with a new character/delete the old character's quest storage.
 
Code:
20:15 Dufi: Welcome, Priest! Say trade and I can help you.
20:15 Priest [209]: quest
20:15 Dufi: I lost my baby seal doll in my home, can you help me the find doll?
20:15 Priest [209]: yes

i write hi quest yes and 0 reaction ;/
 
Back
Top