sim,nesse caso eu preferia usar tabela...
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
local skills = {
["club"] = {skillid = 1,price = {15,9971},vocs = {4,8}},
["sword"] = {skillid = 2,price = {15,9971},vocs = {4,8}},
["mace"] = {skillid = 0,price = {15,9971},vocs = {4,8}},
["axe"] = {skillid = 4,price = {15,9971},vocs = {4,8}},
["shield"] = {skillid = 5,price = {15,9971},vocs = {4,3,7,8}},
["distance"] = {skillid = 4,price = {15,9971},vocs = {3,7}}
}
if (msgcontains(msg, 'skill') or msgcontains(msg, 'skills'))then
local str = ""
str = str .. "I selling this skills: "
for name, pos in pairs(skills) do
str = str.." {"..name.."} = "..pos.price[1].." gold ingot /"
end
str = str .. "."
npcHandler:say(str, cid)
elseif skills[msg] then
if isInArray(skills[msg].vocs,getPlayerVocation(cid)) then
if doPlayerRemoveItem(cid,skills[msg].price[2],skills[msg].price[1]) then
doPlayerAddSkill(cid,skills[msg].skillid,1)
npcHandler:say("You bought a "..msg.." skill", cid)
else
npcHandler:say("You do not have "..skills[msg].price[1].." ".. getItemNameById(skills[msg].price[2]), cid)
end
else
npcHandler:say("You dont have vocation for buy this skill", cid)
end
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())