• 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!

Action [8.4] Enchant system (with rainbow shield)

Keraxel

Ω Obfuscator Ω
Joined
Feb 2, 2008
Messages
941
Reaction score
5
Location
Republic of Poland
I was write this code cause I didn't found it on any forum.
So... let's start.

enchant.lua
PHP:
--by Keraxel 
function onUse(cid, item, fromPosition, itemEx, toPosition) 

--CONFIG 
local config = { 
mana = 300, 
soul = 2, 
messNotEnoughSoul = "You don't have enough soul points.", 
messNotEnoughMana = "You don't have enough mana points.", 
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 = { 
    -- {earth, fire, energy, ice} 
    [2430] = {7860, 7750, 7875, 7769}, 
    [2423] = {7864, 7754, 7879, 7773}, 
    [7406] = {7857, 7747, 7872, 7766}, 
    [7383] = {7855, 7745, 7870, 7764}, 
    [7384] = {7856, 7746, 7871, 7765}, 
    [7415] = {7866, 7756, 7881, 7775}, 
    [7380] = {7862, 7752, 7877, 7771}, 
    [7402] = {7858, 7784, 7873, 7767}, 
    [2391] = {7868, 7758, 7883, 7777}, 
    [7389] = {7861, 7751, 7876, 7770}, 
    [2383] = {7854, 7744, 7869, 7763}, 
    [7392] = {7867, 7757, 7882, 7776}, 
    [2429] = {7859, 7749, 7874, 7768}, 
    [2445] = {7865, 7755, 7880, 7774}, 
    [2454] = {7863, 7753, 7878, 7772} 
} 
     
         
        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, config.effect) 
                    return TRUE 
                end 
            end 
        elseif isInArray(gems, item.itemid) == TRUE then 
            for i=1, #gems do 
                if isInArray(altars[i], itemEx.itemid) == TRUE and item.itemid == gems[i] then 
                    if getPlayerMana(cid) >= config.mana then 
                        if getPlayerSoul(cid) >= config.soul then
                            doRemoveItem(item.uid, 1) 
                            doPlayerAddItem(cid, enchantedGems[i], 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[i] then 
                            doTransformItem(itemEx.uid, v[i], 1000) 
                            doRemoveItem(item.uid, 1) 
                            doSendMagicEffect(fromPosition, config.effect) 
                            return TRUE 
                        end 
                    end 
                end 
            end     
        end 
    return TRUE 
end

actions.xml
Code:
<action itemid="7759" script="enchant.lua"/>
<action itemid="7760" script="enchant.lua"/>
<action itemid="7761" script="enchant.lua"/>
<action itemid="7762" script="enchant.lua"/>
<action itemid="2150" script="enchant.lua"/>
<action itemid="2149" script="enchant.lua"/>
<action itemid="2146" script="enchant.lua"/>
<action itemid="2147" script="enchant.lua"/>

How it works?
When you will use enchanted gem on weapons wchich can be enchanted/rainbow shield it will change to enchaned weapon or terran/fiery/sparkling/icy rainbow shield.

If you see any bug post message in this topic. You can also spend some rep points :)

[12/29/2008]Patch 1: Correct creating weapons with 1000 charges.
[12/29/2008]Patch 2: Added config and enchanting normal gems with altars.

Regards,
Keraxel.
 
Last edited:
I was write this code cause I didn't found it on any forum.
So... let's start.

