• 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 What is error?

Natan Beckman

Well-Known Member
Joined
Aug 1, 2010
Messages
548
Reaction score
54
Location
Teresina-PI/Br
What is error?

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 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, "warrior helmet") then
		if getPlayerItemCount(cid, 2475) >= 4 then
			npcHandler:say("Are you sure you would like to trade {four} or your helmet's for a {flas of warrior's sweat}?", cid)
			talkState[talkUser] = 1
		else
			npcHandler:say("Sorry, you do not have {eight} Warrior Helmets.", cid)
			talkState[talkUser] = 0
		end
	elseif msgcontains(msg, 'yes') and talkState[talkUser] == 1 then
		if getPlayerItemCount(cid, 2475) >= 4 then
			doPlayerRemoveItem(cid, 2475, 4)
			npcHandler:say("Here you are.", cid)
			doPlayerAddItem(cid, 5885, 1)
			talkState[talkUser] = 0
		else
			npcHandler:say("Sorry, you do not have {eight} Warrior Helmets.", cid)
			talkState[talkUser] = 0
		end
	elseif msgcontains(msg, "no") then
		npcHandler:say("Then not.", cid)
		talkState[talkUser] = 0
	end
	
	return true
end

        elseif msgcontains(msg, "enchanted chicken wings") then
		if getPlayerItemCount(cid, 2195) >= 5 then
			npcHandler:say("Are you sure you would like to trade {five} or your helmet's for a {enchanted chicken wings}?", cid)
			talkState[talkUser] = 2
		else
			npcHandler:say("Sorry, you do not have {five} Boots of Haste.", cid)
			talkState[talkUser] = 0
		end
	elseif msgcontains(msg, 'yes') and talkState[talkUser] == 2 then
		if getPlayerItemCount(cid, 2195) >= 5 then
			doPlayerRemoveItem(cid, 2195, 5)
			npcHandler:say("Here you are.", cid)
			doPlayerAddItem(cid, 5891, 1)
			talkState[talkUser] = 0
		else
			npcHandler:say("Sorry, you do not have {five} Boots of Haste.", cid)
			talkState[talkUser] = 0
		end
	elseif msgcontains(msg, "no") then
		npcHandler:say("Then not.", cid)
		talkState[talkUser] = 0
	end
	
	return true
end
	
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Sorry Ruda:

[1:29:48.343] [Error - LuaInterface::loadFile] data/npc/scripts/Haroun.lua:45: '<eof>' expected near 'elseif'
[1:29:48.359] [Warning - NpcEvents::NpcEvents] Cannot load script: data/npc/scripts/Haroun.lua
[1:29:48.359] data/npc/scripts/Haroun.lua:45: '<eof>' expected near 'elseif'
[1:29:48.359] [Error - NpcScript Interface]
[1:29:48.359] (Unknown script file)
[1:29:48.359] Description:
[1:29:48.359] attempt to call a nil value
[1:29:48.359] stack traceback:
[1:29:48.500] [Error - LuaInterface::loadFile] data/npc/scripts/Haroun.lua:45: '<eof>' expected near 'elseif'
[1:29:48.546] [Warning - NpcEvents::NpcEvents] Cannot load script: data/npc/scripts/Haroun.lua
[1:29:48.546] data/npc/scripts/Haroun.lua:45: '<eof>' expected near 'elseif'
 
try this

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 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, "warrior helmet") then
		if getPlayerItemCount(cid, 2475) >= 4 then
			npcHandler:say("Are you sure you would like to trade {four} or your helmet's for a {flas of warrior's sweat}?", cid)
			talkState[talkUser] = 1
		else
			npcHandler:say("Sorry, you do not have {eight} Warrior Helmets.", cid)
			talkState[talkUser] = 0
		end
	elseif msgcontains(msg, 'yes') and talkState[talkUser] == 1 then
		if getPlayerItemCount(cid, 2475) >= 4 then
			doPlayerRemoveItem(cid, 2475, 4)
			npcHandler:say("Here you are.", cid)
			doPlayerAddItem(cid, 5885, 1)
			talkState[talkUser] = 0
		else
			npcHandler:say("Sorry, you do not have {eight} Warrior Helmets.", cid)
			talkState[talkUser] = 0
		end
	elseif msgcontains(msg, "no") then
		npcHandler:say("Then not.", cid)
		talkState[talkUser] = 0
    elseif msgcontains(msg, "enchanted chicken wings") then
		if getPlayerItemCount(cid, 2195) >= 5 then
			npcHandler:say("Are you sure you would like to trade {five} or your helmet's for a {enchanted chicken wings}?", cid)
			talkState[talkUser] = 2
		else
			npcHandler:say("Sorry, you do not have {five} Boots of Haste.", cid)
			talkState[talkUser] = 0
		end
	elseif msgcontains(msg, 'yes') and talkState[talkUser] == 2 then
		if getPlayerItemCount(cid, 2195) >= 5 then
			doPlayerRemoveItem(cid, 2195, 5)
			npcHandler:say("Here you are.", cid)
			doPlayerAddItem(cid, 5891, 1)
			talkState[talkUser] = 0
		else
			npcHandler:say("Sorry, you do not have {five} Boots of Haste.", cid)
			talkState[talkUser] = 0
		end
	elseif msgcontains(msg, "no") then
		npcHandler:say("Then not.", cid)
		talkState[talkUser] = 0
	end
 
	return true
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Back
Top