ralke
(҂ ͠❛ ෴ ͡❛)ᕤ
Hi there! I have the following script, running TFS 1.x, for rust removers.
I need to use the following function from a external script right after target:setRarity(COMMON)
But it doesn't work because this function is supposed to work with addItem instead of item transform (if i'm not wrong?). So, I would like to request someone to rebuild the script to work with addItem and removeItem (in case of the rusty armors, etc.) instead of target:transform(targetItem[index].id).
I would really appreciate any help with this, regards!
Lua:
local config = {
[9808] = { -- armadura oxidada (Common)
[1] = {id = 2464, chance = 6994}, -- Chain Armor
[2] = {id = 2483, chance = 3952}, -- Scale Armor
[3] = {id = 2465, chance = 1502}, -- Brass Armor
[4] = {id = 2463, chance = 197} -- Plate Armor
},
[9809] = { -- armadura oxidada (Semi-rare)
[1] = {id = 2483, chance = 6437}, -- Scale Armor
[2] = {id = 2464, chance = 4606}, -- Chain Armor
[3] = {id = 2465, chance = 3029}, -- Brass Armor
[4] = {id = 2463, chance = 1559}, -- Plate Armor
[5] = {id = 2476, chance = 595}, -- armadura de caballero
[6] = {id = 8891, chance = 283}, -- armadura de Paladino
[7] = {id = 2487, chance = 49} -- armadura real
},
[9810] = { -- armadura oxidada (Rare)
[1] = {id = 2465, chance = 6681}, -- Brass Armor
[2] = {id = 2463, chance = 3767}, -- Plate Armor
[3] = {id = 2476, chance = 1832}, -- armadura de caballero
[4] = {id = 2487, chance = 177}, -- armadura real
[5] = {id = 8891, chance = 31}, -- armadura de Paladino
[6] = {id = 2466, chance = 10} -- Golden Armor
},
[9811] = { -- piernas oxidadas (Common)
[1] = {id = 2648, chance = 6949}, -- Chain Legs
[2] = {id = 2468, chance = 3692}, -- Studded Legs
[3] = {id = 2478, chance = 1307}, -- Brass Legs
[4] = {id = 2647, chance = 133} -- Plate Legs
},
[9812] = { -- piernas oxidadas (Semi-Rare)
[1] = {id = 2468, chance = 5962}, -- Studded Legs
[2] = {id = 2648, chance = 4037}, -- Chain Legs
[3] = {id = 2478, chance = 2174}, -- Brass Legs
[4] = {id = 2647, chance = 1242}, -- Plate Legs
[5] = {id = 2477, chance = 186}, -- guardapierna de caballero
},
[9813] = { -- piernas oxidadas (Rare)
[1] = {id = 2478, chance = 6500}, -- Brass Legs
[2] = {id = 2647, chance = 3800}, -- Plate Legs
[3] = {id = 2477, chance = 200}, -- guardapierna de caballero
[4] = {id = 2488, chance = 52}, -- guardapierna real
[5] = {id = 2470, chance = 30} -- Golden Legs
},
[9814] = { -- Heavily Rusted Shield
},
[9815] = { -- Rusted Shield
},
[9816] = { -- Slightly Rusted Shield
[1] = {id = 2510, chance = 3137}, -- Plate Shield
[2] = {id = 2532, chance = 2887}, -- Ancient Shield
[3] = {id = 7460, chance = 929}, -- escudo nordico
[4] = {id = 2519, chance = 23}, -- corona Shield
[5] = {id = 2534, chance = 10} -- Vampire Shield
},
[9820] = { -- Heavily Rusted Helmet
},
[9821] = { -- Rusted Helmet
[1] = {id = 2460, chance = 2200}, -- Brass Helmet
[2] = {id = 2482, chance = 1870}, -- Studded Helmet
[3] = {id = 2459, chance = 1490}, -- Iron Helmet
[4] = {id = 2457, chance = 1010}, -- Steel Helmet
[5] = {id = 2491, chance = 190}, -- casco real
[6] = {id = 2497, chance = 10} -- Crusader Helmet
},
[9822] = { -- Slightly Rusted Helmet
[1] = {id = 2459, chance = 3156}, -- Iron Helmet
[2] = {id = 2457, chance = 2976}, -- Steel Helmet
[3] = {id = 2491, chance = 963}, -- casco real
[4] = {id = 2497, chance = 210}, -- Crusader Helmet
[5] = {id = 2498, chance = 7} -- Royal Helmet
},
[9817] = { -- Heavily Rusted Boots
},
[9818] = { -- Rusted Boots
},
[9819] = { -- Slightly Rusted Boots
},
}
local rustRemover = Action()
function rustRemover.onUse(player, item, fromPosition, target, toPosition, isHotkey)
local targetItem = config[target.itemid]
if not targetItem then
return true
end
local randomChance = math.random(10000)
local index = false
if targetItem[1].chance >= randomChance then -- implying first item in the table index always has the highest chance.
while not index do
randomIndex = math.random(#targetItem)
if targetItem[randomIndex].chance >= randomChance then
index = randomIndex
end
end
end
if not index then
if table.contains({9808, 9809, 9810}, target.itemid) then
msg = "La armadura ya estaba tan oxidada que se rompio cuando intentaste limpiarla."
end
if table.contains({9811, 9812, 9813}, target.itemid) then
msg = "Las piernas ya estaban tan oxidadas que se rompieron cuando intentaste limpiarlas."
end
if table.contains({9814, 9815, 9816}, target.itemid) then
msg = "El escudo ya estaba tan oxidado que se rompio cuando intentaste limpiarlo"
end
if table.contains({9817, 9818, 9819}, target.itemid) then
msg = "Las botas ya estaban tan oxidadas que se rompieron cuando intentaste limpiarlas."
end
if table.contains({9820, 9821, 9822}, target.itemid) then
msg = "El casco ya estaba tan oxidado que se rompio cuando intentaste limpiarlo."
end
player:say(msg, TALKTYPE_MONSTER_SAY)
target:getPosition():sendMagicEffect(CONST_ME_BLOCKHIT)
target:remove()
else
--local minLevel = 10
--local maxLevel = 60
--local randomLevel = math.random(minLevel, maxLevel)
target:transform(targetItem[index].id)
target:setItemLevel(20, false)
target:setRarity(COMMON)
--print("armadura oxidada works.")
target:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
-- player:addAchievementProgress("Polisher", 1000)
end
return item:remove(1)
end
rustRemover:id(9930)
rustRemover:register()
I need to use the following function from a external script right after target:setRarity(COMMON)
Lua:
target:rollAttribute(player, itemType, weaponType, true)
But it doesn't work because this function is supposed to work with addItem instead of item transform (if i'm not wrong?). So, I would like to request someone to rebuild the script to work with addItem and removeItem (in case of the rusty armors, etc.) instead of target:transform(targetItem[index].id).
I would really appreciate any help with this, regards!