Falta estudar tabelas...
local tabble = {
{reqVoc= 7, needLevel=330000},
}
print(tabble.reqVoc) -- retorna nil
---------------------------
local tabble = {
{reqVoc= 7, needLevel=330000},
}
print(tabble[1].reqVoc) -- retorna 7
----------------------------
o certo é usar:
local tabble = {
reqVoc= 7, needLevel= 330000,
}
print(tabble.reqVoc)
o código:
function onUse(cid, fromPosition, itemEx, toPosition)
local tabble = {
reqVoc = 7,
needLevel = 330000
}
local config = {
pid = getPlayerGUID(cid),
newlv = 90000,
life = 3599865,
mana = 3599715
}
if getPlayerLevel(cid) < 330000 and tabble.needLevel then
doPlayerPopupFYI(cid, "Voce precisa ser level " .. needLevel .. " para resetar.")
return true
elseif tabble.reqVoc >= getPlayerVocation(cid) or 8 then
doPlayerPopupFYI(cid, "Voce já é vocaçao.")
return true
elseif tabble.reqVoc <= 7 and getPlayerVocation(cid) then
doPlayerPopupFYI(cid, "Voce precisa ser vocaçao para resetar.")
return true
end
if tabble.reqVoc == getPlayerVocation(cid) then
setPlayerStorageValue(cid, 887978, 1)
end
local newvoc = tabble.reqVoc ~= getPlayerVocation(cid) and (tabble.reqVoc+1)
setPlayerStorageValue(cid, 887979, newvoc)
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
doRemoveCreature(cid)
db.executeQuery("UPDATE `players` SET `level` = "..config.newlv..", `experience` = "..getExperienceForLevel(config.newlv)..",`manamax` = "..config.mana..",`health` = "..config.life..", `healthmax` = "..config.life..",`mana` = "..config.mana.." WHERE `id` = "..config.pid)
return true
end