• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Enchanted Weapon bug (Help)

LucasFerraz

Systems Analyst
Joined
Jun 10, 2010
Messages
2,858
Reaction score
96
Location
Brazil
When charges of a weapon enchanted is over, the weapon transform to original and if attack +1 time it disappears.
How can I make to when charges of Icy Spike Sword(example) end it transform to spike sword and to not desappears if attack one more time?(It is being destroyed)

Lua:
function onUse(cid, item, fromPosition, item2, toPosition)
local gems = {2146, 2147, 2149, 2150}
local egems = {7759, 7760, 7761, 7762}
local altars = {{7508, 7509, 7510, 7511}, {7504, 7505, 7506, 7507}, {7516, 7517, 7518, 7519}, {7512, 7513, 7514, 7515}}
local weapons = {2383, 7384, 7389, 7406, 7402, 2429, 2430, 2435, 7380, 2454, 2423, 2445, 7415, 7392, 2391, 2544, 8905, 2342}
local eweapons = {{7763, 7744, 7854, 7869}, {7765, 7746, 7856, 7871}, {7770, 7751, 7861, 7876}, {7766, 7747, 7857, 7872}, {7767, 7748, 7858, 7873}, {7768, 7749, 7859, 7874}, {7769, 7750, 7860, 7875}, {7770, 7751, 7861, 7876}, {7771, 7752, 7862, 7877}, {7772, 7753, 7863, 7878}, {7773, 7754, 7864, 7879}, {7774, 7755, 7865, 7880}, {7775, 7756, 7866, 7881}, {7776, 7757, 7867, 7882}, {7777, 7758, 7868, 7883}, {7839, 7840, 7838, 7850}, {8907, 8906, 8909, 8908}, {2343, 2343, 2343, 2343}}
local type = item.type
if type == 0 then
type = 1
end
local mana = -300 * type
local soul = -2 * type
if isInArray(gems, item.itemid)== TRUE then
for aa=1, #gems do
if item.itemid == gems[aa] then
a=aa
end
end
if isInArray(altars[a], item2.itemid)== TRUE then
if getPlayerMana(cid) >= mana and getPlayerSoul(cid) >= soul then
doTransformItem(item.uid,egems[a])
doPlayerAddMana(cid,mana)
doPlayerAddSoul(cid,soul)
doSendMagicEffect(fromPosition,39)
else
doPlayerSendCancel(cid,"You dont have mana or soul points.")
end
else
return 2
end
elseif isInArray(egems, item.itemid)== TRUE then
for bb=1, #egems do
if item.itemid == egems[bb] then
b=bb
end
end
if isInArray(weapons, item2.itemid)== TRUE then
for cc=1, #weapons do
if item2.itemid == weapons[cc] then
c=cc
end
end
doTransformItem(item2.uid,eweapons[c][b],1000)
doDecayItem(item.uid)
doSendMagicEffect(fromPosition,39)
doRemoveItem(item.uid,1)
else
doPlayerSendCancel(cid,"You can't enchanted this.")
end
else
return 0
end
return 1
end

My Icy spike sword:
XML:
	<item id="7763" article="a" name="icy spike sword">
		<attribute key="weight" value="5000" />
		<attribute key="defense" value="21" />
		<attribute key="attack" value="24" />
		<attribute key="weaponType" value="sword" />
		<attribute key="extradef" value="2" />
		<attribute key="elementIce" value="4" />
		<attribute key="charges" value="1000" />
		<attribute key="decayTo" value="2383" />
		<attribute key="showcharges" value="1" />
	</item>
 
Last edited:
Do you have decayTo for them in items.xml?
Code:
	<item id="7744" article="a" name="spike sword">
		<attribute key="weight" value="5000" />
		<attribute key="defense" value="21" />
		<attribute key="attack" value="24" />
		<attribute key="weaponType" value="sword" />
		<attribute key="extradef" value="2" />
		<attribute key="elementFire" value="4" />
		<attribute key="charges" value="1000" />
