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

Machine Problem

Bulet

Knight of Apocalypse
Joined
Jul 12, 2009
Messages
183
Reaction score
9
Location
Brazil
I need know if have a way to use Enchant jewel on item with a actionid to that perform a action, but i had enchant system on scripts thats is mine problem for now i try use getThingfromPos but any one cant work. Plx i need help

I use that on Elemental Spheres Quest machine
the red lines is on are the problem now

Code:
--by Keraxel Updated by Bullet
function onUse(cid, item, fromPosition, itemEx, toPosition) 

--CONFIG 
local config = { 
-- ELEMENTAL SPHERES QUEST CONFIG
machUID = 1400,  
machStorage = 1400,
arkStorage = 1401,
overStorage = 1402,
emachAID = 1403,
emachStorage = 1403,  
lordStorage = 1404,
switch1floorUID = 1405,
switch2floorUID = 1406,
teleportUID = 1407,
PallyPos = {x=33262, y=32201, z=13},  
SorcerPos = {x=33180, y=32198, z=13},  
DruidPos = {x=33329, y=32075, z=13},  
KninaPos = {x=33086, y=32094, z=13},  
messNotGem = "You can't have enchanted gem for you profession.", 
messNotArk = "You can't proceed, go back and talk with Arkulius.", 
-- ELEMENTAL SPHERES QUEST CONFIG END
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 machpos1 = {x=33268, y=31830, z=10, stackpos=1}
local machpos2 = {x=33269, y=31830, z=10, stackpos=1}
local getmach1 = getThingfromPos(machpos1)
local getmach2 = getThingfromPos(machpos2)
local machUSE = getPlayerStorageValue(cid, config.machStorage)
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 = {7760, 7759, 7761, 7762}

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

-- ELEMENTAL SPHERES QUEST SCRIPTS

[COLOR="Red"]    if item.aid == config.machUID and machUSE == -1 then[/COLOR]
	     doPlayerSendCancel(cid,config.messNotArk)
    elseif machUSE >= 1 then
[COLOR="Red"]    if(isPaladin(cid) and item.itemid == 7759 and item.aid == config.machUID)  then[/COLOR]
		 doRemoveItem(item.uid, 1)
         doSendMagicEffect(toPosition, 11) 
		 setPlayerStorageValue(cid, config.machStorage, machUSE + 1)
[COLOR="Red"]    elseif(isSorcerer(cid) and item.itemid == 7760 and item.aid == config.machUID)  then	[/COLOR]	 
		 doRemoveItem(item.uid, 1)
         doSendMagicEffect(toPosition, 11) 
		 setPlayerStorageValue(cid, config.machStorage, machUSE + 1)
[COLOR="Red"]    elseif(isDruid(cid) and item.itemid == 7761 and item.aid == config.machUID)  then	[/COLOR]	 
		 doRemoveItem(item.uid, 1)
         doSendMagicEffect(toPosition, 11) 
		 setPlayerStorageValue(cid, config.machStorage, machUSE + 1)
[COLOR="Red"]    elseif(isKnight(cid) and item.itemid == 7762 or item.aid == config.machUID)  then[/COLOR]
		 doRemoveItem(item.uid, 1)
         doSendMagicEffect(toPosition, 11) 
		 setPlayerStorageValue(cid, config.machStorage, machUSE + 1)
         return TRUE 
     end 
	elseif machUSE == 21 then
[COLOR="Red"]		 if(isPaladin(cid) and item.uid == config.machUID)  then[/COLOR]
		 doTeleportThing(cid, config.PallyPos)
		 doSendMagicEffect(fromPosition, 10)
		 setPlayerStorageValue(cid, config.machStorage, machUSE - 20)
[COLOR="Red"]         elseif(isSorcerer(cid) and item.uid == config.machUID)  then[/COLOR]		
		 doTeleportThing(cid, config.SorcerPos)
		 doSendMagicEffect(fromPosition, 10)
		 setPlayerStorageValue(cid, config.machStorage, machUSE - 20)
[COLOR="Red"]         elseif(isDruid(cid) and item.uid == config.machUID)  then	[/COLOR]
		 doTeleportThing(cid, config.DruidPos)
		 doSendMagicEffect(fromPosition, 10)
		 setPlayerStorageValue(cid, config.machStorage, machUSE - 20)
[COLOR="Red"]         elseif(isKnight(cid) and item.uid == config.machUID)  then[/COLOR]
		 doTeleportThing(cid, config.KninaPos)
		 doSendMagicEffect(fromPosition, 10)
		 setPlayerStorageValue(cid, config.machStorage, machUSE - 20)		 
	else
	 doPlayerSendCancel(cid,config.messNotGem)
	 end
		 end
-- ELEMENTAL SPHERES QUEST SCRIPTS END

     
    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_RED)
		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_RED)
		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, 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
 
Last edited:
Back
Top