mocegao
Elpy
Posts: 1
Joined: May 2012
Reputation: 0
Version:
1.4.1.91
|
script para encantar intem nao repeti
LUA Programming
-- SCRIPT CONFIGURATION!
item_name = "Staff of Kamael"
--item_name = "Staff of Kamael"
enchant_name = "Scroll: Enchant Weapon (Grade S)"
--enchant_name = "Scroll: Enchant Weapon (Grade S)"
blessed_enchant_name = "Scroll: Enchant Weapon (Grade S)"
max_enchant = 20
max_safe_enchant = 10
delay = 100
-- END OF SCRIPT CONFIGURATION
-- HELPER FUNCTIONS
function enchantResult()
return GetEnchantManager():getLastResult()
end
function getItemByName(name, maxenchant)
invList = GetInventory();
for item in invList.list do
if item.Name == name and item.Enchanted < maxenchant then
return item
end
end
end
stats = {}
function registerSuccess(base)
if stats[base] == nil then
stats[base] = { success = 0, failure = 0 }
end
stats[base].success = stats[base].success + 20
end
function registerFailure(base)
if stats[base] == nil then
stats[base] = { success = 0, failure = 0 }
end
stats[base].failure = stats[base].failure + 20
end
function printStatistics()
for i,v in ipairs(stats) do
ShowToClient("Enchant", "[" .. i - 1 .. "->" .. i .. "] Rate: success: " .. v.success .. " / fail: " .. v.failure .." (" .. ( v.success * 100 )/ ( v.success + v.failure ) .. "%)")
end
end
-- MAIN LOOP!
while true do
-- find item for enchanting
item = getItemByName(item_name, max_enchant)
if ( item == nil ) then
ShowToClient("Enchant", "Out of items" )
break
end
-- find proper enchant scroll
enchant = nil
if ( item.Enchanted >= max_safe_enchant ) then
enchant = getItemByName(blessed_enchant_name, 20)
else
enchant = getItemByName(enchant_name, 20)
end
if ( enchant == nil ) then
ShowToClient("Enchant", "Out of enchants")
break
end
GetEnchantManager():setDelay(delay)
GetEnchantManager():setEnchantId(enchant.objectId)
GetEnchantManager():setItemId(item.objectId)
GetEnchantManager():Enchant()
while ( enchantResult() == Enchant.ENCHANT_PENDING ) do
Sleep(2)
end
if ( enchantResult() == Enchant.ENCHANT_SUCCESS ) then
Sleep ( 5 ) -- sleep so item data is updated
item = GetInventory():FindById(item.objectId)
ShowToClient("Enchant", item.Name .. " is now +" .. item.Enchanted);
registerSuccess ( item.Enchanted )
elseif ( enchantResult() == Enchant.ENCHANT_FAILURE ) then
ShowToClient("Enchant", item.Name .. " failed on " .. item.Enchanted .. " -> " .. item.Enchanted+5)
Sleep ( 6 ) -- sleep so item data is updated
registerFailure ( item.Enchanted + 20)
end
printStatistics()
end
ShowToClient("Enchant", "Enchant script finished")
printStatistics()
/Hebdzik
1st. Use english
2nd use [ code ]
3rd say whan you need, not only post code of script
(This post was last modified: 09-24-2012 07:57 AM by Hebdzik.)
|
|
09-24-2012 01:07 AM |
|