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

Lua CreateItem after time - bug

agel

New Member
Joined
Jul 21, 2009
Messages
49
Reaction score
0
I'm using TFS 0.3.4PL2. This is the script I'm using:
Code:
function onUse(cid, item, frompos, item2, topos)
 
	local switchUniqueID = 30050  -- uniqueID of switch
	local switchID = 1945
	local switch2ID = 1946
	local itemID = 2881
	local itempos = {x=921, y=961, z=8, stackpos=1} 
	local wallpos = {x=919, y=962, z=8, 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 == 1026 then
			doSendMagicEffect(itempos,10)
			doSendMagicEffect(wallchk,10)
			doRemoveItem(getitem.uid,1)
			doRemoveItem(wallchk.uid,1)
			doTransformItem(item.uid,item.itemid+1)
			addEvent(onTimer2, 2*60*1000)
	elseif item.uid == switchUniqueID and item.itemid == switch2ID then
			doTransformItem(item.uid,item.itemid-1)
	else
			doPlayerSendCancel(cid,"You need to place the corpse of Katla, on the correct spot - then pull the lever.")
end
	return 1
end


function onTimer2()

wallnewpos = {x=919, y=962, z=8} 
		doCreateItem(1026,1,wallnewpos)
end
Everything works excellent, except for the last part. No wall is ever created. What do I need to change?
 
Changed so it looked like this:
Code:
function onUse(cid, item, frompos, item2, topos)
 
	local switchUniqueID = 30050  -- uniqueID of switch
	local switchID = 1945
	local switch2ID = 1946
	local itemID = 2881
	local itempos = {x=921, y=961, z=8, stackpos=1} 
	local wallpos = {x=919, y=962, z=8, 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 == 1026 then
			doSendMagicEffect(itempos,10)
			doSendMagicEffect(wallchk,10)
			doRemoveItem(getitem.uid,1)
			doRemoveItem(wallchk.uid,1)
			doTransformItem(item.uid,item.itemid+1)
			addEvent(onTimer2, 2*60*1000)
	elseif item.uid == switchUniqueID and item.itemid == switch2ID then
			doTransformItem(item.uid,item.itemid-1)
	else
			doPlayerSendCancel(cid,"You need to place the corpse of Katla, on the correct spot - then pull the lever.")
end
	return 1
end


function onTimer2()

wallnewpos = {x=919, y=962, z=8, stackpos=1} 
		doCreateItem(1026,1,wallnewpos)
end
Still didn't work.
 
Try putting a broadcast command in your onTimer2 function and see if the function is even being called. If it doesn't broadcast then we know where to start!
 
Try putting a broadcast command in your onTimer2 function and see if the function is even being called. If it doesn't broadcast then we know where to start!
Would you mind explaining how to do that? Lua's not really my thing :huh:
 
Sure!

Just change it to this..

Code:
function onTimer2()

wallnewpos = {x=919, y=962, z=8, stackpos=1} 
		doBroadcastMessage("onTime2 is being called")
		doCreateItem(1026,1,wallnewpos)
end
 
And there are no error messages in the server? If there are none, then the function is not even being called.. And nor do I know why..
 
Lua:
function onTimer2()

wallnewpos = {x=919, y=962, z=8, stackpos=1} 
		doCreateItem(1026,1,wallnewpos)
end

function onUse(cid, item, frompos, item2, topos)
 
	local switchUniqueID = 30050  -- uniqueID of switch
	local switchID = 1945
	local switch2ID = 1946
	local itemID = 2881
	local itempos = {x=921, y=961, z=8, stackpos=1} 
	local wallpos = {x=919, y=962, z=8, 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 == 1026 then
			doSendMagicEffect(itempos,10)
			doSendMagicEffect(wallchk,10)
			doRemoveItem(getitem.uid,1)
			doRemoveItem(wallchk.uid,1)
			doTransformItem(item.uid,item.itemid+1)
			addEvent(onTimer2, 2*60*1000)
	elseif item.uid == switchUniqueID and item.itemid == switch2ID then
			doTransformItem(item.uid,item.itemid-1)
	else
			doPlayerSendCancel(cid,"You need to place the corpse of Katla, on the correct spot - then pull the lever.")
end
	return TRUE
end
 
Back
Top