• 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 [Release]Enchant Weapons/Gems System

Zeriikler

New Member
Joined
Apr 14, 2008
Messages
31
Reaction score
0
Credits:
Omen -- For releasing a good base to work off of.
Zeriikler -- Making it work 100%


Lets start with the movements first.

Put this in your data>movements>scripts
enchant_gems.lua

Code:
function onStepIn(cid, item, pos)

--Config-->
local tele = {x=XXXX, y=YYYY, z=ZZZZ} --Where they will be teleported after they sucessfully walk on alter
local druid = "Only premium Druids of level 30 or higher are able to pass through here." --If they aren't a druid with Premium & level 30+
local sorcerer = "Only premium Sorcerers of level 30 or higher are able to pass through here." --If they aren't a sorcerer with Premium & level 30+
local not_enough_gem = "You need at least 1 or more gems to pass." --What it will say if they don't have no gems.
local action1 = 7801 --The action.id for small sapphire alter
local action2 = 7802 --The action.id for small emerald alter
local action3 = 7803 --The action.id for small ruby alter
local action4 = 7804 --The action.id for small amethysts alter
local effect = 10 --The effect when they get teleported (Default is 10)
--End Config-->

--Do not touch this--
if getPlayerLookDir(cid) == 0 then
    newdir = 2
elseif getPlayerLookDir(cid) == 1 then
    newdir = 3
elseif getPlayerLookDir(cid) == 2 then
    newdir = 0
else
    newdir = 1
end

--Don't edit this unless you know what you are doing.

if item.actionid == action1 then
--Small Sapphires
            if getPlayerVocation(cid) == 2 or getPlayerVocation(cid) == 6 and getPlayerLevel(cid) >= 30 and isPremium(cid) == TRUE then
                if getPlayerItemCount(cid,2146) ~= 0 then
                    doTeleportThing(cid,tele)
                    doPlayerTakeItem(cid,2146,1)
                    doPlayerAddItem(cid,7759,1)
                    doSendMagicEffect(tele,effect)
                elseif getPlayerItemCount(cid,2146) == 0 then
                    doMoveCreature(cid, newdir)
                    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, not_enough_gem)
                end
            else
                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, druid)
                doMoveCreature(cid, newdir)
            end
--Small Emeralds
            elseif item.actionid == action2 then
                if getPlayerVocation(cid) == 2 or getPlayerVocation(cid) == 6 and getPlayerLevel(cid) >= 30 and isPremium(cid) == TRUE then
                    if getPlayerItemCount(cid,2149) ~= 0 then
                        doTeleportThing(cid,tele)
                        doPlayerTakeItem(cid,2149,1)
                        doPlayerAddItem(cid,7761,1)
                        doSendMagicEffect(tele,effect)
                    elseif getPlayerItemCount(cid,2149) == 0 then
                        doMoveCreature(cid, newdir)
                        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, not_enough_gem)
                    end
                else
                    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, druid)
                    doMoveCreature(cid, newdir)
                end
--Small Rubies
            elseif item.actionid == action3 then
                if getPlayerVocation(cid) == 1 or getPlayerVocation(cid) == 5 and getPlayerLevel(cid) >= 30 and isPremium(cid) == TRUE then
                    if getPlayerItemCount(cid,2147) ~= 0 then
                        doTeleportThing(cid,tele)
                        doPlayerTakeItem(cid,2147,1)
                        doPlayerAddItem(cid,7760,1)
                        doSendMagicEffect(tele,effect)
                    elseif getPlayerItemCount(cid,2147) == 0 then
                        doMoveCreature(cid, newdir)
                        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, not_enough_gem)
                    end
                else
                    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, sorcerer)
                    doMoveCreature(cid, newdir)
                end
--Small Amethysts
            elseif item.actionid == action4 then
                if getPlayerVocation(cid) == 1 or getPlayerVocation(cid) == 5 and getPlayerLevel(cid) >= 30 and isPremium(cid) == TRUE then
                    if getPlayerItemCount(cid,2150) ~= 0 then
                        doTeleportThing(cid,tele)
                        doPlayerTakeItem(cid,2150,1)
                        doPlayerAddItem(cid,7762,1)
                        doSendMagicEffect(tele,effect)
                    elseif getPlayerItemCount(cid,2150) == 0 then
                        doMoveCreature(cid, newdir)
                        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, not_enough_gem)
                    end
                else
                    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, sorcerer)
                    doMoveCreature(cid, newdir)
                end
            end
    return 1
end
Now for the action..
data>actions>scripts
enchant_weapons.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, 7406, 7402, 2429, 2430, 2435, 7380, 2454, 2423, 2445, 7415, 7392, 2391, 2544}
                    --Ice        Fire       Earth     Energy
local eweapons = {{7763, 7744, 7854, 7869}, {7765, 7746, 7856, 7871}, {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}}
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 1
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,"Sorry, not possible.")
            end
        else
            return 0
        end
    return 1
end
Now put this in movements.xml
Code:
<!--Enchanting Gems Script-->
    <movevent event="StepIn" actionid="7801" script="enchant_gems.lua" />
    <movevent event="StepIn" actionid="7802" script="enchant_gems.lua" />
    <movevent event="StepIn" actionid="7803" script="enchant_gems.lua" />
    <movevent event="StepIn" actionid="7804" script="enchant_gems.lua" />
Put this in actions.xml
Code:
<!--Enchant Weapons-->
    <action fromid="2146" toid="2147" script="enchant_weapons.lua" />
    <action fromid="2149" toid="2150" script="enchant_weapons.lua" />
    <action fromid="7759" toid="7762" script="enchant_weapons.lua" />

You can edit it to make it 100% like real tibia. But.. It's a lot better this way(IMO).
Comments plix? :)

Rep? :)
 
Last edited by a moderator:
Well I liked your script, it was very useful to me. I will modify it so it becomes like Real Tibia's.
 
when im enchanting 1 arrow it gives 100 enchanted arrows :/ and error in console:

LuaDoTransformItem<>. Stack count cannot be higher than 100.
 
if u are right it's not so funny :>
so everyone who use newest tfs have same problem not only me..
Any clue how to fix it?:p
 
only remove the arrow enchant part..
Code:
local weapons = {2383, 7384, 7406, 7402, 2429, 2430, 2435, 7380, 2454, 2423, 2445, 7415, 7392, 2391[COLOR=Red], 2544[/COLOR]}
Code:
local eweapons = {{7763, 7744, 7854, 7869}, {7765, 7746, 7856, 7871}, {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}[COLOR=Red], {7839, 7840, 7838, 7850}[/COLOR]}
 
How to enchant gems ?:p
Im use that script but shrines dont enchant gems so what im must to do? ;( pls help...

btw if u need past "teleport" like in rl tibia what id that it have in map editor?:p


thx..and sorry for my english :)
 
Last edited:
Back
Top