• 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 Get position item used actionid

maikons

Member
Joined
Aug 1, 2015
Messages
227
Reaction score
16
Someone help me to get door position to set player there

To change this 1,2,3 to door position

Code:
local storage = 55565
local open_door

function onUse(cid, item, frompos, item2, toPosition)
   if(getPlayerStorageValue(cid, storage)) ~= -1 then
     if(item.uid == 1225) then -- north / south
       open_door = 1226
     elseif(item.uid == 1223) then -- east / west
       open_door = 1224
     end
     doTransformItem(item.uid, open_door)
     doTeleportThing(cid, {x = 1, y = 2, z = 3})
   else
     doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE,"You not complete postman quest!")
   end
   return true
end
 
Code:
local storage = 55565
local open_door

function onUse(cid, item, frompos, item2, toPosition)
   if(getPlayerStorageValue(cid, storage)) ~= -1 then
     if(item.uid == 1225) then -- north / south
       open_door = 1226
     elseif(item.uid == 1223) then -- east / west
       open_door = 1224
     end
     doTransformItem(item.uid, open_door)
     doTeleportThing(cid, toPosition)
   else
     doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE,"You not complete postman quest!")
   end
   return true
end
 
Code:
local storage = 55565
local open_door

function onUse(cid, item, frompos, item2, toPosition)
   if(getPlayerStorageValue(cid, storage)) ~= -1 then
     if(item.uid == 1225) then -- north / south
       open_door = 1226
     elseif(item.uid == 1223) then -- east / west
       open_door = 1224
     end
     doTransformItem(item.uid, open_door)
     doTeleportThing(cid, toPosition)
   else
     doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE,"You not complete postman quest!")
   end
   return true
end


Tyy

Why door not open and close?

Code:
<action actionid="7426" script="porta_postman.lua" />

Code:
--local storage = 55565
local open_door

function onUse(cid, item, frompos, item2, toPosition)
  --if(getPlayerStorageValue(cid, storage)) ~= -1 then
  doTeleportThing(cid, toPosition)
  --else
  --  doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE,"You not complete postman quest!")
  --end
  return true
end


Code:
  <movevent type="StepIn"  actionid="7426" event="script" value="abrirporta_postman.lua"/>
   <movevent type="StepOut" actionid="7426" event="script" value="fecharporta_postman.lua"/>

Code:
local closed_door

function onStepIn(cid, item, position, fromPosition)
  if(item.uid == 1225) then -- north / south
  closed_door = 1226
  elseif(item.uid == 1223) then -- east / west
  closed_door = 1224
  end
   doTransformItem(item.uid, closed_door)
   return true
end

Code:
local closed_door

function onStepOut(cid, item, position, fromPosition)
  if(item.uid == 1226) then -- north / south
  closed_door = 1225
  elseif(item.uid == 1224) then -- east / west
  closed_door = 1223
  end
   doTransformItem(item.uid, closed_door)
   return true
end
 
You didnt define, closed_door id.
Code:
local closed_door = id
for ex. local closed_door = 4521
 
You didnt define, closed_door id.
Code:
local closed_door = id
for ex. local closed_door = 4521

Because can be 2
Code:
if(item.uid == 1225) then -- north / south
closed_door = 1226
elseif(item.uid == 1223) then -- east / west
closed_door = 1224
end
 
Code:
local open_doorn = 1226 -- id north open door
local open_doore = 1224 -- id east open door
function onStepIn(cid, item, position, fromPosition)
if(item.uid == 1225) then -- north / south
doTransformItem(item.uid, open_doorn - 1)
elseif(item.uid == 1223) then -- east / west
doTransformItem(item.uid, open_doore - 1)
end
return true
end

Try this.
 
Last edited:
Code:
local open_doorn = 1226 -- id north open door
local open_doore = 1224 -- id east open door
function onStepIn(cid, item, position, fromPosition)
if(item.uid == 1225) then -- north / south
doTransformItem(item.uid, open_doorn - 1)
elseif(item.uid == 1223) then -- east / west
doTransformItem(item.uid, open_doore - 1)
end
return true
end

Try this.

I tried... Nothing...

Code:
local open_doorn = 1226 -- id north open door
local open_doore = 1224 -- id east open door

function onStepIn(cid, item, position, fromPosition)
if(item.uid == 1225) then -- north / south
doTransformItem(item.uid, open_doorn - 1)
elseif(item.uid == 1223) then -- east / west
doTransformItem(item.uid, open_doore - 1)
end
return true
end

Code:
local open_doorn = 1225 -- id north open door
local open_doore = 1223 -- id east open door

function onStepOut(cid, item, position, fromPosition)
if(item.uid == 1226) then -- north / south
doTransformItem(item.uid, open_doorn - 1)
elseif(item.uid == 1224) then -- east / west
doTransformItem(item.uid, open_doore - 1)
end
return true
end
 
Code:
local doorpos = {x = 1, y = 2, z = 3}

function onStepOut(cid, item, position, fromPosition)
if(item.uid == 1226) then -- north / south <<<< if player step out
doTransformItem(getTileItemById(doorpos, 1225).uid, 1224) <<< transform open door to 1224 id = closed door
elseif(item.uid == 1224) then -- east / west
doTransformItem(getTileItemById(doorpos, 1223).uid, 1222) <<< 1222 id for closed door
end
return true
end
 
