• 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 You can't drop here!

jestem pro

That is the question
Joined
Apr 20, 2013
Messages
650
Solutions
14
Reaction score
88
Hello everybody! I have a dilemma.

I've tried to do , but I can't do this.

so if the item is at position( 1000, 1000, 7) for example 2160 (crystal coin) how I will put this item again at the same position I won't be able to put. If this item is laying there still.

Code:
if getTileItemById(pos[i], 2669).uid > 0 then
  doPlayerSendCancel(cid, "You can not drop your item here!")
  return false
  end

But this don't work.
 
Check for the stackpos when you are placing items, e.g. {x = 1000, y = 1000, z = 7, stackpos = 0}, 0 is reserved for ground tiles like grass, dirt etc, 2669 is a fish (salmon), just check for what is sitting there already, if the item is stack-able then save the sub-type, remove it, then add the saved amount + the new amount, if you want to place another item on top just increase the stackpos by 1.

Programming is a series of steps, if the functionality doesn't already exist you need to build it yourself, this is why it is important to not just know the framework but also the language itself.
 
hmm okey on the ground is laying some item hmm wand 2424 and I put the other item maybe this fish 2669 so now I want to not be able to put next that same item 2669.

I have problem here :
Code:
function onAddItem(moveitem, tileitem, position, cid)
  for i = 1, #pos do
 
  if getTileItemById(pos[i], 2669).uid > 0 then    ----- HERE IT CHECKS THAT THE SAME ITEM IS LAYING AND STOPPING TO WORK
  doPlayerSendCancel(cid, "You can not drop your item here!")
  return false
  end
 
 
 if moveitem.itemid == 2669 and getTileItemById(pos[i], itemTryToFound).uid > 0 then   HERE IT CHECK THAT  THE ITEM GENERALLY IS LAYING
      doCreateItem(createItemId ,1, pos[i])  AND SCRIPT CONTINUES TO WORK

and I don't know that the sign is good " function > 0". If you could check it.

Thanks and sorry my English.
 
I'm so sorry, of course :

Code:
local pos = {
       {x=1000, y=1000, z=7, stackpos=2},
       {x=1001, y=1001, z=7, stackpos=2}
       }
local createItemId = 8046
local itemTryToFound = 2669

function onAddItem(moveitem, tileitem, position, cid)
  for i = 1, #pos do
 
  if getTileItemById(pos[i], 2669).uid > 0 then
  doPlayerSendCancel(cid, "You can not drop your item here!")
  return false
  end
 
 
 if moveitem.itemid == 2669 and getTileItemById(pos[i], itemTryToFound).uid > 0 then
      doCreateItem(createItemId ,1, pos[i])
         
   
    local function unFreeze(pName)   
    local ids = {8046, 2669, 2137}
      for _, v in ipairs(ids) do
      local item = getTileItemById(pos[i], v)
        if (item) then
  doRemoveItem(item.uid, 1)
          doSendMagicEffect(pos[i], 6)
             
      end
        end       
  local parcel = doCreateItemEx(ITEM_PARCEL)
  doAddContainerItem(parcel, 11129, 1)     
  doPlayerSendMailByName(pName, parcel, 2)
    end
  addEvent(unFreeze, 10 * 1000, getCreatureName(cid))   
  end
end  
return true
end
 
A+ for effort but this is coded entirely wrong, just want to point out a few things, never define a function in a loop, use proper indentation so you can see the level of execution, comment the code and give your variables, tables & functions names that describe their purpose.

Ok, so far we have these id's
Code:
something sparkling = 8046,
salmon fish = 2669,
golden fruit = 2137,
dragon statue = 11129

And a mess of code that doesn't make any real sense or give purpose.. even tho you said you didn't want items to be dropped on an existing item type, your code for whatever sense is does make says otherwise.

So basically you have no idea what you are doing.. still good that you tried..
 
Last edited:
code works as it is, because I don't know how to use two loops at the same time.

I just want you to tell me how to block the item if the ground already lay this item (2669) . I could no longer impose such the item when the item already is laying here.
 
Back
Top