• 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 [0.4] open door (id 5283) cant be triggered by item.

elnelson

Lunaria World Dev
Joined
Jun 20, 2009
Messages
579
Solutions
2
Reaction score
58
Location
México
Hello otlanders, i have an issue. Im trying to transform this itemid (5283) to 5277 but seems like stackpos is not getting the lecture, so it does not work, just ignore the item.

Lua:
if (isInArray(5283, itemEx.itemid)) and checkStackpos(itemEx, toPosition) then
print("x")
doTransformItem(itemEx.uid, 5277)
doSendMagicEffect(toPosition, CONST_ME_POFF)
 
trying to check an array that isn't one

Code:
if itemEx.itemid == 5283 and ....


or the 2nd method if u wanna check arrays, although this is stupid for only 1 possibility
Code:
if (isInArray({5283}, itemEx.itemid)) and ....
 
I've never seen getStackPos before.. but I assume itemEx wouldn't work?
itemEx.uid is usually what you want to use.
 
I've never seen getStackPos before.. but I assume itemEx wouldn't work?
itemEx.uid is usually what you want to use.
yes sir, i added that getStackPos trying to fix the issue, but did not work. So, yes, im trying to use itemEx.uid but is not working.
 
I agree with above.

but just in case it's something simple you've overlooked..

Lua:
print(itemEx.itemid)
if itemEx.itemid == 5283 then
    print("Itemid is correct.")
    doTransformItem(itemEx.uid, 5277)
    doSendMagicEffect(toPosition, CONST_ME_POFF)
else
    print("Itemid is not correct.")
end
 
I agree with above.

but just in case it's something simple you've overlooked..

Lua:
print(itemEx.itemid)
if itemEx.itemid == 5283 then
    print("Itemid is correct.")
    doTransformItem(itemEx.uid, 5277)
    doSendMagicEffect(toPosition, CONST_ME_POFF)
else
    print("Itemid is not correct.")
end


here is the full script, it convert walls into doors, doors into windows and windows into walls, but if someone open the door and try to convert the opened door into a window, it will build a wall instead of transforming item id, i tried with your script @Xikini, but seem its not working properly

sorry for the dogshit script u.u im still learning
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
horizontal0 = {5261, 5266, 5268, 5274, 5275}
vertical0 = {5262, 5264, 5270, 5272, 5273}
local items ={
{5263, vertical0[math.random(1,5)], vertical0[math.random(1,5)]},
{horizontal0[math.random(1,5)],0,horizontal0[math.random(1,5)]},
{horizontal0[math.random(1,5)], vertical0[math.random(1,5)], 5265},
}
local click = getThingPosition(itemEx.uid)
local playerpos = getPlayerPosition(cid)
local i = getThingPosition(itemEx.uid).x-getPlayerPosition(cid).x+2
local j = getThingPosition(itemEx.uid).y-getPlayerPosition(cid).y+2


if(isInArray(horizontal0, itemEx.itemid)) then --wall to door
doSendMagicEffect(toPosition, CONST_ME_POFF)
doTransformItem(itemEx.uid, 5282)
print(2)

elseif(isInArray(5279, itemEx.itemid))  then --door to window
doTransformItem(itemEx.uid, 5276)
doSendMagicEffect(toPosition, CONST_ME_POFF)

elseif(isInArray(5280, itemEx.itemid)) then
doTransformItem(itemEx.uid, 5276)
doSendMagicEffect(toPosition, CONST_ME_POFF)

elseif(isInArray(5276, itemEx.itemid)) then --window to wall
doTransformItem(itemEx.uid, items[j][i])
doSendMagicEffect(toPosition, CONST_ME_POFF)
--vertical
elseif(isInArray(vertical0, itemEx.itemid)) then --wall to door
doSendMagicEffect(toPosition, CONST_ME_POFF)
doTransformItem(itemEx.uid, 5279)

