• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

[Action] Key disappears after using on a door. Does somebody know how to do?

LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if itemEx.actionid == item.actionid and itemEx.itemid == CLOSED_DOOR_ID then
		doRemoveItem(item.uid)
		doTransformItem(itemEx.uid, OPEN_DOOR_ID)
		return true
	end
end
remember to change the uppercase stuff, and they need to have same actionid's
 
I do it xDDD
LUA:
local location = {x=1000, y=1000, z=1000}
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if itemEx.actionid == item.actionid then
		doRemoveItem(item.uid)
		doTeleportThing(cid, location)
		return true
	end
end
Hope it works xD
 
LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if itemEx.actionid == item.actionid and itemEx.itemid == CLOSED_DOOR_ID then
		doRemoveItem(item.uid)
		doTransformItem(itemEx.uid, OPEN_DOOR_ID)
		return true
	end
end
remember to change the uppercase stuff, and they need to have same actionid's

I used this script now like this
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if itemEx.actionid == item.actionid and itemEx.itemid == 9279 then
		doRemoveItem(item.uid)
		doTransformItem(itemEx.uid, 9280)
		return true
	end
end


and this is actions xml
Code:
	<action itemid="2091" event="script" value="door1.lua"/>

Is that correct?
I can't add the key a actionID because the key should be dropped by a boss monster
 
it works with this script now
but it just opens it like a normal key script
Can you change it so you will get teleported to X Z Y and the key disappears?
because when you use the key it doesn't disappear
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if itemEx.actionid == item.actionid and itemEx.itemid == 9271then
		doRemoveItem(item.uid)
		doTransformItem(itemEx.uid, 9280)
		return true
	end
end

Which line should I use btw?
Code:
	<action itemid="2091" event="script" value="door1.lua"/>
	<action action="2091" event="script" value="door1.lua"/>

the key;
Code:
22:56 You see a golden key (Key:2091).
It weighs 1.00 oz.
ItemID: [2091], ActionID: [2091].

the door;
Code:
22:57 You see a closed door.
ItemID: [10272], ActionID: [2091].
Thanks in advance (:
I rep you cykotitan and dantarrix, because you already tried to help me so much (:
 
Last edited:
LUA:
local tp = {x=100, y=100, z=7} -- new position

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if itemEx.actionid == 2091 then
		doRemoveItem(item.uid)
		doTeleportThing(cid, tp)
		doSendMagicEffect(tp, CONST_ME_TELEPORT)
		return true
	end
end
and register the key with actionid only, or else the script won't be executed at all
XML:
<action actionid="2091" event="script" value="door1.lua"/>
 
It does work now with the key.
When I use the key with actionID 2091 on the door with actionID 2091, I get teleported and the key disappears.
Everything fine.

But when I use the door without the key, I get teleported and the DOOR disappears
help, please?

good job, I can't rep u cus I did already :|
 
Last edited:
Okay, you're a god of scripting (:
Thank you ;)!

can't rep u :/
already done

if anyone needs the script! credits to cykotitan
LUA:
local tp = {x = 1254, y = 1015, z = 10} -- new position
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.itemid == 2091 and itemEx.actionid == 2091 then
		doRemoveItem(item.uid)
		doTeleportThing(cid, tp)
		doSendMagicEffect(tp, CONST_ME_TELEPORT)
		return true
	end
end

XML:
<action actionid="2091" event="script" value="door1.lua"/>
 
Back
Top