• 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] Lever to open/close Gate

sebas182

New Member
Joined
Aug 10, 2008
Messages
121
Reaction score
1
It's a script to open and close the castle's gate... Only Gods may have acess, I tried to make a script but it's not working, someone may help me?


Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if (getPlayerStorageValue(cid, 37000) < 1) then
		doCreateItem(1547, 1, {x = 1964, y = 1984, z = 7})
		doCreateItem(1547, 1, {x = 1965, y = 1984, z = 7})
		doCreateItem(1547, 1, {x = 1966, y = 1984, z = 7})
		doCreateItem(1547, 1, {x = 1967, y = 1984, z = 7})
		doCreateItem(1547, 1, {x = 1968, y = 1984, z = 7})
		doCreateItem(1547, 1, {x = 1969, y = 1984, z = 7})
		doCreateItem(1547, 1, {x = 1970, y = 1984, z = 7})
		local i1 = getThingFromPos({x = 1964, y = 1984, z = 5}, 1547)
		local i2 = getThingFromPos({x = 1965, y = 1984, z = 5}, 1547)
		local i3 = getThingFromPos({x = 1966, y = 1984, z = 5}, 1547)
		local i4 = getThingFromPos({x = 1967, y = 1984, z = 5}, 1547)
		local i5 = getThingFromPos({x = 1968, y = 1984, z = 5}, 1547)
		local i6 = getThingFromPos({x = 1969, y = 1984, z = 5}, 1547)
		local i7 = getThingFromPos({x = 1970, y = 1984, z = 5}, 1547)
		local i8 = getThingFromPos({x = 1971, y = 1984, z = 5}, 1547)
		doRemoveItem(i1)
		doRemoveItem(i2)
		doRemoveItem(i3)
		doRemoveItem(i4)
		doRemoveItem(i5)
		doRemoveItem(i6)
		doRemoveItem(i7)
		doRemoveItem(i8)
		setPlayerStorageValue(37000, 1)
		return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
	else
		doCreateItem(1547, 1, {x = 1964, y = 1984, z = 5})
		doCreateItem(1547, 1, {x = 1965, y = 1984, z = 5})
		doCreateItem(1547, 1, {x = 1966, y = 1984, z = 5})
		doCreateItem(1547, 1, {x = 1967, y = 1984, z = 5})
		doCreateItem(1547, 1, {x = 1968, y = 1984, z = 5})
		doCreateItem(1547, 1, {x = 1969, y = 1984, z = 5})
		doCreateItem(1547, 1, {x = 1970, y = 1984, z = 5})
		local a1 = getThingFromPos({x = 1964, y = 1984, z = 7}, 1547)
		local a2 = getThingFromPos({x = 1965, y = 1984, z = 7}, 1547)
		local a3 = getThingFromPos({x = 1966, y = 1984, z = 7}, 1547)
		local a4 = getThingFromPos({x = 1967, y = 1984, z = 7}, 1547)
		local a5 = getThingFromPos({x = 1968, y = 1984, z = 7}, 1547)
		local a6 = getThingFromPos({x = 1969, y = 1984, z = 7}, 1547)
		local a7 = getThingFromPos({x = 1970, y = 1984, z = 7}, 1547)
		doRemoveItem(a1)
		doRemoveItem(a2)
		doRemoveItem(a3)
		doRemoveItem(a4)
		doRemoveItem(a5)
		doRemoveItem(a6)
		doRemoveItem(a7)
		return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
	end
end

I dont know what I will do to "check if gate is closed" =\

Must I use doRelocate(pos, toPos[, creatures = true])???

Please help
 
