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

Problem with timerevent [SOLVED THX TO CYKOTITAN]

Exmortis

Member
Joined
Jun 27, 2008
Messages
189
Reaction score
5
Alright so i'm trying to get this script working for my TFS 0.2.7 server and i dont know what i've done work but the timer isnt working.
Its supposed to be that you put an object on a platform and then pull a lever which removes a door/stone. Then after say like 5-10 seconds, the scripts resets and the stone is there again.
What have i done wrong?

Script:
Code:
function onUse(cid, item, frompos, item2, topos)
 
	local switchUniqueID = 65535  -- uniqueID of switch
	local switchID = 1945
	local switch2ID = 1946
	local itemID = 9734
	local itempos = {x=1006, y=1086, z=7, stackpos=1} 
	local wallpos = {x=1005, y=1085, z=7, stackpos=1}
 
	local playername = getPlayerName(cid)
	local getitem = getThingfromPos(itempos)
	local wallchk = getThingfromPos(wallpos)
 
	if item.uid == switchUniqueID and item.itemid == switchID and getitem.itemid == itemID and wallchk.itemid == 3700 then
			doSendMagicEffect(itempos,10)
			doSendMagicEffect(wallchk,10)
			doRemoveItem(getitem.uid,1)
			doRemoveItem(wallchk.uid,1)
			doTransformItem(item.uid,item.itemid+1)
			addEvent(onTimer5, 5)
	elseif item.uid == switchUniqueID and item.itemid == switch2ID then
			doTransformItem(item.uid,item.itemid-1)
	else
			doPlayerSendCancel(cid,"You need to place the potion of the slain Guard.")
end
	return 1
end


function onTimer5()

wallnewpos = {x=1005, y=1085, z=7} 
		doCreateItem(3700,1,wallnewpos)
end
 
Last edited:
Lua:
local itemPos = {x=1006, y=1086, z=7}
local wallPos = {x=1005, y=1085, z=7}

local function reset(leverPos)
	doCreateItem(3700, 1, wallPos)
	doTransformItem(getTileItemById(leverPos, 1946).uid, 1945)
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.itemid == 1945 then
		local v = getTileItemById(itemPos, 9734).uid
		if v > 0 then
			doSendMagicEffect(itemPos, CONST_ME_TELEPORT)
			doSendMagicEffect(wallPos, CONST_ME_TELEPORT)
			doRemoveItem(v)
			doRemoveItem(getTileItemById(wallPos, 3700).uid)
			doTransformItem(item.uid, 1946)
			addEvent(reset, 5000, fromPosition)
		else
			doPlayerSendCancel(cid, 'You need to place the potion of the slain Guard.')
		end
		return true
	end
end
 
Back
Top