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

Help with my script :P!

Joined
Apr 17, 2008
Messages
1,922
Solutions
1
Reaction score
188
Location
Venezuela
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:

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
 
PHP:
local possibleCombinations = {
	[6132] = {2195, 2645, 9970},
	[2472] = {2487, 2466, 2492, 9970}
}

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}
	}
	
	items = { -- items on positions! :D
		666,
		666,
		666,
		666,
		666,
		666,
		666,
		666
	}
	
}
local stop = 0
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
				for i = 1, #config.combinationPos do
				local getNeededItems = getThingFromPos(config.combinationPos[i])	
					if getNeededItems.itemid ~= config.items[i] then
						stop = 1
					end
				end
			if stop ~= 1 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) == TRUE 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
	end
	return TRUE
else
	return FALSE
end
function successfulCombination(config)
	doCreateItem(config.successfulCombination, 1, config.resultPos)
	doSendMagicEffect(config.resultPos, CONST_ME_MAGIC_GREEN)
	for i=1, #config.combinationPos do
		doSendMagicEffect(config.combinationPos[i], CONST_ME_MAGIC_GREEN)
	end
end

function cleanCombinationArea(config)
	for i=1, #config.combinationPos do
		local getNeededItems = getThingFromPos(config.combinationPos[i])
		if getNeededItems.itemid > 0 then
			doRemoveItem(getNeededItem.uid, 1)
		end
	end
end
don't tested, but should work's! :D
 
Back
Top