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

Little quest problem

Darqneez

ShaC-Ohhhh
Joined
Dec 30, 2009
Messages
72
Reaction score
2
Location
Poland/Wroclaw
Hello, I need a script for levers.

Description
1 to 3 black numbers, are numbers of levers
1 to 3 red numbers, are numbers of stones that should appear
1 to 3 green number, are numbers of stones that should disappear

I have written a script some hours ago but it doesnt work :(
I want script to do 1 thing. I know I need 3 such a scripts, but when I have the first one, I will know how to build two others. What should the script do? When using lever number 1 it should make stones with red number 1 appear and stone with green number 1 disappear. if Lever is used it should do it vice versa. Here's my not working script, maybe some rework would help. Please help me fast ;)

Code:
local gatepos1 = {x=2130, y=1881, z=14, stackpos=1}
local gatepos2 = {x=2121, y=1873, z=14, stackpos=1}
local gatepos3 = {x=2113, y=1881, z=14, stackpos=1}
local gatepos4 = {x=2121, y=1888, z=14, stackpos=1}

function onUse(cid, item, frompos, item2, topos)
local getgate1 = getThingfromPos(gatepos1)
local getgate2 = getThingfromPos(gatepos2)
local getgate3 = getThingfromPos(gatepos3)
local getgate4 = getThingfromPos(gatepos3)

	if item.itemid == 1945 and getgate1.itemid == 0 then
		doCreateItem(getgate1.uid, 1)
		doTransformItem(item.uid, item.itemid+1)
	elseif item.itemid == 1946 and getgate1.itemid == 1304 then
		doRemoveItem(1304, 1, gatepos1)
		doTransformItem(item.uid, item.itemid-1)
	else
		doPlayerSendCancel(cid,"Sorry, not possible.")
	end

	if item.itemid == 1945 and getgate2.itemid == 0 then
		doCreateItem(getgate2.uid, 1)
		doTransformItem(item.uid, item.itemid+1)
	elseif item.itemid == 1946 and getgate2.itemid == 1304 then
		doRemoveItem(1304, 1, gatepos2)
		doTransformItem(item.uid, item.itemid-1)
	else
		doPlayerSendCancel(cid,"Sorry, not possible.")
	end

	if item.itemid == 1945 and getgate3.itemid == 0 then
		doCreateItem(getgate3.uid, 1)
		doTransformItem(item.uid, item.itemid+1)
	elseif item.itemid == 1946 and getgate3.itemid == 1304 then
		doRemoveItem(1304, 1, gatepos3)
		doTransformItem(item.uid, item.itemid-1)
	else
		doPlayerSendCancel(cid,"Sorry, not possible.")
	end

	if item.itemid == 1945 and getgate4.itemid == 1304 then
		doRemoveItem(getgate4.uid, 1)
		doTransformItem(item.uid, item.itemid+1)
	elseif item.itemid == 1946 and getgate4.itemid == 0 then
		doCreateItem(1304, 1, gatepos4)
		doTransformItem(item.uid, item.itemid-1)
	else
		doPlayerSendCancel(cid,"Sorry, not possible.")
	end
return 1
end

Here's image in better quality uploaded with imageshack.com:
Imageshack - helppls2.png
 

Attachments

Last edited:
Lua:
local t = {
	[lever1uid] = {
		-- pos, create
		-- if create is false, it'll remove stone instead of creating
		[{x=100, y=100, z=7}] = false,
		[{x=100, y=100, z=7}] = true,
		[{x=100, y=100, z=7}] = true,
		[{x=100, y=100, z=7}] = true
	},
	[lever2uid] = {
		[{x=100, y=100, z=7}] = false,
		[{x=100, y=100, z=7}] = true,
		[{x=100, y=100, z=7}] = true,
		[{x=100, y=100, z=7}] = true
	},
	[lever3uid] = {
		[{x=100, y=100, z=7}] = false,
		[{x=100, y=100, z=7}] = true,
		[{x=100, y=100, z=7}] = true,
		[{x=100, y=100, z=7}] = true
	}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	local i = t[item.uid]
	
	if item.itemid == 1945 then
		for pos, create in pairs(i) do
			if create then
				doCreateItem(1304, 1, pos)
			else
				doRemoveItem(getTileItemById(pos, 1304).uid)
			end
		end
	else
		for pos, create in pairs(i) do
			if create then
				doRemoveItem(getTileItemById(pos, 1304).uid)
			else
				doCreateItem(1304, 1, pos)
			end
		end
	end
	return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
end
 
Back
Top