Ir para conteúdo

Featured Replies

Postado

estou com esse aki  alguém pode ajudar

 

[Error - CreatureScript Interface]
data/creaturescripts/scripts/killuaItemUp.lua:onKill
Description:
(luaGetMonsterInfo) Monster not found

 

 

-- Itens Upgrade System feito por Killua (Vítor Bertolucci)

local min_exp = 2000 -- Exp mínima para o monstro valer (exp que fica no monster.xml)
local exp_levels = {100000, 245000, 499500, 743300, 967000, 1317400, 2038000, 3800000, 5214000, 7130000} -- Exp pra upar. A cada vez que um item atingir um desses valores de exp, ele upa 1 lvl. (Tem 10, ou seja, nível máximo do item = 10) Pode por mais leveis se quiser.
local slots = {1,4,7,8,5,6}
local wands = {7735,7414,7410,7424}

local function getItemExp(item)
    if item.itemid > 0 then
        return getItemAttribute(item.uid, "exp") or tonumber(0)
    end
    return false
end

local function getItemLevel(experience)
    if experience < exp_levels[1] then return tonumber(0) end
    local old = 1
    for i = 2,10 do
        if experience < exp_levels and experience >= exp_levels[old] then
            return tonumber(old)
        end
        old = i
    end
end

local function getMonsterItemExp (cid,monsterExp)
    local n = monsterExp * 2.71828182846
    local lvl = getPlayerLevel(cid)
    n = (n / (lvl ^ (2.71828182846/10)))/1000
    return math.floor(n)
end


local function doItemAddExp(cid,item,exp)
    if item.itemid > 0 and tonumber(exp) then
        local exp_now = getItemExp(item)
        local oldLevel = getItemLevel(exp_now)
        doItemSetAttribute(item.uid, "exp", exp_now + exp)
        local newLevel = getItemLevel(getItemExp(item))

        if oldLevel < newLevel then

            local isPair = newLevel%2 == 0 and true or false
            local attribute = isPair and 1 or 2

            -- Upar o item
            local itemName = getItemNameById(item.itemid)
            doItemSetAttribute(item.uid,"name",itemName.." +"..newLevel)
            if isShield(item.uid) then
                local def = getItemAttribute(item.uid, "defense") or getItemInfo(item.itemid).defense
                doItemSetAttribute(item.uid,"defense", def + attribute)
                doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_ORANGE,"Seu "..itemName.." upou para o level "..newLevel.." e recebeu +".. attribute .." de defesa.")
            elseif (isSword(item.uid) or isAxe(item.uid) or isClub(item.uid) or isBow(item.uid)) then
                local atk = getItemAttribute(item.uid, "attack") or getItemInfo(item.itemid).attack
                doItemSetAttribute(item.uid,"attack", atk + attribute)
                doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_ORANGE,"Seu "..itemName.." upou para o level "..newLevel.." e recebeu +".. attribute .." de ataque.")
            elseif isArmor(item.itemid) then
                local arm = getItemAttribute(item.uid, "armor") or getItemInfo(item.itemid).armor
                doItemSetAttribute(item.uid,"armor", arm + attribute)
                doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_ORANGE,"Seu "..itemName.." upou para o level "..newLevel.." e recebeu +".. attribute .." de arm.")
            elseif isWand(item.uid) and isInArray(wands,item.itemid) then
                doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_ORANGE,"Sua "..itemName.." upou para o level "..newLevel.." e recebeu +5% de poder de ataque")
            end
        end

    end
    return false
end

function onKill(cid, target, lastHit)   

    if isPlayer(cid) and isMonster(target) then

        local monsterName = getCreatureName(target)
        if not monsterName or type(monsterName) ~= "string" then return true end
        local monster = getMonsterInfo(monsterName)
        if not monster then return true end
        local monsterExp = getMonsterInfo(monsterName).experience
        if not monsterExp then return true end
        local exp_gain = getMonsterItemExp(cid,monsterExp)


        if monsterExp >= min_exp then
            for _,b in pairs(slots) do
                local item = getPlayerSlotItem(cid, b)
                if item.uid > 0 then
                    if isArmor(item.itemid) or isShield(item.uid) or isWand(item.uid) or isAxe(item.uid) or isSword(item.uid) or isClub(item.uid) or isBow(item.uid) then
                        doItemAddExp(cid, item, exp_gain)
                        local itemExp = getItemExp(item)
                        --doPlayerSendTextMessage(cid,MESSAGE_EVENT_DEFAULT,"Seu "..getItemNameById(item.itemid).." ganhou "..exp_gain.." pontos de exp ao derrotar um "..monsterName..". Ele tem ["..itemExp.."/".. exp_levels[ getItemLevel(itemExp) +1] .."] pontos atualmente.")
                    end
                end

            end
        end
    end
    return true
end

function onLogin(cid)
    registerCreatureEvent(cid, "Item level")
    return true
end

 

 

