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

Hammel

Mapper
Joined
Dec 14, 2009
Messages
37
Reaction score
0
Hey, someone can help me with this scripit?

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
 
function creatureSayCallback(cid, type, msg)
    -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
    if (not npcHandler:isFocused(cid)) then
        return false
    end
         if msgcontains(msg, 'mission') then
                npcHandler:say('Go kill {6666 demons} with Grizzly Adams and come back to me after that', cid)
                talk_state = 1
                               end 
        elseif msgcontains(msg, 'mission') and talk_state == 2 then
                npcHandler:say('Did you kill the demons?', cid)
                talk_state = 0
        elseif msgcontains(msg, '') and talk_state == 2 then
                npcHandler:say('Did you kill the demons?', cid)
                talk_state = 0
        elseif msgcontains(msg, 'yes') and talk_state == 3 then
            if getPlayerStorageValue(cid, 65535) == 1 then
                npcHandler:say('Excelent! Now talk about hallowed axe', cid)
                doPlayerSetStorageValue(cid, 65536,1)
                talk_state = 0
                                end
            else
                npcHandler:say('Go defeat the demons first.', cid)
                talk_state = 0
            end
       if msgcontains(msg, 'hallowed axe') then
                npcHandler:say('Do you want to buy a Hallowed Axe from me?', cid)
                talk_state = 2
        elseif msgcontains(msg, 'yes') and talk_state == 1 then
                local price = 1000
            if getPlayerItemCount(cid, 2386) >= 1 and getPlayerMoney(cid) >= price then 
            if getPlayerStorageValue(cid, 65536) == 1 then 
                if doPlayerRemoveMoney(cid, price) == true then
                    npcHandler:say('Here you are. You can now defeat the demon oak with this axe.', cid)
                    doPlayerRemoveItem(cid, 2386, 1)
                    doPlayerAddItem(cid, 8293, 1)
                    talk_state = 0
                end
            else
                npcHandler:say('I need an axe and ' .. price .. ' gold coins to make you a {hallowed axe}.', cid)
                talk_state = 0
            end
        elseif msgcontains(msg, 'demon oak') then
                npcHandler:say('Did you defeat the demon oak?', cid)
                talk_state = 3
        elseif msgcontains(msg, 'yes') and talk_state == 2 then
            if getPlayerStorageValue(cid, 35700) == 1 then
                npcHandler:say('Good job! Go now to the gravestone south of Demon Oak, you might find something useful there!', cid)
                doPlayerSetStorageValue(cid, 35700, 2)
                talk_state = 0
            else
                npcHandler:say('Go defeat the demon oak first.', cid)
                talk_state = 0
            end
		elseif msgcontains(msg, 'hugo') then
        selfSay('Ah, the bane of the Plains of Havoc, the hidden beast, the unbeatable foe. I live here for years and I am sure it\'s only a {myth}.', cid)
        talk_state = 4
		elseif msgcontains(msg, 'myth') and talk_state == 3 then
            selfSay('There are many tales about the fearsome Hugo. It\'s said it is an abomination, accidentally created by {Yenny the Gentle}. It\'s halve demon, halve something else and people say it\'s still alive after dozens of years.', cid)
                talk_state = 5
		elseif msgcontains(msg, 'yenny the gentle') and talk_state == 4 then
            selfSay('Yenny, known as the Gentle, was one of most powerfull magicwielders in ancient times and known throughout the world for her mercy and kindness.', cid)
					setPlayerStorageValue(cid,6664,1)
					talk_state = 6
------------------------------------------------ confirm no ------------------------------------------------
        elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 3) then
            npcHandler:say('Ok thanks.', cid)
            talk_state = 0
        end
    -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
    return true
end
 
 
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

It doesn't work, what's the erro? Please someone can fix it?
 
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, "hallowed axe") then
		selfSay("Do you want to buy a Hallowed Axe for " .. HALLOWEDAXE_PRICE .. " gold coins?", cid)
		talkState[talkUser] = 1
	elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then
		if getPlayerItemCount(cid, 2386) >= 1 and getPlayerMoney(cid) >= HALLOWEDAXE_PRICE then
			if doPlayerRemoveMoney(cid, HALLOWEDAXE_PRICE) then
				selfSay("Here you are. You can now defeat the demon oak with this axe.", cid)
				doPlayerRemoveItem(cid, 2386, 1)
				doPlayerAddItem(cid, 8293, 1)
				talkState[talkUser] = 0
			end
		else
			selfSay("I need an axe and " .. HALLOWEDAXE_PRICE.. " gold coins to make you a {hallowed axe}.", cid)
			talkState[talkUser] = 0
		end
	elseif msgcontains(msg, "demon oak") then
		selfSay("Did you defeat the demon oak?", cid)
		talkState[talkUser] = 2
	elseif msgcontains(msg, "yes") and talkState[talkUser] == 2 then
		if getCreatureStorage(cid, storages.done) == 1 then
			selfSay("Good job!", cid)
			doCreatureSetStorage(cid, storages.done, 2)
			talkState[talkUser] = 0
		else
			selfSay("Go defeat the demon oak first.", cid)
			talkState[talkUser] = 0
		end
	elseif msgcontains(msg, "no") and (talkState[talkUser] >= 1 and talkState[talkUser] <= 3) then
		selfSay("Ok thanks.", cid)
		talkState[talkUser] = 0
	end
	return true
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Last edited:
Thank you, but I don't want this script. The script that I want is one who get player storagevalue of killing in the name of... quest, when he kills 6666 demons and after that the npc give the axe to go to demon oak.

I don't know how it can work.
 
Back
Top