function onUse(cid, item, frompos, item2, topos)
local wallpos1 = {x=420, y=791, z=7, stackpos=1} --- coordinates of the wall to be removed ---
local wallpos2 = {x=421, y=791, z=7, stackpos=1}
local wallpos3 = {x=422, y=791, z=7, stackpos=1}
local wall1 = getThingfromPos(wallpos1)
local wall2 = getThingfromPos(wallpos2)
local wall3 = getThingfromPos(wallpos3)
local wallID = 9485 --- item id of the wall to be removed ---
if item.itemid == 1945 then
doRemoveItem(wall1.uid, 1)
doRemoveItem(wall2.uid, 1)
doRemoveItem(wall3.uid, 1)
doPlayerSendTextMessage(cid,22,"Something has moved not too far away.")
elseif item.itemid == 1945 then
doCreateItem(wallID, 1, wallpos1)
doCreateItem(wallID, 1, wallpos2)
doCreateItem(wallID, 1, wallpos3)
doPlayerSendTextMessage(cid,22,"Something has moved not too far away.")
end
return TRUE
end
local walls = {
{{x=420, y=791, z=7, stackpos=1},9485},
{{x=421, y=791, z=7, stackpos=1},9485},
{{x=422, y=791, z=7, stackpos=1},9485},
}
local str = "Something has moved not too far away."
isWallRemoved = FALSE
function onUse(cid, item, frompos, item2, topos)
if isWallRemoved == FALSE then
for i=1,#walls do
doRemoveItem(getThingFromPos(walls[i][1]).uid, 1)
end
isWallRemoved = TRUE
else
for i=1,#walls do
doCreateItem(walls[i][2], 1, walls[i][1])
isWallRemoved == FALSE
end
end
doPlayerSendTextMessage(cid,22, str)
end
You added onStepIn with a table?
PHP:function onUse(cid, item, frompos, item2, topos) local wallpos1 = {x=420, y=791, z=7, stackpos=1} --- coordinates of the wall to be removed --- local wallpos2 = {x=421, y=791, z=7, stackpos=1} local wallpos3 = {x=422, y=791, z=7, stackpos=1} local wall1 = getThingfromPos(wallpos1) local wall2 = getThingfromPos(wallpos2) local wall3 = getThingfromPos(wallpos3) local wallID = 9485 --- item id of the wall to be removed --- if item.itemid == 1945 then doRemoveItem(wall1.uid, 1) doRemoveItem(wall2.uid, 1) doRemoveItem(wall3.uid, 1) doPlayerSendTextMessage(cid,22,"Something has moved not too far away.") elseif item.itemid == 1945 then doCreateItem(wallID, 1, wallpos1) doCreateItem(wallID, 1, wallpos2) doCreateItem(wallID, 1, wallpos3) doPlayerSendTextMessage(cid,22,"Something has moved not too far away.") end return TRUE end
should work:
PHP:local walls = { {{x=420, y=791, z=7, stackpos=1},9485}, {{x=421, y=791, z=7, stackpos=1},9485}, {{x=422, y=791, z=7, stackpos=1},9485}, } local str = "Something has moved not too far away." isWallRemoved = FALSE function onUse(cid, item, frompos, item2, topos) if isWallRemoved == FALSE then for i=1,#walls do doRemoveItem(getThingFromPos(walls[i][1]).uid, 1) end isWallRemoved = TRUE else for i=1,#walls do doCreateItem(walls[i][2], 1, walls[i][1]) isWallRemoved == FALSE end end doPlayerSendTextMessage(cid,22, str) return TRUE end
add in actions by uniqueid. ; )
local walls = {
{{x=420, y=791, z=7, stackpos=1},9485},
{{x=421, y=791, z=7, stackpos=1},9485},
{{x=422, y=791, z=7, stackpos=1},9485},
}
local str = "Something has moved not too far away."
isWallRemoved = FALSE
function onUse(cid, item, frompos, item2, topos)
if isWallRemoved == FALSE then
for i=1,#walls do
doRemoveItem(getThingFromPos(walls[i][1]).uid, 1)
end
isWallRemoved = TRUE
else
for i=1,#walls do
doCreateItem(walls[i][2], 1, walls[i][1])
isWallRemoved = FALSE
end
end
doPlayerSendTextMessage(cid,22, str)
return TRUE
end
Look now, i miss put twice "=" should be once.PHP:local walls = { {{x=420, y=791, z=7, stackpos=1},9485}, {{x=421, y=791, z=7, stackpos=1},9485}, {{x=422, y=791, z=7, stackpos=1},9485}, } local str = "Something has moved not too far away." isWallRemoved = FALSE function onUse(cid, item, frompos, item2, topos) if isWallRemoved == FALSE then for i=1,#walls do doRemoveItem(getThingFromPos(walls[i][1]).uid, 1) end isWallRemoved = TRUE else for i=1,#walls do doCreateItem(walls[i][2], 1, walls[i][1]) isWallRemoved = FALSE end end doPlayerSendTextMessage(cid,22, str) return TRUE end
Look now, i miss put twice "=" should be once.PHP:local walls = { {{x=420, y=791, z=7, stackpos=1},9485}, {{x=421, y=791, z=7, stackpos=1},9485}, {{x=422, y=791, z=7, stackpos=1},9485}, } local str = "Something has moved not too far away." isWallRemoved = FALSE function onUse(cid, item, frompos, item2, topos) if isWallRemoved == FALSE then for i=1,#walls do doRemoveItem(getThingFromPos(walls[i][1]).uid, 1) end isWallRemoved = TRUE else for i=1,#walls do doCreateItem(walls[i][2], 1, walls[i][1]) isWallRemoved = FALSE end end doPlayerSendTextMessage(cid,22, str) return TRUE end
local walls = {
{{x=420, y=791, z=7, stackpos=1},9485},
{{x=421, y=791, z=7, stackpos=1},9485},
{{x=422, y=791, z=7, stackpos=1},9485},
}
local str = "Something has moved not too far away."
isWallRemoved = FALSE
function onUse(cid, item, frompos, item2, topos)
if item.itemid == 1945 then
if isWallRemoved == FALSE then
for i=1,#walls do
doRemoveItem(getThingFromPos(walls[i][1]).uid, 1)
end
isWallRemoved = TRUE
else
for i=1,#walls do
doCreateItem(walls[i][2], 1, walls[i][1])
isWallRemoved = FALSE
end
end
doTransformItem(item.uid, item.itemid+1)
doPlayerSendTextMessage(cid,22, str)
elseif item.itemid === 1946 then
doTransformItem(item.uid, item.itemid-1)
end
return TRUE
end
function onUse(cid, item, frompos, item2, topos)
gatepos1 = {x=420, y=791, z=7, stackpos=1}
gatepos2 = {x=421, y=791, z=7, stackpos=1}
gatepos3 = {x=422, y=791, z=7, stackpos=1}
if item.uid == 9485 and item.itemid == 1945 then
doRemoveItem(9485,1,gatepos1)
doRemoveItem(9485,1,gatepos2)
doRemoveItem(9485,1,gatepos3)
doTransformItem(item.uid,item.itemid+1)
elseif item.uid == 9485 and item.itemid == 1946 then
doCreateItem(9485,1,gatepos1)
doCreateItem(9485,1,gatepos2)
doCreateItem(9485,1,gatepos3)
doTransformItem(item.uid,item.itemid-1)
else
doPlayerSendCancel(cid,"Sorry not possible.")
end
return 1
end
return 1
end
end
this script should work also remember to put UID:9485 on the switch in the mapeditor
PHP:function onUse(cid, item, frompos, item2, topos) gatepos1 = {x=420, y=791, z=7, stackpos=1} gatepos2 = {x=421, y=791, z=7, stackpos=1} gatepos3 = {x=422, y=791, z=7, stackpos=1} if item.uid == 9485 and item.itemid == 1945 then doRemoveItem(9485,1,gatepos1) doRemoveItem(9485,1,gatepos1) doRemoveItem(9485,1,gatepos1) doTransformItem(item.uid,item.itemid+1) elseif item.uid == 9485 and item.itemid == 1946 then doCreateItem(9485,1,gatepos1) doCreateItem(9485,1,gatepos2) doCreateItem(9485,1,gatepos3) doTransformItem(item.uid,item.itemid-1) else doPlayerSendCancel(cid,"Sorry not possible.") end return 1 end return 1 end
local walls =
{
{{x=420, y=791, z=7, stackpos=1}, 9485},
{{x=421, y=791, z=7, stackpos=1}, 9485},
{{x=422, y=791, z=7, stackpos=1}, 9485}
}
local str = "Something has moved not too far away."
function onUse(cid, item, fromPosition, itemEx, toPosition)
if(item.itemid == 1945) then
for i = 1, table.maxn(walls) do
doRemoveItem(getThingFromPos(walls[i][1]).uid, 1)
end
doTransformItem(item.uid, 1946)
elseif(item.itemid == 1946) then
for i = 1, table.maxn(walls) do
doCreateItem(walls[i][2], 1, walls[i][1])
end
doTransformItem(item.uid, 1945)
end
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, str)
return TRUE
end
plx.
Code:local walls = { {{x=420, y=791, z=7, stackpos=1}, 9485}, {{x=421, y=791, z=7, stackpos=1}, 9485}, {{x=422, y=791, z=7, stackpos=1}, 9485} } local str = "Something has moved not too far away." function onUse(cid, item, fromPosition, itemEx, toPosition) if(item.itemid == 1945) then for i = 1, table.maxn(walls) do doRemoveItem(getThingFromPos(walls[i][1]).uid, 1) end doTransformItem(item.uid, 1946) elseif(item.itemid == 1946) then for i = 1, table.maxn(walls) do doCreateItem(walls[i][2], 1, walls[i][1]) end doTransformItem(item.uid, 1945) end doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, str) return TRUE end