• 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 Key to Mwall wont work, simple

ziggy46802

Active Member
Joined
Aug 19, 2012
Messages
418
Reaction score
27
Here is my code

LUA:
local pos = {x=419, y=1325, z=8}

local mwall = 1497

local key = 2087

function onUse(cid, item, frompos, item2, topos)
	if getPlayerItemCount(cid, key) >= 1 and 
	(item.itemid == key) and 
	(itemEx.itemid == mwall) then
		doRemoveItem(pos, mwall)
		doCreatureSay(cid, "Opened the door.", TALKTYPE_ORANGE_1)
		addEvent(respawn, 3000)
			else
			doCreatureSay(cid, "You do not have the right key for this door.", TALKTYPE_ORANGE_1)
			end
	return true
end

function respawn(cid)
	doCreateItem(mwall, pos)
end

So when I "use" the mwall it gives me the else reading "you dont have the key" but when I use the key on the mwall, it says "sorry not possible" at the bottom and does nothing, whats wrong with this code? The UID's and such are set right thats not the problem.
 
Well with this code, uid has nothing to do with it. You must make sure the magic wall you are using key on is itemid 1497, if its any other type of magic wall it wont work.

After that id try taking out the item.itemid == key part, and just set the itemid in your actions.xml.

so...

LUA:
local pos = {x=419, y=1325, z=8}
 
local mwall = 1497
 
local key = 2087
 
function onUse(cid, item, frompos, item2, topos)
	if getPlayerItemCount(cid, key) >= 1 then
	if (itemEx.itemid == mwall) then
		doRemoveItem(pos, mwall)
		doCreatureSay(cid, "Opened the door.", TALKTYPE_ORANGE_1)
		addEvent(respawn, 3000)
			else
			doCreatureSay(cid, "This is not the right Mwall for this key.", TALKTYPE_ORANGE_1)
			end
	return true
end
end
 
function respawn(cid)
	doCreateItem(mwall, pos)
end

Code:
<action itemid="2087" event="script" value="other/enchanting.lua"/>
 
with this in actions

LUA:
<action itemid="2087" event="script" value="quests/key3001.lua"/> <!-- wooden key -->

and this code

LUA:
local pos = {x=419, y=1325, z=8}

local mwall = 1497

local key = 2087

function onUse(cid, item, frompos, item2, topos)
	if getPlayerItemCount(cid, key) >= 1 and
	(itemEx.itemid == mwall) then
		doRemoveItem(pos, mwall)
		doCreatureSay(cid, "Opened the door.", TALKTYPE_ORANGE_1)
		addEvent(respawn, 3000)
			else
			doCreatureSay(cid, "You do not have the right key for this door.", TALKTYPE_ORANGE_1)
			end
	return true
end

function respawn(cid)
	doCreateItem(mwall, pos)
end

It still does not work

And the mwall on the map does match the code's mwall, so thats not the problem
 
LUA:
local config = {
	pos = {x=419, y=1325, z=8},
	mwall = 1497,
	time = 3
}
  
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if (itemEx.itemid == config.mwall and getTileItemById(config.pos, config.mwall).uid > 0) then
		doRemoveItem(getTileItemById(config.pos,config.mwall).uid,1)
		doCreatureSay(cid, "Opened the door.", TALKTYPE_ORANGE_1)
		addEvent(respawn, config.time*1000)
	else
		doCreatureSay(cid, "You do not have the right key for this door.", TALKTYPE_ORANGE_1)
	end
	return true
end
 
function respawn(cid)
	doCreateItem(config.mwall,1,config.pos)
end
 
Last edited:
Back
Top