Postado
local min_exp = 2000
local exp_levels = {100000, 245000, 499500, 743300, 967000, 1317400, 2038000, 3800000, 5214000, 7130000} 
local slots = {1,4,7,8,5,6}
local wands = {7735,7414,7410,7424}
local function getItemExp(item)
    if item.itemid > 0 then
        return getItemAttribute(item.uid, "exp") or tonumber(0)
    end
    return false
end
local function getItemLevel(experience)
    if experience < exp_levels[1] then return tonumber(0) end
    local old = 1
    for i = 2,10 do
        if experience < exp_levels and experience >= exp_levels[old] then
            return tonumber(old)
        end
        old = i
    end
end
local function getMonsterItemExp (cid,monsterExp)
    local n = monsterExp * 2.71828182846
    local lvl = getPlayerLevel(cid)
    n = (n / (lvl ^ (2.71828182846/10)))/1000
    return math.floor(n)
end
function onKill(cid, target, lastHit)   
    if isPlayer(cid) and isMonster(target) then
        local name = getCreatureName(target)
        local monsterExp = getMonsterInfo(name).experience
        local exp_gain = getMonsterItemExp(cid, monsterExp)
        if monsterExp >= min_exp then
            for _,b in pairs(slots) do
                local item = getPlayerSlotItem(cid, b)
                if item.uid > 0 then
                    if isArmor(item.itemid) or isShield(item.uid) or isWand(item.uid) or isAxe(item.uid) or isSword(item.uid) or isClub(item.uid) or isBow(item.uid) then
                        doItemAddExp(cid, item, exp_gain)
                        local itemExp = getItemExp(item)
                        --doPlayerSendTextMessage(cid,MESSAGE_EVENT_DEFAULT,"Seu "..getItemNameById(item.itemid).." ganhou "..exp_gain.." pontos de exp ao derrotar um "..name..". Ele tem ["..itemExp.."/".. exp_levels[ getItemLevel(itemExp) +1] .."] pontos atualmente.")
                    end
                end
            end
        end
    end
    return true
end
function onLogin(cid)
    registerCreatureEvent(cid, "Item level")
    return true
end

 

Postado
  • Autor
  Em 26/07/2018 em 02:20, Vodkart disse:

local min_exp = 2000
local exp_levels = {100000, 245000, 499500, 743300, 967000, 1317400, 2038000, 3800000, 5214000, 7130000} 
local slots = {1,4,7,8,5,6}
local wands = {7735,7414,7410,7424}
local function getItemExp(item)
    if item.itemid > 0 then
        return getItemAttribute(item.uid, "exp") or tonumber(0)
    end
    return false
end
local function getItemLevel(experience)
    if experience < exp_levels[1] then return tonumber(0) end
    local old = 1
    for i = 2,10 do
        if experience < exp_levels and experience >= exp_levels[old] then
            return tonumber(old)
        end
        old = i
    end
end
local function getMonsterItemExp (cid,monsterExp)
    local n = monsterExp * 2.71828182846
    local lvl = getPlayerLevel(cid)
    n = (n / (lvl ^ (2.71828182846/10)))/1000
    return math.floor(n)
end
function onKill(cid, target, lastHit)   
    if isPlayer(cid) and isMonster(target) then
        local name = getCreatureName(target)
        local monsterExp = getMonsterInfo(name).experience
        local exp_gain = getMonsterItemExp(cid, monsterExp)
        if monsterExp >= min_exp then
            for _,b in pairs(slots) do
                local item = getPlayerSlotItem(cid, b)
                if item.uid > 0 then
                    if isArmor(item.itemid) or isShield(item.uid) or isWand(item.uid) or isAxe(item.uid) or isSword(item.uid) or isClub(item.uid) or isBow(item.uid) then
                        doItemAddExp(cid, item, exp_gain)
                        local itemExp = getItemExp(item)
                        --doPlayerSendTextMessage(cid,MESSAGE_EVENT_DEFAULT,"Seu "..getItemNameById(item.itemid).." ganhou "..exp_gain.." pontos de exp ao derrotar um "..name..". Ele tem ["..itemExp.."/".. exp_levels[ getItemLevel(itemExp) +1] .."] pontos atualmente.")
                    end
                end
            end
        end
    end
    return true
end
function onLogin(cid)
    registerCreatureEvent(cid, "Item level")
    return true
end

 

agora deu esse @Vodkart

Error - CreatureScript Interface]
data/creaturescripts/scripts/killuaItemUp.lua:onKill
Description:
data/creaturescripts/scripts/killuaItemUp.lua:37: attempt to call global 'doItemAddExp' (a nil value)
stack traceback:
        data/creaturescripts/scripts/killuaItemUp.lua:37: in function <data/creaturescripts/scripts/killuaItemUp.lua:27>

Postado

vc n tem as outras funções

 

adc no seu script

 

function doItemAddExp(item)
    if item.itemid > 0 then
        return doItemSetAttribute(item.uid, "exp", getItemExp(item) + 1)
    end
    return false
end
function doItemAddLevel(item, count)
    if item.itemid > 0 and tonumber(count) then
        return doItemSetAttribute(item.uid, "level", getItemLevel(item) + count)
    end
    return false
end

 

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.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Conteúdo Similar

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo