Não sei porque o outro tópico que fiz foi fechado sem aviso algum, mas emfim.
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:
Spoiler
function getItemExp(item)if item.itemid >0 then return getItemAttribute(item.uid,"exp") or 0 end returnfalseendfunction getItemLevel(item)if item.itemid >0 then return getItemAttribute(item.uid,"level") or 0 end returnfalseendfunction doItemAddExp(item)if item.itemid >0 then return doItemSetAttribute(item.uid,"exp", getItemExp(item)+1) end returnfalseendfunction doItemAddLevel(item, count)if item.itemid >0 and tonumber(count) then return doItemSetAttribute(item.uid,"level", getItemLevel(item)+ count) end returnfalseendlocal 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.(Tem10, 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)doif slots[b] then if type(slots[b])=="table" then for i =1,#slots[b]do local tb = slots[b] table.insert(tab, tb[i]) end else table.insert(tab, slots[b]) end end end end if#tab >0 then for i =1,#tab do local item = getPlayerSlotItem(cid, tab[i])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 returntrueendfunction onLogin(cid) registerCreatureEvent(cid,"Item level")returntrueend
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).
Pergunta
gabriel28 60
Não sei porque o outro tópico que fiz foi fechado sem aviso algum, mas emfim.
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:
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).
TFS 0.4 rev 3884 Tibia 8.6.
Agradeço desde já.
Link para o comentário
https://xtibia.com/forum/topic/243622-problema-com-um-script/Compartilhar em outros sites
4 respostass a esta questão
Posts Recomendados