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

(8.6) Time lever

pansuchar

Member
Joined
Dec 29, 2008
Messages
68
Reaction score
5
Hi all. I need script for time lever.
I have something like this:
K2VaAxh.png

(i know, thats ugly, but it simply shows what i need ^_^)
How would that work? I pull the lever and have 30 seconds to pass, after 30 seconds, brick walls appears again.

engine: tfs 0.3.6
 
Thanks very much, you script is working for me :) but i have one complain.
When i click use one time on lever wall disappear, ok good :) i wait 10 seconds, wall appears again.
But when i click use, wait 3 seconds, click use again wall appears immediately after this 3 seconds. After that i click use, i see smoke but wall still exist and i have to use lever one more time to disappear the wall :p
 
Lua:
local c = {
	[11111yourUidNr1111] = {
		pos = {
			{x = 1111, y = 2222, z = 333}, -- wall pos 1
			{x = 1111, y = 2222, z = 333}, -- wall pos 2
			{x = 1111, y = 2222, z = 333} -- wall pos 3
		},
		relocate = {
			{x = 1111, y = 2222, z = 333}, -- relocate pos from pos 1
			{x = 1111, y = 2222, z = 333}, -- relocate pos from pos 2
			{x = 1111, y = 2222, z = 333} -- relocate pos from pos 3
		},
		statua = 1304, -- wall itemid
		time = 10 -- how much seconds
	}
}
 
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
 
	local u = c[item.uid]
 
	if u then
		local iu = item.uid
		if(item.itemid == 1946) then
			doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
			return true
		end
		if u.pos then
			for i = 1, #u.pos do
				if getTileItemById(u.pos[i], u.statua).uid > 0 then
					doRemoveItem(getTileItemById(u.pos[i], u.statua).uid, 1)
					doSendMagicEffect(u.pos[i], CONST_ME_POFF)
					addEvent(function()
						doRelocate(u.pos[i], u.relocate[i])
						doCreateItem(u.statua, 1, u.pos[i])
						doTransformItem(iu, 1945)
					end, u.time*1000)
				end
			end
		end
	end
 
	return true
end
 
Great job andypsylon, works excellent :)
One more question. If i would like to add another place with another positions and wall id how can i do that?
 
Last edited:
You can add as you like and what you want.
Lua:
local c = {
	[11111yourUidNr1111] = {
		pos = {
			{x = 1111, y = 2222, z = 333}, -- wall pos 1
			{x = 1111, y = 2222, z = 333}, -- wall pos 2
			{x = 1111, y = 2222, z = 333} -- wall pos 3
		},
		relocate = {
			{x = 1111, y = 2222, z = 333}, -- relocate pos from pos 1
			{x = 1111, y = 2222, z = 333}, -- relocate pos from pos 2
			{x = 1111, y = 2222, z = 333} -- relocate pos from pos 3
		},
		statua = 1304, -- wall itemid
		time = 10 -- how much seconds
	},
	[22222yourUidNr2222] = {
		pos = {
			{x = 1111, y = 2222, z = 333}, -- wall pos 1
			{x = 1111, y = 2222, z = 333}, -- wall pos 2
			...
			{x = 1111, y = 2222, z = 333}, -- wall pos n-1
			{x = 1111, y = 2222, z = 333} -- wall pos n
		},
		relocate = {
			{x = 1111, y = 2222, z = 333}, -- relocate pos from pos 1
			{x = 1111, y = 2222, z = 333}, -- relocate pos from pos 2
			...
			{x = 1111, y = 2222, z = 333} -- relocate pos from pos n-1
			{x = 1111, y = 2222, z = 333} -- relocate pos from pos n
		},
		statua = 2343242, -- itemid
		time = 10 -- how much seconds
	}
}
 
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
 
	local u = c[item.uid]
 
	if u then
		local iu = item.uid
		if(item.itemid == 1946) then
			doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
			return true
		end
		if u.pos then
			for i = 1, #u.pos do
				if getTileItemById(u.pos[i], u.statua).uid > 0 then
					doRemoveItem(getTileItemById(u.pos[i], u.statua).uid, 1)
					doSendMagicEffect(u.pos[i], CONST_ME_POFF)
					addEvent(function()
						doRelocate(u.pos[i], u.relocate[i])
						doCreateItem(u.statua, 1, u.pos[i])
						doTransformItem(iu, 1945)
					end, u.time*1000)
				end
			end
		end
	end
 
	return true
end
 
Back
Top