mayby that:
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
if getPlayerStorageValue(cid, 37000) == 1 then
	if item.itemid == 1945 then
		doCreateItem(1547, 1, {x = 1964, y = 1984, z = 7})
		doCreateItem(1547, 1, {x = 1965, y = 1984, z = 7})
		doCreateItem(1547, 1, {x = 1966, y = 1984, z = 7})
		doCreateItem(1547, 1, {x = 1967, y = 1984, z = 7})
		doCreateItem(1547, 1, {x = 1968, y = 1984, z = 7})
		doCreateItem(1547, 1, {x = 1969, y = 1984, z = 7})
		doCreateItem(1547, 1, {x = 1970, y = 1984, z = 7})
		local i1 = getThingFromPos({x = 1964, y = 1984, z = 5}, 1547)
		local i2 = getThingFromPos({x = 1965, y = 1984, z = 5}, 1547)
		local i3 = getThingFromPos({x = 1966, y = 1984, z = 5}, 1547)
		local i4 = getThingFromPos({x = 1967, y = 1984, z = 5}, 1547)
		local i5 = getThingFromPos({x = 1968, y = 1984, z = 5}, 1547)
		local i6 = getThingFromPos({x = 1969, y = 1984, z = 5}, 1547)
		local i7 = getThingFromPos({x = 1970, y = 1984, z = 5}, 1547)
		local i8 = getThingFromPos({x = 1971, y = 1984, z = 5}, 1547)
		doRemoveItem(i1)
		doRemoveItem(i2)
		doRemoveItem(i3)
		doRemoveItem(i4)
		doRemoveItem(i5)
		doRemoveItem(i6)
		doRemoveItem(i7)
		doRemoveItem(i8)
		return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
	else
		doCreateItem(1547, 1, {x = 1964, y = 1984, z = 5})
		doCreateItem(1547, 1, {x = 1965, y = 1984, z = 5})
		doCreateItem(1547, 1, {x = 1966, y = 1984, z = 5})
		doCreateItem(1547, 1, {x = 1967, y = 1984, z = 5})
		doCreateItem(1547, 1, {x = 1968, y = 1984, z = 5})
		doCreateItem(1547, 1, {x = 1969, y = 1984, z = 5})
		doCreateItem(1547, 1, {x = 1970, y = 1984, z = 5})
		local a1 = getThingFromPos({x = 1964, y = 1984, z = 7}, 1547)
		local a2 = getThingFromPos({x = 1965, y = 1984, z = 7}, 1547)
		local a3 = getThingFromPos({x = 1966, y = 1984, z = 7}, 1547)
		local a4 = getThingFromPos({x = 1967, y = 1984, z = 7}, 1547)
		local a5 = getThingFromPos({x = 1968, y = 1984, z = 7}, 1547)
		local a6 = getThingFromPos({x = 1969, y = 1984, z = 7}, 1547)
		local a7 = getThingFromPos({x = 1970, y = 1984, z = 7}, 1547)
		doRemoveItem(a1)
		doRemoveItem(a2)
		doRemoveItem(a3)
		doRemoveItem(a4)
		doRemoveItem(a5)
		doRemoveItem(a6)
		doRemoveItem(a7)
		return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
	end
end
end

and why you dont use
Code:
local cofig ={
{x = 1964, y = 1984, z = 7},
{x = 1964, y = 1984, z = 7},
.
.
}

and in function:
Code:
for _, pos in ipairs(config) do
doCreateItem(1547, 1, pos)
end
 
Lua:
local positions = {
	{x=1964, y=1984, z=7},
	{x=1965, y=1984, z=7},
	{x=1966, y=1984, z=7},
	{x=1967, y=1984, z=7},
	{x=1968, y=1984, z=7},
	{x=1969, y=1984, z=7},
	{x=1970, y=1984, z=7}
}
local gateId = 1547
local storage = 11111

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if getPlayerStorageValue(cid, storage) == 1 then
		if item.itemid == 1945 then
			for _, pos in ipairs(positions) do
				doCreateItem(gateId, pos)
				pos.z = 5
				if getThingFromPos(pos).itemid == gateId then
					doRemoveItem(getThingFromPos(pos).uid)
				end
			end
			return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
		else
			for _, pos in ipairs(positions) do
				if getThingFromPos(pos).itemid == gateId then
					doRemoveItem(getThingFromPos(pos).uid)
				end
				pos.z = 5
				doCreateItem(gateId, pos)
			end
			return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
		end
	end
	return true
end

no tested
 
