Postado Fevereiro 10, 2016 9 anos Script 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 playerHaveItems(cid, itemid) local items = type(itemid) == "table" and itemid or {itemid} for i = 1, #items do if getPlayerItemCount(cid, items) <= 0 thenreturn falseendendreturn trueend function doPlayerRemoveItems(cid, itemid, count)local items = type(itemid) == "table" and itemid or {itemid}for i = 1, #items dodoPlayerRemoveItem(cid, items, count ~= nil and count or 1)endreturn nilend function creatureSayCallback(cid, type, msg) if(not npcHandler:isFocused(cid)) thenreturn falseend if msgcontains(msg, "trocar") thenif playerHaveItems(cid, {2134, 2174, 2159}) thendoPlayerRemoveItems(cid, {2134, 2174, 2159}, 300)doPlayerAddItem(cid, 2090, 1)elseselfSay("Você Não tem os itens necessarios.")endendreturn true endnpcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)npcHandler:addModule(FocusModule:new()) Agora vá em Data/Npc/Nomedonpc.xml <?xml version="1.0" encoding="UTF-8"?><npc name="Fernando" script="trocaitems.lua" walkinterval="2000" floorchange="0"><health now="100" max="100"/><look type="169" head="114" body="86" legs="114" feet="0" addons="2"/><parameters><parameter key="message_greet" value="Ola, diga {trocar} para trocar 3 items por 1."/></parameters></npc> Ta Dando esse erro [10/02/2016 12:58:23] [Error - LuaScriptInterface::loadFile] data/npc/scripts/trocaitems.lua:45: 'end' expected (to close 'function' at line 29) near 'endnpcHandler'[10/02/2016 12:58:23] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/trocaitems.lua[10/02/2016 12:58:23] data/npc/scripts/trocaitems.lua:45: 'end' expected (to close 'function' at line 29) near 'endnpcHandler'
Postado Fevereiro 10, 2016 9 anos 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 playerHaveItems(cid, itemid) local items = type(itemid) == "table" and itemid or {itemid} for i = 1, #items do if getPlayerItemCount(cid, items) <= 0 then return false end end return true end function doPlayerRemoveItems(cid, itemid, count) local items = type(itemid) == "table" and itemid or {itemid} for i = 1, #items do doPlayerRemoveItem(cid, items, count ~= nil and count or 1) end return nil end function creatureSayCallback(cid, type, msg) if(not npcHandler:isFocused(cid)) then return false end if msgcontains(msg, "trocar") then if playerHaveItems(cid, {2134, 2174, 2159}) then doPlayerRemoveItems(cid, {2134, 2174, 2159}, 300) doPlayerAddItem(cid, 2090, 1) else selfSay("Você Não tem os itens necessarios.") end end end return true endnpcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) testa ai n é certeza Editado Fevereiro 10, 2016 9 anos por Valakinhas (veja o histórico de edições)
Postado Fevereiro 10, 2016 9 anos Autor [10/02/2016 13:23:47] [Error - LuaScriptInterface::loadFile] data/npc/scripts/trocaitems.lua:40: '<eof>' expected near 'endnpcHandler' [10/02/2016 13:23:47] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/trocaitems.lua [10/02/2016 13:23:47] data/npc/scripts/trocaitems.lua:40: '<eof>' expected near 'endnpcHandler'
Postado Fevereiro 10, 2016 9 anos 14 minutos atrás, Daniel augusto silva disse: [10/02/2016 13:23:47] [Error - LuaScriptInterface::loadFile] data/npc/scripts/trocaitems.lua:40: '<eof>' expected near 'endnpcHandler' [10/02/2016 13:23:47] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/trocaitems.lua [10/02/2016 13:23:47] data/npc/scripts/trocaitems.lua:40: '<eof>' expected near 'endnpcHandler' 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 playerHaveItems(cid, itemid) local items = type(itemid) == "table" and itemid or {itemid} for i = 1, #items do if getPlayerItemCount(cid, items) <= 0 then return false end end return true end function doPlayerRemoveItems(cid, itemid, count) local items = type(itemid) == "table" and itemid or {itemid} for i = 1, #items do doPlayerRemoveItem(cid, items, count ~= nil and count or 1) end return nil end function creatureSayCallback(cid, type, msg) if(not npcHandler:isFocused(cid)) then return false end if msgcontains(msg, "trocar") then if playerHaveItems(cid, {2134, 2174, 2159}) then doPlayerRemoveItems(cid, {2134, 2174, 2159}, 300) doPlayerAddItem(cid, 2090, 1) else selfSay("Você Não tem os itens necessarios.") end end return true end endnpcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
Postado Fevereiro 10, 2016 9 anos Autor [10/02/2016 13:56:24] [Error - Npc interface] [10/02/2016 13:56:24] data/npc/scripts/trocaitems.lua [10/02/2016 13:56:24] Description: [10/02/2016 13:56:24] data/npc/scripts/trocaitems.lua:39: attempt to index global 'endnpcHandler' (a nil value) [10/02/2016 13:56:24] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/trocaitems.lua
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.