Well.. i'm trying to do a Combination System.
You put some items in certain place and press the switch and a item is created.
In my script they should be created soft boots with boots of haste, steel boots and small topaz OR a magic plate armor with a golden armor, crown armor, dragon scale mail and small topaz but.. when i put the items in the place and press the switch, the text appears: "You need to put the correct item with the requiered jewel."
here is my script:
You put some items in certain place and press the switch and a item is created.
In my script they should be created soft boots with boots of haste, steel boots and small topaz OR a magic plate armor with a golden armor, crown armor, dragon scale mail and small topaz but.. when i put the items in the place and press the switch, the text appears: "You need to put the correct item with the requiered jewel."
here is my script:
Code:
local possibleCombinations = {
[6132] = {2195, 2645, 9970},
[2472] = {2487, 2466, 2492, 9970}
}
for successfulCombination, itemNeeded in pairs(possibleCombinations) do
local config = {
enableCombinationSystem = "yes",
levelToCombine = 0,
priceToCombine = 10000,
timeBeforeResult = 3,
chanceToAFailedCombination = 30,
resultPos = {x=62, y=675, z=7},
combinationPos = {
{x=54, y=676, z=7, stackpos=1},
{x=55, y=676, z=7, stackpos=1},
{x=56, y=676, z=7, stackpos=1},
{x=54, y=677, z=7, stackpos=1},
{x=55, y=677, z=7, stackpos=1},
{x=56, y=677, z=7, stackpos=1},
{x=54, y=678, z=7, stackpos=1},
{x=55, y=678, z=7, stackpos=1},
{x=56, y=678, z=7, stackpos=1}
}
}
for i = 1, table.maxn(config.combinationPos) do
local getNeededItems = getThingFromPos(config.combinationPos[i])
function onUse(cid, item, frompos, item2, topos)
if config.enableCombinationSystem == "yes" then
if item.actionid == 15233 and item.itemid == 9825 then
if getPlayerLevel(cid) >= config.levelToCombine then
if getPlayerMoney(cid) >= config.priceToCombine then
if getNeededItems.itemid == itemNeeded then
if math.random(100) <= config.chanceToAFailedCombination then
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"Combination Failed.")
doSendMagicEffect(combinationPos[i], CONST_ME_POFF)
else
if doPlayerRemoveMoney(cid, config.priceToCombine) then
addEvent(cleanCombinationArea, (1000*config.timeBeforeResult))
addEvent(successfulCombination, (1000*config.timeBeforeResult))
doTransformItem(item.uid, item.itemid+1)
else
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"You need " .. config.priceToCombine .. " gold pieces to make a combination.")
end
end
else
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"You need to put the correct item with the requiered jewel.")
end
else
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"You need " .. config.priceToCombine .. " gold pieces to make a combination.")
end
else
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"You need level " .. config.levelToCombine .. " or more to make a combination.")
end
elseif item.actionid == 15233 and item.itemid == 9826 then
doTransformItem(item.uid, item.itemid-1)
end
end
end
end
end
function successfulCombination()
doCreateItem(successfulCombination, 1, resultPos)
doSendMagicEffect(resultPos, CONST_ME_MAGIC_GREEN)
doSendMagicEffect(config.combinationPos[i], CONST_ME_MAGIC_GREEN)
end
function cleanCombinationArea()
if getNeededItems.itemid > 0 then
doRemoveItem(getNeededItem.uid, 1)
end
end