Obsdark
Member
- Joined
- Sep 25, 2011
- Messages
- 213
- Reaction score
- 9
¡¡¡Hey oh!!!
I'm working on a Trading NPC who receive 2 items and some gold and trade them for another item entirely diferent, the problem is i don't know how to make the correct way to call the table, i leave the npc entirely writed here to see if someone can help me with that:
This is the error who appeard in the console:
Do you think you can help me?
What you think can be the problem?
i suspect of this two parts, because in the second one i think i'm not callingthe table properly, but the problem is:
how can i call the items by they name in the table properly?
is that the problem or is another one, and if is that way how to fix it?
¡¡¡Bless you and Cheers up!!!
(Y)(Y)
-Obsdark-
I'm working on a Trading NPC who receive 2 items and some gold and trade them for another item entirely diferent, the problem is i don't know how to make the correct way to call the table, i leave the npc entirely writed here to see if someone can help me with that:
LUA:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
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
local v = {
["sword"] = {110, 2376, 10, 1, 2379}, -- iron, id.nuevoitem, oro, id.oro, cantidad.refinar, itemid.arefinar
["spike sword"] = {120, 2383, 10, 1, 2376}
}
function creatureSayCallback(cid, type, msg)
local s = getPlayerItemCount
local msgn = "Lo lamento, pero no tienes los materiales suficientes ;)."
if (msgcontains(msg, 'Refinar')) and s(cid,115) == 0 then
npcHandler:say('¡No tienes iron! Consigue algo y luego regresa ;)', cid)
elseif msgcontains(msg, 'Refinar') and s(cid,2148) == 0 then
npcHandler:say(' ¡No tienes oro! Consigue algunas monedas y luego regresas, ¿Quieres? ;)', cid)
elseif (msgcontains(msg, 'Refinar')) and s(cid,115) < 110 then
npcHandler:say('¡No tienes suficiente iron! Consigue algo y luego regresa ;)', cid)
elseif msgcontains(msg, 'Refinar') and s(cid,2148) < 10 then
npcHandler:say(' ¡No tienes suficiente oro! Consigue algunas monedas y luego regresas, ¿Quieres? ;)', cid)
end
for txt, v in pairs(tabla) do
if msgcontains(msg, 'txt') then
if s(cid, 115) == v[1] and s(cid,2148) == v[3] and s(cid,v[5]) == v[4] then
doPlayerRemoveItem(cid,115,v[1])
doPlayerRemoveItem(cid,2148,v[3])
doPlyerRemoveItem(cid,v[6],v[5])
doPlayerAddItem(cid,v[2],1)
npcHandler:say("Aqui tienes tu ".. getItemNameById(v[2]) .."!", cid)
else
npcHandler:say("".. msgn .."", cid)
end
end
end
return true
end
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
This is the error who appeard in the console:
Do you think you can help me?
What you think can be the problem?
i suspect of this two parts, because in the second one i think i'm not callingthe table properly, but the problem is:
how can i call the items by they name in the table properly?
is that the problem or is another one, and if is that way how to fix it?
LUA:
local v = {
["sword"] = {110, 2376, 10, 1, 2379},
["spike sword"] = {120, 2383, 10, 1, 2376}
}
(...)
for txt, v in pairs(tabla) do
if msgcontains(msg, 'txt') then
if s(cid, 115) == v[1] and s(cid,2148) == v[3] and s(cid,v[5]) == v[4] then
¡¡¡Bless you and Cheers up!!!
(Y)(Y)
-Obsdark-