enchant.lua
Code:
--by Keraxel
function onUse(cid, item, fromPosition, itemEx, toPosition)
local array = { [7759] = 8907, [7760] = 8906, [7761] = 8909, [7762] = 8908 }
local gems = {7761, 7760, 7762, 7759}
local weapons = {
    [2430] = {7860, 7750, 7875, 7769},
    [2423] = {7864, 7754, 7879, 7773},
    [7406] = {7857, 7747, 7872, 7766},
    [7383] = {7855, 7745, 7870, 7764},
    [7384] = {7856, 7746, 7871, 7765},
    [7415] = {7866, 7756, 7881, 7775},
    [7380] = {7862, 7752, 7877, 7771},
    [7402] = {7858, 7784, 7873, 7767},
    [2391] = {7868, 7758, 7883, 7777},
    [7389] = {7861, 7751, 7876, 7770},
    [2383] = {7854, 7744, 7869, 7763},
    [7392] = {7867, 7757, 7882, 7776},
    [2429] = {7859, 7749, 7874, 7768},
    [2445] = {7865, 7755, 7880, 7774},
    [2454] = {7863, 7753, 7878, 7772}
}
	if itemEx.itemid == 8905 then
		for k, v in pairs(array) do
			if item.itemid == k then
				doTransformItem(itemEx.uid, v)
				doChangeTypeItem(item.uid, item.type - 1)
				return TRUE
			end
		end
	else
		for k, v in pairs(weapons) do
			if itemEx.itemid == k then
				for i=1, #gems do
					if item.itemid == gems[i] then
						doTransformItem(itemEx.uid, v[i])
						doChangeTypeItem(item.uid, item.type - 1)
						return TRUE
					end
				end
			end
		end	

	end
	return TRUE
end

actions.xml
Code:
<action itemid="7759" script="enchant.lua"/>
<action itemid="7760" script="enchant.lua"/>
<action itemid="7761" script="enchant.lua"/>
<action itemid="7762" script="enchant.lua"/>

How it works?
When you will use enchanted gem on weapons wchich can be enchanted/rainbow shield it will change to enchaned weapon or terran/fiery/sparkling/icy rainbow shield.

If you see any bug post message in this topic. You can also spend some rep points :)

Regards,
Keraxel.

edit: Can any moderator change topic name to "[Action] Enchant weapons & rainbow shield" ? ;p

actually i have an script that enchants gems and weapons with a set amount of charges in this case 1000. and also enchants the raimbow shield

enchant.lua
Code:
function onUse(cid, item, frompos, item2, topos)

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}
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}}


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(frompos,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)
doSendMagicEffect(frompos,39)
doRemoveItem(item.uid,1)
else
doPlayerSendCancel(cid,"You can't enchanted this.")
end
else
return 0
end
return 1
end

actions.xml
Code:
<action itemid="2146" script="enchant.lua" />
<action itemid="2147" script="enchant.lua" />
<action itemid="2150" script="enchant.lua" />
<action itemid="2149" script="enchant.lua" />

<action itemid="7759" script="enchant.lua" />
<action itemid="7760" script="enchant.lua" />
<action itemid="7761" script="enchant.lua" />
<action itemid="7762" script="enchant.lua" />

are beta 2 dont have enchanting in engine?:>

yes the forgotten server 0.3 b2 does support enchanting engine.
 
Last edited:
actually i have an script that enchants gems and weapons with a set amount of charges in this case 1000. and also enchants the raimbow shield

enchant.lua
Code:
--by Richi~ --
function onUse(cid, item, frompos, item2, topos)

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}
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}}


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(frompos,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)
doSendMagicEffect(frompos,39)
doRemoveItem(item.uid,1)
else
doPlayerSendCancel(cid,"You can't enchanted this.")
end
else
return 0
end
return 1
end

actions.xml
Code:
<action itemid="2146" script="enchant.lua" />
<action itemid="2147" script="enchant.lua" />
<action itemid="2150" script="enchant.lua" />
<action itemid="2149" script="enchant.lua" />

<action itemid="7759" script="enchant.lua" />
<action itemid="7760" script="enchant.lua" />
<action itemid="7761" script="enchant.lua" />
<action itemid="7762" script="enchant.lua" />



yes the forgotten server 0.3 b2 does support enchanting engine.

I didn't found enchant engine in beta 2 so I wrote it myself. I think my code is cleaner than yours.
 
