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
[Need Help] Enchant Script
Author Message
nvnhathuy Offline
Elpy
*

Posts: 3
Joined: Sep 2013
Reputation: 0
Version: 1.4.1.112
Post: #1
[Need Help] Enchant Script

hi Guys!
I searched in forum, but cant find solution.
i got problem with enchant script, when i run it, it only enchant 1 time, no notice to client and stop, i must have to stop and start again.
I playing interlude server, run origin script of l2tower, just change name scroll, weapon, safe, max. And if fail, iteam became+10
Anyone can help me please?

Here my script (Mod put it in scroll box please, i dont know how to , thanks )
p/s: sorry my bad english.

-- SCRIPT CONFIGURATION!

item_name = "Vesper Bow"
enchant_name = "Scroll: Enchant Weapon (Grade S)"
blessed_enchant_name = "Blessed Scroll: Enchant Weapon (Grade S)"
max_enchant = 30
max_safe_enchant = 10
delay = 2100

-- 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 + 1
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()
(This post was last modified: 11-08-2013 15:19 PM by nvnhathuy.)
11-08-2013 15:18 PM
Find all posts by this user Quote this message in a reply
deivuzas1 Offline
Elpy
*

Posts: 1
Joined: Oct 2016
Reputation: 0
Version: 1.4.1.121
Post: #2
RE: [Need Help] Enchant Script

I have the same problem then I press enchant it makes +1 or +2 and stops and need to do it again , before it was everything allright maybe its server bug?
03-03-2017 20:07 PM
Find all posts by this user Quote this message in a reply
Post Reply 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Get skill enchant level raid1141 1 4,515 10-15-2015 14:57 PM
Last Post: raid1141
  Auto Enchant Script sone78 3 8,394 11-26-2014 17:20 PM
Last Post: sone78
  Not working Enchant sallabisey 0 2,173 03-28-2014 08:02 AM
Last Post: sallabisey
  Enchant salimonas 0 2,294 06-29-2013 22:25 PM
Last Post: salimonas
  Enchant NaoJogoMais 0 3,085 04-09-2013 21:37 PM
Last Post: NaoJogoMais
  Auto Enchant Armor problems psyhyk 1 3,816 03-28-2013 23:06 PM
Last Post: MtnDew
  Enchant not blessed? jnorman 6 7,146 01-21-2013 00:04 AM
Last Post: jnorman
  Script Enchant Armor ? Farghass 1 6,603 11-22-2012 23:13 PM
Last Post: aniah
  The script to enchant and + 2 stops working what is wrong? xamius55 1 2,998 08-07-2012 19:12 PM
Last Post: AdioZ
Question Auto item enchant problem [Video] AdioZ 4 15,156 08-05-2012 11:06 AM
Last Post: feliperigo



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