[B][COLOR="red"]		<attribute key="decayTo" value="2383" />[/COLOR][/B]
		<attribute key="showcharges" value="1" />
	</item>
Because this used to work, could be a bug in 0.4
 
When charges of a weapon enchanted is over, the weapon disappears.
XML:
	<item id="7763" article="a" name="icy spike sword">
		<attribute key="weight" value="5000" />
		<attribute key="defense" value="21" />
		<attribute key="attack" value="24" />
		<attribute key="weaponType" value="sword" />
		<attribute key="extradef" value="2" />
		<attribute key="elementIce" value="4" />
		<attribute key="charges" value="1000" />
		<attribute key="decayTo" value="2383" />
		<attribute key="showcharges" value="1" />
	</item>
 
Lua:
function onUse(cid, item, fromPosition, item2, toPosition)
local gems = {2146, 2147, 2149, 2150}
local egems = {7759, 7760, 7761, 7762}
local altars = {{7508, 7509, 7510, 7511}, {7504, 7505, 7506, 7507}, {7516, 7517, 7518, 7519}, {7512, 7513, 7514, 7515}}
local weapons = {2383, 7384, 7389, 7406, 7402, 2429, 2430, 2435, 7380, 2454, 2423, 2445, 7415, 7392, 2391, 2544, 8905, 2342}
local eweapons = {{7763, 7744, 7854, 7869}, {7765, 7746, 7856, 7871}, {7770, 7751, 7861, 7876}, {7766, 7747, 7857, 7872}, {7767, 7748, 7858, 7873}, {7768, 7749, 7859, 7874}, {7769, 7750, 7860, 7875}, {7770, 7751, 7861, 7876}, {7771, 7752, 7862, 7877}, {7772, 7753, 7863, 7878}, {7773, 7754, 7864, 7879}, {7774, 7755, 7865, 7880}, {7775, 7756, 7866, 7881}, {7776, 7757, 7867, 7882}, {7777, 7758, 7868, 7883}, {7839, 7840, 7838, 7850}, {8907, 8906, 8909, 8908}, {2343, 2343, 2343, 2343}}
local type = item.type
if type == 0 then
type = 1
end
local mana = -300 * type
local soul = -2 * type
if isInArray(gems, item.itemid)== TRUE then
for aa=1, #gems do
if item.itemid == gems[aa] then
a=aa
end
end
if isInArray(altars[a], item2.itemid)== TRUE then
if getPlayerMana(cid) >= mana and getPlayerSoul(cid) >= soul then
doTransformItem(item.uid,egems[a])
doPlayerAddMana(cid,mana)
doPlayerAddSoul(cid,soul)
doSendMagicEffect(fromPosition,39)
else
doPlayerSendCancel(cid,"You dont have mana or soul points.")
end
else
return 2
end
elseif isInArray(egems, item.itemid)== TRUE then
for bb=1, #egems do
if item.itemid == egems[bb] then
b=bb
end
end
if isInArray(weapons, item2.itemid)== TRUE then
for cc=1, #weapons do
if item2.itemid == weapons[cc] then
c=cc
end
end
doTransformItem(item2.uid,eweapons[c][b],1000)
doDecayItem(item.uid)
doSendMagicEffect(fromPosition,39)
doRemoveItem(item.uid,1)
else
doPlayerSendCancel(cid,"You can't enchanted this.")
end
else
return 0
end
return 1
end
 
Last edited:
hey man, try to use mine action script, here is:

function onUse(cid, item, fromPosition, itemEx, toPosition)

--CONFIG
local config = {
mana = 300,
soul = 2,
messNotEnoughSoul = "You don't have enough soul.",
messNotEnoughMana = "You don't have enough mana.",
effect = 39 --you can test effects with !z command (ex. !z 23)
}
--/CONFIG