Last edited:
I didn't found enchant engine in beta 2 so I wrote it myself. I think my code is cleaner than yours.

i know but mine does the gems in the altar + enchanting the items in the same script and gives the 1000 charges in the enchanted weapons.

i only posted my script because not everybody has the altars enchanting the gems and also fixed the bug of the charges of the enchanted weapons.
 
Mine too :) Check it before posting :D
Btw. this script itn't yours, I saw them about one year ago on other forum.
 
Last edited:
Mine too :) Check it before posting :D
Btw. this script itn't yours, I saw them about one year ago on other forum.

your right and i did check your script that why i posted mine your right about my script but i forgot whos credits are and i added the rainbow shield, and the 1000 charges. so i will edit the script
 
I was meant your last post :) We shouldn't start flaming here, so end of this topic.

If You see any bug or wrong preformance of script just reply in this topic.
 
It works to enchant, but the charges doesnt run out O,o

Using latest TFS (0.3.1)
 
Charges of what? Weapon? It's not my fault :/

Like when I enchant a spikesword with ice. It gets 1000 charges. Even if I hit something like a thousand times. It still stays at 1000 xD
 
Hey Buddy, There is a bug in code ;)

there is:

PHP:
if isInArray(altars[i], itemEx.itemid) == TRUE and item.itemid == gems[i] then 
                    doRemoveItem(item.uid, 1) 
                    doPlayerAddItem(cid, enchantedGems[i], 1) 
                    if getPlayerMana(cid) >= config.mana then 
                        if getPlayerSoul(cid) >= config.soul then 
                            doPlayerAddSoul(cid,-config.soul) 
                            doPlayerAddMana(cid,-config.mana) 
                        else ....

This is enchanting even if u don't have a soul points or mana.

it should look like that;

PHP:
                if isInArray(altars[i], itemEx.itemid) == TRUE and item.itemid == gems[i] then  
                    if getPlayerMana(cid) >= config.mana then 
                        if getPlayerSoul(cid) >= config.soul then 
                    doRemoveItem(item.uid, 1) 
                    doPlayerAddItem(cid, enchantedGems[i], 1)
                            doPlayerAddSoul(cid,-config.soul) 
                            doPlayerAddMana(cid,-config.mana) 
                        else 
                            ....

Litte Bug ;)
 
Those lines was already in constant.lua -.-
Code:
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}
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}}

so it'll be better to use those.
 
Hey Buddy, There is a bug in code ;)

there is:

PHP:
if isInArray(altars[i], itemEx.itemid) == TRUE and item.itemid == gems[i] then 
                    doRemoveItem(item.uid, 1) 
                    doPlayerAddItem(cid, enchantedGems[i], 1) 
                    if getPlayerMana(cid) >= config.mana then 
                        if getPlayerSoul(cid) >= config.soul then 
                            doPlayerAddSoul(cid,-config.soul) 
                            doPlayerAddMana(cid,-config.mana) 
                        else ....

This is enchanting even if u don't have a soul points or mana.

it should look like that;

PHP:
                if isInArray(altars[i], itemEx.itemid) == TRUE and item.itemid == gems[i] then  
                    if getPlayerMana(cid) >= config.mana then 
                        if getPlayerSoul(cid) >= config.soul then 
                    doRemoveItem(item.uid, 1) 
                    doPlayerAddItem(cid, enchantedGems[i], 1)
                            doPlayerAddSoul(cid,-config.soul) 
                            doPlayerAddMana(cid,-config.mana) 
                        else 
                            ....

Litte Bug ;)

I'm wondering that I didn't fix that yet o_O

As I said before. I'm using the latest TFS 0.3.1 cryingblablabla
^^
Aaah I didn't notice that. I don't know why because charges works perfectly for me (the same distro).

Those lines was already in constant.lua -.-
Code:
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}
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}}

so it'll be better to use those.

I know about it but I haven't time for repair it ;) It's not big issue.
 
Back
Top