L2Tower Discord Let's keep the community alive with discord. Discussions about plugins and scripts L2Tower Discord

Post Reply 
 
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Enchat max 30, when failure reset to +7
Author Message
verinek Offline
Elpy
*

Posts: 2
Joined: May 2013
Reputation: 0
Version: 1.4.1.112
Post: #1
Enchat max 30, when failure reset to +7

Hey,
I got problem with repeating a enchant script. When I turn it on for 1st time it works fine, but when item failure reset to +7 and then nothink happend.
There is a cript that i use:
Quote:-- SCRIPT CONFIGURATION!

item_name = "Necklace of Valakas"
enchant_name = "Blessed Scroll: Enchant Armor (Grade S)"
blessed_enchant_name = "Blessed Scroll: Enchant Armor (Grade S)"
max_enchant = 30
max_safe_enchant = 7
delay = 0

-- 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 + 1
end

function registerFailure(base)
if stats[base] == nil then
stats[base] = { success = 0, failure = 0 }
end
stats[base].failure = stats[base].failure + 7
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(200)
end

if ( enchantResult() == Enchant.ENCHANT_SUCCESS ) then
Sleep ( 500 ) -- 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+1)
Sleep ( 500 ) -- sleep so item data is updated
registerFailure ( item.Enchanted + 1)
end
printStatistics()
end
ShowToClient("Enchant", "Enchant script finished")
printStatistics()
06-24-2014 18:34 PM
Find all posts by this user Quote this message in a reply
verinek Offline
Elpy
*

Posts: 2
Joined: May 2013
Reputation: 0
Version: 1.4.1.112
Post: #2
RE: Enchat max 30, when failure reset to +7

up
06-27-2014 12:11 PM
Find all posts by this user Quote this message in a reply
Post Reply 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Bot reset setting problem aa300598 2 3,651 02-04-2016 13:18 PM
Last Post: TheQQmaster
  Stop bottin , Reset Your router , Delog your Main JazzDancer 5 4,038 11-29-2013 19:32 PM
Last Post: JazzDancer
  reset config afetr restart kreon 7 5,062 11-01-2013 13:58 PM
Last Post: akatim
  how reset settings of tower? renato_jose 3 4,229 10-29-2012 15:57 PM
Last Post: ClockMan



User(s) browsing this thread: 1 Guest(s)