elseif(isInArray(5282, itemEx.itemid)) then --door to window
doTransformItem(itemEx.uid, 5277)
doSendMagicEffect(toPosition, CONST_ME_POFF)

print(itemEx.itemid)
elseif itemEx.itemid == 5283 then
    print("Itemid is correct.")
    doTransformItem(itemEx.uid, 5277)
    doSendMagicEffect(toPosition, CONST_ME_POFF)

elseif(isInArray(5277, itemEx.itemid)) then --window to wall
doTransformItem(itemEx.uid, items[j][i])
doSendMagicEffect(toPosition, CONST_ME_POFF)

elseif getTileItemById(toPosition,5901).itemid >= 10 then --floor
doCreateItem(405,1, click)
doSendMagicEffect(toPosition, CONST_ME_POFF)
else
    doCreateItem(items[j][i], 1, click)
    doSendMagicEffect(toPosition, CONST_ME_POFF) --wall
return true
end
end
 
here is the full script, it convert walls into doors, doors into windows and windows into walls, but if someone open the door and try to convert the opened door into a window, it will build a wall instead of transforming item id, i tried with your script @Xikini, but seem its not working properly

sorry for the dogshit script u.u im still learning
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
horizontal0 = {5261, 5266, 5268, 5274, 5275}
vertical0 = {5262, 5264, 5270, 5272, 5273}
local items ={
{5263, vertical0[math.random(1,5)], vertical0[math.random(1,5)]},
{horizontal0[math.random(1,5)],0,horizontal0[math.random(1,5)]},
{horizontal0[math.random(1,5)], vertical0[math.random(1,5)], 5265},
}
local click = getThingPosition(itemEx.uid)
local playerpos = getPlayerPosition(cid)
local i = getThingPosition(itemEx.uid).x-getPlayerPosition(cid).x+2
local j = getThingPosition(itemEx.uid).y-getPlayerPosition(cid).y+2


if(isInArray(horizontal0, itemEx.itemid)) then --wall to door
doSendMagicEffect(toPosition, CONST_ME_POFF)
doTransformItem(itemEx.uid, 5282)
print(2)

elseif(isInArray(5279, itemEx.itemid))  then --door to window
doTransformItem(itemEx.uid, 5276)
doSendMagicEffect(toPosition, CONST_ME_POFF)

elseif(isInArray(5280, itemEx.itemid)) then
doTransformItem(itemEx.uid, 5276)
doSendMagicEffect(toPosition, CONST_ME_POFF)

elseif(isInArray(5276, itemEx.itemid)) then --window to wall
doTransformItem(itemEx.uid, items[j][i])
doSendMagicEffect(toPosition, CONST_ME_POFF)
--vertical
elseif(isInArray(vertical0, itemEx.itemid)) then --wall to door
doSendMagicEffect(toPosition, CONST_ME_POFF)
doTransformItem(itemEx.uid, 5279)

elseif(isInArray(5282, itemEx.itemid)) then --door to window
doTransformItem(itemEx.uid, 5277)
doSendMagicEffect(toPosition, CONST_ME_POFF)

print(itemEx.itemid)
elseif itemEx.itemid == 5283 then
    print("Itemid is correct.")
    doTransformItem(itemEx.uid, 5277)
    doSendMagicEffect(toPosition, CONST_ME_POFF)

elseif(isInArray(5277, itemEx.itemid)) then --window to wall
doTransformItem(itemEx.uid, items[j][i])
doSendMagicEffect(toPosition, CONST_ME_POFF)

elseif getTileItemById(toPosition,5901).itemid >= 10 then --floor
doCreateItem(405,1, click)
doSendMagicEffect(toPosition, CONST_ME_POFF)
else
    doCreateItem(items[j][i], 1, click)
    doSendMagicEffect(toPosition, CONST_ME_POFF) --wall
return true
end
end
add me on discord again. I got like 20 questions. lmao
 

Similar threads

Back
Top