Postado Fevereiro 20, 2017 8 anos Tenho um script que a arma vai ganhando experiência e upa de acordo com a quantidade de monstros que o player mata, deixando o item +1 até +10. Só que, ao invés da descrição do item ficar: You see a brass armor +2 (arm: 9), fica assim: You see a brass armor +1 +2 (arm: 10). Sempre que upa o level, vai acrescentando na descrição. Segue o script do sistema: Mostrar conteúdo oculto function getItemExp(item) if item.itemid > 0 then return getItemAttribute(item.uid, "exp") or 0 end return false end function getItemLevel(item) if item.itemid > 0 then return getItemAttribute(item.uid, "level") or 0 end return false end 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 local table_of_slots = {"head", "body", "legs", "feet", "hands"} --Slots. Ex.: {"head", "body"} local min_exp = 500 -- Exp mínima para o monstro valer (exp que fica no monster.xml) local exp_levels = {2, 4, 6, 180, 280, 400, 550, 700, 900, 1500} -- Exp pra upar. A cada vez que um item atigingir 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 = { ["head"] = 1, ["body"] = 4, ["legs"] = 7, ["feet"] = 8, ["hands"] = {5, 6}, } function onKill(cid, target, lastHit) local tab = {} if isPlayer(cid) and isMonster(target) then if getMonsterInfo(getCreatureName(target)).experience >= min_exp then if #table_of_slots > 0 then for a, b in pairs(table_of_slots) do if slots then if type(slots) == "table" then for i = 1, #slots do local tb = slots table.insert(tab, tb) end else table.insert(tab, slots) end end end end if #tab > 0 then for i = 1, #tab do local item = getPlayerSlotItem(cid, tab) if item.uid > 0 then doItemAddExp(item) if getItemLevel(item) then if isInArray(exp_levels, getItemExp(item)) then if getItemInfo(item.itemid).attack > 0 or getItemInfo(item.itemid).defense > 0 or getItemInfo(item.itemid).armor > 0 then if getItemLevel(item) ~= #exp_levels then doItemAddLevel(item, 1) doItemSetAttribute(item.uid, "name", getItemName(item.uid).." +"..getItemLevel(item)) doSendMagicEffect(getThingPos(cid), 28) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Seu "..getItemNameById(item.itemid).." atingiu "..getItemExp(item).."exp e ganhou 1 level! Agora ele esta level "..getItemLevel(item)) local atk = getItemAttribute(item.uid, "attack") or getItemInfo(item.itemid).attack local def = getItemAttribute(item.uid, "defense") or getItemInfo(item.itemid).defense local arm = getItemAttribute(item.uid, "armor") or getItemInfo(item.itemid).armor if getItemInfo(item.itemid).armor > 0 then doItemSetAttribute(item.uid, "armor",arm + 1) elseif getItemInfo(item.itemid).attack > 0 then doItemSetAttribute(item.uid, "attack",atk + 1) elseif getItemInfo(item.itemid).defense > 0 and getItemInfo(item.itemid).attack <= 0 then doItemSetAttribute(item.uid, "defense",def + 1) end end end end end end end end end end return true end function onLogin(cid) registerCreatureEvent(cid, "Item level") return true end Gostaria que não conflitasse com outro script que tenho, que muda a descrição também. É um script que adiciona reflet ao equipamento, ficando: You see a brass armor ref 2% (arm: 8). Dai com esse script, ficaria: You see a brass armor +1 ref 2% (arm: 9). Agradeço desde já. Editado Fevereiro 20, 2017 8 anos por gabriel28 (veja o histórico de edições)
Postado Fevereiro 21, 2017 8 anos Em 20/02/2017 em 13:27, gabriel28 disse: Tenho um script que a arma vai ganhando experiência e upa de acordo com a quantidade de monstros que o player mata, deixando o item +1 até +10. Só que, ao invés da descrição do item ficar: You see a brass armor +2 (arm: 9), fica assim: You see a brass armor +1 +2 (arm: 10). Sempre que upa o level, vai acrescentando na descrição. Segue o script do sistema: Mostrar conteúdo oculto Mostrar conteúdo oculto function getItemExp(item) if item.itemid > 0 then return getItemAttribute(item.uid, "exp") or 0 end return false end function getItemLevel(item) if item.itemid > 0 then return getItemAttribute(item.uid, "level") or 0 end return false end 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 local table_of_slots = {"head", "body", "legs", "feet", "hands"} --Slots. Ex.: {"head", "body"} local min_exp = 500 -- Exp mínima para o monstro valer (exp que fica no monster.xml) local exp_levels = {2, 4, 6, 180, 280, 400, 550, 700, 900, 1500} -- Exp pra upar. A cada vez que um item atigingir 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 = { ["head"] = 1, ["body"] = 4, ["legs"] = 7, ["feet"] = 8, ["hands"] = {5, 6}, } function onKill(cid, target, lastHit) local tab = {} if isPlayer(cid) and isMonster(target) then if getMonsterInfo(getCreatureName(target)).experience >= min_exp then if #table_of_slots > 0 then for a, b in pairs(table_of_slots) do if slots then if type(slots) == "table" then for i = 1, #slots do local tb = slots table.insert(tab, tb) end else table.insert(tab, slots) end end end end if #tab > 0 then for i = 1, #tab do local item = getPlayerSlotItem(cid, tab) if item.uid > 0 then doItemAddExp(item) if getItemLevel(item) then if isInArray(exp_levels, getItemExp(item)) then if getItemInfo(item.itemid).attack > 0 or getItemInfo(item.itemid).defense > 0 or getItemInfo(item.itemid).armor > 0 then if getItemLevel(item) ~= #exp_levels then doItemAddLevel(item, 1) doItemSetAttribute(item.uid, "name", getItemName(item.uid).." +"..getItemLevel(item)) doSendMagicEffect(getThingPos(cid), 28) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Seu "..getItemNameById(item.itemid).." atingiu "..getItemExp(item).."exp e ganhou 1 level! Agora ele esta level "..getItemLevel(item)) local atk = getItemAttribute(item.uid, "attack") or getItemInfo(item.itemid).attack local def = getItemAttribute(item.uid, "defense") or getItemInfo(item.itemid).defense local arm = getItemAttribute(item.uid, "armor") or getItemInfo(item.itemid).armor if getItemInfo(item.itemid).armor > 0 then doItemSetAttribute(item.uid, "armor",arm + 1) elseif getItemInfo(item.itemid).attack > 0 then doItemSetAttribute(item.uid, "attack",atk + 1) elseif getItemInfo(item.itemid).defense > 0 and getItemInfo(item.itemid).attack <= 0 then doItemSetAttribute(item.uid, "defense",def + 1) end end end end end end end end end end return true end function onLogin(cid) registerCreatureEvent(cid, "Item level") return true end Gostaria que não conflitasse com outro script que tenho, que muda a descrição também. É um script que adiciona reflet ao equipamento, ficando: You see a brass armor ref 2% (arm: 8). Dai com esse script, ficaria: You see a brass armor +1 ref 2% (arm: 9). Agradeço desde já. function getItemExp(item) if item.itemid > 0 then return getItemAttribute(item.uid, "exp") or 0 end return false end function getItemLevel(item) if item.itemid > 0 then return getItemAttribute(item.uid, "level") or 0 end return false end 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 local table_of_slots = {"head", "body", "legs", "feet", "hands"} --Slots. Ex.: {"head", "body"} local min_exp = 500 -- Exp mínima para o monstro valer (exp que fica no monster.xml) local exp_levels = {2, 4, 6, 180, 280, 400, 550, 700, 900, 1500} -- Exp pra upar. A cada vez que um item atigingir 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 = { ["head"] = 1, ["body"] = 4, ["legs"] = 7, ["feet"] = 8, ["hands"] = {5, 6}, } function onKill(cid, target, lastHit) local tab = {} if isPlayer(cid) and isMonster(target) then if getMonsterInfo(getCreatureName(target)).experience >= min_exp then if #table_of_slots > 0 then for a, b in pairs(table_of_slots) do if slots then if type(slots) == "table" then for i = 1, #slots do local tb = slots table.insert(tab, tb) end else table.insert(tab, slots) end end end end if #tab > 0 then for i = 1, #tab do local item = getPlayerSlotItem(cid, tab) if item.uid > 0 then doItem AddExp(item) if getItemLevel(item) then if isInArray(exp_levels, getItemExp(item)) then if getItemInfo(item.itemid).attack > 0 or getItemInfo(item.itemid).defense > 0 or getItemInfo(item.itemid).armor > 0 then if getItemLevel(item) ~= #exp_levels then doItemAddLevel(item, 1) doItemSetAttribute(item.uid, "name", getItemName(item.uid)..) doItemSetAttribute(item.uid, "name", getItemName(item.uid).." +"..getItemLevel(item)) doSendMagicEffect(getThingPos(cid), 28) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Seu "..getItemNameById(item.itemid).." atingiu "..getItemExp(item).."exp e ganhou 1 level! Agora ele esta level "..getItemLevel(item)) local atk = getItemAttribute(item.uid, "attack") or getItemInfo(item.itemid).attack local def = getItemAttribute(item.uid, "defense") or getItemInfo(item.itemid).defense local arm = getItemAttribute(item.uid, "armor") or getItemInfo(item.itemid).armor if getItemInfo(item.itemid).armor > 0 then doItemSetAttribute(item.uid, "armor",arm + 1) elseif getItemInfo(item.itemid).attack > 0 then doItemSetAttribute(item.uid, "attack",atk + 1) elseif getItemInfo(item.itemid).defense > 0 and getItemInfo(item.itemid).attack <= 0 then doItemSetAttribute(item.uid, "defense",def + 1) end end end end end end end end end end return true end function onLogin(cid) registerCreatureEvent(cid, "Item level") return true end
Postado Fevereiro 22, 2017 8 anos Autor Em 21/02/2017 em 20:30, Gustavo Ntos disse: function getItemExp(item) if item.itemid > 0 then return getItemAttribute(item.uid, "exp") or 0 end return false end function getItemLevel(item) if item.itemid > 0 then return getItemAttribute(item.uid, "level") or 0 end return false end 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 local table_of_slots = {"head", "body", "legs", "feet", "hands"} --Slots. Ex.: {"head", "body"} local min_exp = 500 -- Exp mínima para o monstro valer (exp que fica no monster.xml) local exp_levels = {2, 4, 6, 180, 280, 400, 550, 700, 900, 1500} -- Exp pra upar. A cada vez que um item atigingir 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 = { ["head"] = 1, ["body"] = 4, ["legs"] = 7, ["feet"] = 8, ["hands"] = {5, 6}, } function onKill(cid, target, lastHit) local tab = {} if isPlayer(cid) and isMonster(target) then if getMonsterInfo(getCreatureName(target)).experience >= min_exp then if #table_of_slots > 0 then for a, b in pairs(table_of_slots) do if slots then if type(slots) == "table" then for i = 1, #slots do local tb = slots table.insert(tab, tb) end else table.insert(tab, slots) end end end end if #tab > 0 then for i = 1, #tab do local item = getPlayerSlotItem(cid, tab) if item.uid > 0 then doItem AddExp(item) if getItemLevel(item) then if isInArray(exp_levels, getItemExp(item)) then if getItemInfo(item.itemid).attack > 0 or getItemInfo(item.itemid).defense > 0 or getItemInfo(item.itemid).armor > 0 then if getItemLevel(item) ~= #exp_levels then doItemAddLevel(item, 1) doItemSetAttribute(item.uid, "name", getItemName(item.uid)..) doItemSetAttribute(item.uid, "name", getItemName(item.uid).." +"..getItemLevel(item)) doSendMagicEffect(getThingPos(cid), 28) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Seu "..getItemNameById(item.itemid).." atingiu "..getItemExp(item).."exp e ganhou 1 level! Agora ele esta level "..getItemLevel(item)) local atk = getItemAttribute(item.uid, "attack") or getItemInfo(item.itemid).attack local def = getItemAttribute(item.uid, "defense") or getItemInfo(item.itemid).defense local arm = getItemAttribute(item.uid, "armor") or getItemInfo(item.itemid).armor if getItemInfo(item.itemid).armor > 0 then doItemSetAttribute(item.uid, "armor",arm + 1) elseif getItemInfo(item.itemid).attack > 0 then doItemSetAttribute(item.uid, "attack",atk + 1) elseif getItemInfo(item.itemid).defense > 0 and getItemInfo(item.itemid).attack <= 0 then doItemSetAttribute(item.uid, "defense",def + 1) end end end end end end end end end end return true end function onLogin(cid) registerCreatureEvent(cid, "Item level") return true end Não deu certo, cara. Não dá nenhum erro, mas o script não funciona.
Postado Fevereiro 23, 2017 8 anos Em 23/02/2017 em 02:06, gabriel28 disse: up Mostrar conteúdo oculto function getItemExp(item) if item.itemid > 0 then return getItemAttribute(item.uid, "exp") or 0 end return false end function getItemLevel(item) if item.itemid > 0 then return getItemAttribute(item.uid, "level") or 0 end return false end 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 local table_of_slots = {"head", "body", "legs", "feet", "hands"} --Slots. Ex.: {"head", "body"} local min_exp = 500 -- Exp mínima para o monstro valer (exp que fica no monster.xml) local exp_levels = {2, 4, 6, 180, 280, 400, 550, 700, 900, 1500} -- Exp pra upar. A cada vez que um item atigingir 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 = { ["head"] = 1, ["body"] = 4, ["legs"] = 7, ["feet"] = 8, ["hands"] = {5, 6}, } function onKill(cid, target, lastHit) local tab = {} if isPlayer(cid) and isMonster(target) then if getMonsterInfo(getCreatureName(target)).experience >= min_exp then if #table_of_slots > 0 then for a, b in pairs(table_of_slots) do if slots then if type(slots) == "table" then for i = 1, #slots do local tb = slots table.insert(tab, tb) end else table.insert(tab, slots) end end end end if #tab > 0 then for i = 1, #tab do local item = getPlayerSlotItem(cid, tab) if item.uid > 0 then doItem AddExp(item) if getItemLevel(item) then if isInArray(exp_levels, getItemExp(item)) then if getItemInfo(item.itemid).attack > 0 or getItemInfo(item.itemid).defense > 0 or getItemInfo(item.itemid).armor > 0 then if getItemLevel(item) ~= #exp_levels then doItemAddLevel(item, 1) doItemSetAttribute(item.uid, "name", getItemName(item.uid)) doItemSetAttribute(item.uid, "name", getItemName(item.uid).." +"..getItemLevel(item)) doSendMagicEffect(getThingPos(cid), 28) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Seu "..getItemNameById(item.itemid).." atingiu "..getItemExp(item).."exp e ganhou 1 level! Agora ele esta level "..getItemLevel(item)) local atk = getItemAttribute(item.uid, "attack") or getItemInfo(item.itemid).attack local def = getItemAttribute(item.uid, "defense") or getItemInfo(item.itemid).defense local arm = getItemAttribute(item.uid, "armor") or getItemInfo(item.itemid).armor if getItemInfo(item.itemid).armor > 0 then doItemSetAttribute(item.uid, "armor",arm + 1) elseif getItemInfo(item.itemid).attack > 0 then doItemSetAttribute(item.uid, "attack",atk + 1) elseif getItemInfo(item.itemid).defense > 0 and getItemInfo(item.itemid).attack <= 0 then doItemSetAttribute(item.uid, "defense",def + 1) end end end end end end end end end end return true end function onLogin(cid) registerCreatureEvent(cid, "Item level") return true 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.