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

Glidarn

Member
Joined
May 9, 2009
Messages
970
Reaction score
16
Location
Åkersberga, Sweden
This is my problem... i don't know what causing it, these errors just poppin' up
ImageShack® - Online Photo and Video Hosting

LUA:
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 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 from me?', cid)
                talkState[talkUser] = 1
        elseif msgcontains(msg, 'yes') and talkState[talkUser] == 1 then
                local price = 1000
                if getPlayerItemCount(cid, 2386) >= 1 and getPlayerMoney(cid) >= price then
                        if doPlayerRemoveMoney(cid, 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 ' .. 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 getPlayerStorageValue(cid, 35700) == 1 then
                        selfSay('Good job!', cid)
                        doPlayerSetStorageValue(cid, 35700, 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())
 
Try:
LUA:
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 creatureSayCallback(cid, type, msg)
 
        if(not npcHandler:isFocused(cid)) then
                return false
        end
        local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
		if not(talkState[talkUser]) then
			talkState[talkUser] = 0
		end
        if msgcontains(msg, 'hallowed axe') then
                selfSay('Do you want to buy a Hallowed Axe from me?', cid)
                talkState[talkUser] = 1
        elseif msgcontains(msg, 'yes') and talkState[talkUser] == 1 then
                local price = 1000
                if getPlayerItemCount(cid, 2386) >= 1 and getPlayerMoney(cid) >= price then
                        if doPlayerRemoveMoney(cid, 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 ' .. 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 getPlayerStorageValue(cid, 35700) == 1 then
                        selfSay('Good job!', cid)
                        doPlayerSetStorageValue(cid, 35700, 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())
 
Code:
function onSay(cid, words, param, channel)
	local func = doCreateMonster
	if(words:sub(2, 2) == "n") then
		func = doCreateNpc
	end

	local pid = cid
	local t = string.explode(param, ",")
	if(t[2]) then
		pid = getPlayerByNameWildcard(t[2])
		if(not pid) then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. t[2] .. " not found.")
			return true
		end
	end

	local position = getCreaturePosition(pid)
	local effect = CONST_ME_MAGIC_RED
	local ret = func(t[1], position, [B][COLOR="red"]false[/COLOR][/B])
	if(tonumber(ret) == nil) then
		effect = CONST_ME_POFF
		doPlayerSendDefaultCancel(cid, (ret == false and RETURNVALUE_NOTPOSSIBLE or RETURNVALUE_NOTENOUGHROOM))
	end

	doSendMagicEffect(position, effect)
	return true
end
The default script shouldn't show any errors.
 
Back
Top