Code:
local doorpos = {x = 1, y = 2, z = 3}

function onStepOut(cid, item, position, fromPosition)
if(item.uid == 1226) then -- north / south <<<< if player step out
doTransformItem(getTileItemById(doorpos, 1225).uid, 1224) <<< transform open door to 1224 id = closed door
elseif(item.uid == 1224) then -- east / west
doTransformItem(getTileItemById(doorpos, 1223).uid, 1222) <<< 1222 id for closed door
end
return true
end

what? doorpos? i dont understand this script
 
Why are u using "
function onStepIn(cid, item, position, fromPosition)"? Instead of action id to open door?

because when i use a door
ItemID: [1225]

with this action to open
Code:
--local storage = 55565
function onUse(cid, item, frompos, item2, toPosition)
  --if(getPlayerStorageValue(cid, storage)) ~= -1 then
      print(item.uid)
  doTeleportThing(cid, toPosition)
  local newdoor = item.uid + 1
  print(newdoor)
  --doTransformItem(item.uid, newdoor)
  --else
  --  doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE,"You not complete postman quest!")
  --end
  return true
end

The print on console is note 1226
Is:
70013
70014
 
Code:
--local storage = 55565
function onUse(cid, item, fromPosition, itemEx, toPosition)
if item.itemid == 1224 then return false end
  --if(getPlayerStorageValue(cid, storage)) ~= -1 then
  doTeleportThing(cid, toPosition)
doTransformItem(item.uid, item.itemid + 1)
  --else
  --  doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE,"You not complete postman quest!")
  --end
  return true
end
 
Code:
--local storage = 55565
function onUse(cid, item, fromPosition, itemEx, toPosition)
if item.itemid == 1224 then return false end
  --if(getPlayerStorageValue(cid, storage)) ~= -1 then
  doTeleportThing(cid, toPosition)
doTransformItem(item.uid, item.itemid + 1)
  --else
  --  doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE,"You not complete postman quest!")
  --end
  return true
end

Code:
--local storage = 55565
function onUse(cid, item, frompos, item2, toPosition)
  if item.itemid == 1224 or item.itemid == 1226 then return false end
--if(getPlayerStorageValue(cid, storage)) ~= -1 then
  doTeleportThing(cid, toPosition)
  doTransformItem(item.uid, item.itemid + 1)
--else
--  doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE,"You not complete postman quest!")
--end
  return true
end

/\ now its work, its open the door, but when i move out it still opend it was to close... :(
 
It should automatically close when stepping out, you have something wrong with your door movement.

Code:
<movevent type="StepOut" itemid="1224" event="script" value="closingdoor.lua"/>

Code:
function onStepOut(cid, item, position, fromPosition)
    local newPosition = {x = position.x, y = position.y, z = position.z}
    if isInArray(verticalOpenDoors, item.itemid) == TRUE then
        newPosition.x = newPosition.x + 1
    else
        newPosition.y = newPosition.y + 1
    end
    doRelocate(position, newPosition)

    local tmpPos = {x = position.x, y = position.y, z = position.z, stackpos = -1}
    local tileCount = getTileThingByPos(tmpPos)
    local i = 1
    local tmpItem = {uid = 1}
    while(tmpItem.uid ~= 0 and i < tileCount) do
        tmpPos.stackpos = i
        tmpItem = getTileThingByPos(tmpPos)
        if tmpItem.uid ~= item.uid and tmpItem.uid ~= 0 and isMoveable(tmpItem.uid) == TRUE then
            doRemoveItem(tmpItem.uid)
        else
            i = i + 1
        end
    end
    doTransformItem(item.uid, item.itemid - 1)
    return TRUE
end
 
It should automatically close when stepping out, you have something wrong with your door movement.

Code:
<movevent type="StepOut" itemid="1224" event="script" value="closingdoor.lua"/>

Code:
function onStepOut(cid, item, position, fromPosition)
    local newPosition = {x = position.x, y = position.y, z = position.z}
    if isInArray(verticalOpenDoors, item.itemid) == TRUE then
        newPosition.x = newPosition.x + 1
    else
        newPosition.y = newPosition.y + 1
    end
    doRelocate(position, newPosition)

    local tmpPos = {x = position.x, y = position.y, z = position.z, stackpos = -1}
    local tileCount = getTileThingByPos(tmpPos)
    local i = 1
    local tmpItem = {uid = 1}
    while(tmpItem.uid ~= 0 and i < tileCount) do
        tmpPos.stackpos = i
        tmpItem = getTileThingByPos(tmpPos)
        if tmpItem.uid ~= item.uid and tmpItem.uid ~= 0 and isMoveable(tmpItem.uid) == TRUE then
            doRemoveItem(tmpItem.uid)
        else
            i = i + 1
        end
    end
    doTransformItem(item.uid, item.itemid - 1)
    return TRUE
end

Like you said, the problem was in my movemments, i just remove that and now all work...
Ty you so much!
 

Similar threads

Back
Top