local array = { [7759] = 8907, [7760] = 8906, [7761] = 8909, [7762] = 8908 }
local altars = {{7516, 7517, 7518, 7519}, {7504, 7505, 7506, 7507}, {7512, 7513, 7514, 7515}, {7508, 7509, 7510, 7511}}
local gems = {2149, 2147, 2150, 2146}
local enchantedGems = {7761, 7760, 7762, 7759}

local weapons = {
-- {fire, ice, earth, energy}
[2383] = {7744, 7763, 7854, 7869},
[7383] = {7745, 7764, 7855, 7870},
[7384] = {7746, 7765, 7856, 7871},
[7406] = {7747, 7766, 7857, 7872},
[7402] = {7748, 7767, 7858, 7873},
[2429] = {7749, 7768, 7859, 7874},
[2430] = {7750, 7769, 7860, 7875},
[7389] = {7751, 7770, 7861, 7876},
[7380] = {7752, 7771, 7862, 7877},
[2454] = {7753, 7772, 7863, 7878},
[2423] = {7754, 7773, 7864, 7879},
[2445] = {7755, 7774, 7865, 7880},
[7415] = {7756, 7775, 7866, 7881},
[7392] = {7757, 7776, 7867, 7882},
[2391] = {7758, 7777, 7868, 7883},
[2544] = {7840, 7839, 7850, 7838},
[8905] = {8906, 8907, 8909, 8908},
}

if(item.itemid == 7761 and itemEx.itemid == 9949) then
doTransformItem(itemEx.uid, 9948)
doDecayItem(itemEx.uid)
doRemoveItem(item.uid, 1)
doSendMagicEffect(toPosition, CONST_ME_MAGIC_GREEN)
return true
end

if(item.itemid == 7761 and itemEx.itemid == 9954) then
doTransformItem(itemEx.uid, 9953)
doDecayItem(itemEx.uid)
doRemoveItem(item.uid, 1)
doSendMagicEffect(toPosition, CONST_ME_MAGIC_GREEN)
return true
end

if(item.itemid == 2147 and itemEx.itemid == 2342) then
doTransformItem(itemEx.uid, 2343)
doDecayItem(itemEx.uid)
doRemoveItem(item.uid, 1)
doSendMagicEffect(toPosition, CONST_ME_MAGIC_RED)
return true
end

if(item.itemid == 7760 and isInArray({9934, 10022}, itemEx.itemid)) then
doTransformItem(itemEx.uid, 9933)
doRemoveItem(item.uid, 1)
doSendMagicEffect(toPosition, CONST_ME_MAGIC_RED)
return true
end

if itemEx.itemid == 8905 and isInArray(enchantedGems, item.itemid) then
for k, v in pairs(array) do
if item.itemid == k then
doTransformItem(itemEx.uid, v)
doRemoveItem(item.uid, 1)
doSendMagicEffect(fromPosition, CONST_ME_MAGIC_BLUE)
return TRUE
end
end
elseif isInArray(gems, item.itemid) == TRUE then
for i=1, #gems do
if isInArray(altars, itemEx.itemid) == TRUE and item.itemid == gems then
if getPlayerMana(cid) >= config.mana then
if getPlayerSoul(cid) >= config.soul then
doRemoveItem(item.uid, 1)
doPlayerAddItem(cid, enchantedGems, 1)
doPlayerAddSoul(cid,-config.soul)
doPlayerAddMana(cid,-config.mana)
else
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, config.messNotEnoughSoul)
doSendMagicEffect(fromPosition, 2)
return FALSE
end
else
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, config.messNotEnoughMana)
doSendMagicEffect(fromPosition, 2)
return FALSE
end
doSendMagicEffect(toPosition, config.effect)
return TRUE
end
end

else
for k, v in pairs(weapons) do
if itemEx.itemid == k then
for i=1, #enchantedGems do
if item.itemid == enchantedGems then
doTransformItem(itemEx.uid, v, 1000)
doRemoveItem(item.uid, 1)
doSendMagicEffect(fromPosition, config.effect)
return TRUE
end
end
end
end
end
return TRUE
end
 
Back
Top