Last edited:
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
if getPlayerStorageValue(cid, 37000) == 1 then
	if item.itemid == 1945 then
		doCreateItem(1547, 1, {x = 1964, y = 1984, z = 7})
		doCreateItem(1547, 1, {x = 1965, y = 1984, z = 7})
		doCreateItem(1547, 1, {x = 1966, y = 1984, z = 7})
		doCreateItem(1547, 1, {x = 1967, y = 1984, z = 7})
		doCreateItem(1547, 1, {x = 1968, y = 1984, z = 7})
		doCreateItem(1547, 1, {x = 1969, y = 1984, z = 7})
		doCreateItem(1547, 1, {x = 1970, y = 1984, z = 7})
		local i1 = getTileItemById({x = 1964, y = 1984, z = 5}, 1547).uid
		local i2 = getTileItemById({x = 1965, y = 1984, z = 5}, 1547).uid
		local i3 = getTileItemById({x = 1966, y = 1984, z = 5}, 1547).uid
		local i4 = getTileItemById({x = 1967, y = 1984, z = 5}, 1547).uid
		local i5 = getTileItemById({x = 1968, y = 1984, z = 5}, 1547).uid
		local i6 = getTileItemById({x = 1969, y = 1984, z = 5}, 1547).uid
		local i7 = getTileItemById({x = 1970, y = 1984, z = 5}, 1547).uid
		local i8 = getTileItemById({x = 1971, y = 1984, z = 5}, 1547).uid
		doRemoveItem(i1)
		doRemoveItem(i2)
		doRemoveItem(i3)
		doRemoveItem(i4)
		doRemoveItem(i5)
		doRemoveItem(i6)
		doRemoveItem(i7)
		doRemoveItem(i8)
		return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
	else
		doCreateItem(1547, 1, {x = 1964, y = 1984, z = 5})
		doCreateItem(1547, 1, {x = 1965, y = 1984, z = 5})
		doCreateItem(1547, 1, {x = 1966, y = 1984, z = 5})
		doCreateItem(1547, 1, {x = 1967, y = 1984, z = 5})
		doCreateItem(1547, 1, {x = 1968, y = 1984, z = 5})
		doCreateItem(1547, 1, {x = 1969, y = 1984, z = 5})
		doCreateItem(1547, 1, {x = 1970, y = 1984, z = 5})
		local a1 = getTileItemById({x = 1964, y = 1984, z = 7}, 1547).uid
		local a2 = getTileItemById({x = 1965, y = 1984, z = 7}, 1547).uid
		local a3 = getTileItemById({x = 1966, y = 1984, z = 7}, 1547).uid
		local a4 = getTileItemById({x = 1967, y = 1984, z = 7}, 1547).uid
		local a5 = getTileItemById({x = 1968, y = 1984, z = 7}, 1547).uid
		local a6 = getTileItemById({x = 1969, y = 1984, z = 7}, 1547).uid
		local a7 = getTileItemById({x = 1970, y = 1984, z = 7}, 1547).uid
		doRemoveItem(a1)
		doRemoveItem(a2)
		doRemoveItem(a3)
		doRemoveItem(a4)
		doRemoveItem(a5)
		doRemoveItem(a6)
		doRemoveItem(a7)
		return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
	end
end
end
 
Lua:
local positions = {
	{x=1964, y=1984, z=7},
	{x=1965, y=1984, z=7},
	{x=1966, y=1984, z=7},
	{x=1967, y=1984, z=7},
	{x=1968, y=1984, z=7},
	{x=1969, y=1984, z=7},
	{x=1970, y=1984, z=7}
}
local gateId = 1547
local storage = 11111

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if getPlayerStorageValue(cid, storage) == 1 then
		if item.itemid == 1945 then
			for _, pos in ipairs(positions) do
				doCreateItem(gateId, pos)
				pos.z = 5
				if getThingFromPos(pos).itemid == gateId then
					doRemoveItem(getThingFromPos(pos).uid)
				end
			end
			return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
		else
			for _, pos in ipairs(positions) do
				if getThingFromPos(pos).itemid == gateId then
					doRemoveItem(getThingFromPos(pos).uid)
				end
				pos.z = 5
				doCreateItem(gateId, pos)
			end
			return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
		end
	end
	return true
