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

Pulling lever makes item disappear

Samuro

GameDev
Joined
Aug 7, 2007
Messages
1,846
Reaction score
572
Location
Sweden
Pulling lever makes item disappear and when you pull it back the item is there again.


I couldn't find this script anywere, probobly because it's so simple to make :p

Rep+ to anyone who makes this
 
I think this should work..
PHP:
function onUse(cid, item, frompos, item2, topos)

	object = {x=0, y=0, z=7, stackpos=255}
	getobject = getThingfromPos(objectpos)

	if item.uid == UNIQUEID and item.itemid == 1945 then
		doTransformItem(item.uid,item.itemid+1)
		doRemoveItem(getobject.uid,1)
	elseif item.uid == UNIQUEID and item.itemid == 1945 then
		doCreateItem(OBJECTID,1,objectpos)
		doTransformItem(item.uid,item.itemid-1)
	else
		doPlayerSendTextMessage(cid,22,"Sorry, not possible.")
	end
	return 1
end
save it with notepad and give it the file format .lua.
 
Code:
local config = {
	position = { x = 100, y = 100, z = 7 },
	itemid = 2400
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.itemid == 1945 then
		doRemoveItem(getTileItemById(config.position, config.itemid).uid)
	elseif item.itemid == 1946 then
		doCreateItem(config.itemid, 1, config.position)
	end
	doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
	return TRUE
end
 
Doesn't work :/

I'm using 2.5.0, forgot to say



Edit:

Code:
local config = {
	position = { x = 100, y = 100, z = 7 }, //position of the stone that's suppose to disappear or the lever?
	itemid = 2400 //the stones item ID?
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.itemid == 1945 then
		doRemoveItem(getTileItemById(config.position, config.itemid).uid)
	elseif item.itemid == 1946 then
		doCreateItem(config.itemid, 1, config.position)
	end
	doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
	return TRUE
end
 
Last edited:
actions.xml
Code:
<action script="openStoneThing.lua"/>

openStoneThing.lua
Code:
local config = {
	position = { x = 1053, y = 984, z = 8 },
	itemid = 1304
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.itemid == 1945 then
		doRemoveItem(getTileItemById(config.position, config.itemid).uid)
	elseif item.itemid == 1946 then
		doCreateItem(config.itemid, 1, config.position)
	end
	doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
	return TRUE
end

Everything seems correct
 
Bump and another question related to this script


Can you make so the stone appears again after 10 seconds efter pulling the switch if someone doesn't pull it back?

Thanks
 
Code:
local config, event = {
	position = { x = 1053, y = 984, z = 8 },
	itemid = 1304
}, 0
local function reset(leverPos)
	doCreateItem(config.itemid, 1, config.position)
	doTransformItem(getTileItemById(leverPos, 1946).uid, 1945)
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.itemid == 1945 then
		doRemoveItem(getTileItemById(config.position, config.itemid).uid)
		doTransformItem(item.uid, 1946)
		event = addEvent(reset, 10 * 1000, toPosition)
	elseif item.itemid == 1946 then
		stopEvent(event)
		reset(toPosition)
	end
	return TRUE
end
 
Back
Top