end

no tested

The gate close but does not open...

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
if getPlayerStorageValue(cid, 37000) == 1 then
	if item.itemid == 1945 then
		doCreateItem(1547, 1, {x = 1964, y = 1984, z = 7})
		doCreateItem(1547, 1, {x = 1965, y = 1984, z = 7})
		doCreateItem(1547, 1, {x = 1966, y = 1984, z = 7})
		doCreateItem(1547, 1, {x = 1967, y = 1984, z = 7})
		doCreateItem(1547, 1, {x = 1968, y = 1984, z = 7})
		doCreateItem(1547, 1, {x = 1969, y = 1984, z = 7})
		doCreateItem(1547, 1, {x = 1970, y = 1984, z = 7})
		local i1 = getTileItemById({x = 1964, y = 1984, z = 5}, 1547).uid
		local i2 = getTileItemById({x = 1965, y = 1984, z = 5}, 1547).uid
		local i3 = getTileItemById({x = 1966, y = 1984, z = 5}, 1547).uid
		local i4 = getTileItemById({x = 1967, y = 1984, z = 5}, 1547).uid
		local i5 = getTileItemById({x = 1968, y = 1984, z = 5}, 1547).uid
		local i6 = getTileItemById({x = 1969, y = 1984, z = 5}, 1547).uid
		local i7 = getTileItemById({x = 1970, y = 1984, z = 5}, 1547).uid
		local i8 = getTileItemById({x = 1971, y = 1984, z = 5}, 1547).uid
		doRemoveItem(i1)
		doRemoveItem(i2)
		doRemoveItem(i3)
		doRemoveItem(i4)
		doRemoveItem(i5)
		doRemoveItem(i6)
		doRemoveItem(i7)
		doRemoveItem(i8)
		return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
	else
		doCreateItem(1547, 1, {x = 1964, y = 1984, z = 5})
		doCreateItem(1547, 1, {x = 1965, y = 1984, z = 5})
		doCreateItem(1547, 1, {x = 1966, y = 1984, z = 5})
		doCreateItem(1547, 1, {x = 1967, y = 1984, z = 5})
		doCreateItem(1547, 1, {x = 1968, y = 1984, z = 5})
		doCreateItem(1547, 1, {x = 1969, y = 1984, z = 5})
		doCreateItem(1547, 1, {x = 1970, y = 1984, z = 5})
		local a1 = getTileItemById({x = 1964, y = 1984, z = 7}, 1547).uid
		local a2 = getTileItemById({x = 1965, y = 1984, z = 7}, 1547).uid
		local a3 = getTileItemById({x = 1966, y = 1984, z = 7}, 1547).uid
		local a4 = getTileItemById({x = 1967, y = 1984, z = 7}, 1547).uid
		local a5 = getTileItemById({x = 1968, y = 1984, z = 7}, 1547).uid
		local a6 = getTileItemById({x = 1969, y = 1984, z = 7}, 1547).uid
		local a7 = getTileItemById({x = 1970, y = 1984, z = 7}, 1547).uid
		doRemoveItem(a1)
		doRemoveItem(a2)
		doRemoveItem(a3)
		doRemoveItem(a4)
		doRemoveItem(a5)
		doRemoveItem(a6)
		doRemoveItem(a7)
		return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
	end
end
end

Not working...


Please help =\
 
add stackpos = 1:

local positions = {
{x=1964, y=1984, z=7, stackpos = 1},
{x=1965, y=1984, z=7, stackpos = 1},
.
.

or 0
 
Last edited:
add stackpos = 1:

local positions = {
{x=1964, y=1984, z=7, stackpos = 1},
{x=1965, y=1984, z=7, stackpos = 1},
.
.

or 0

I tried 1 and 0, both give the error: '=' expected near 'stackpos', I puted this in the start of the script, just like you did.
 
Back
Top