• 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!

RevScripts onItemMoved certain places

zippy

Member
Joined
Feb 1, 2011
Messages
233
Reaction score
8
Hi,

I've come far as this:
Lua:
ec.onItemMoved = function(self, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    if item:getId() == 2400 then
        if fromPosition.x ~= CONTAINER_POSITION and toPosition.x == CONTAINER_POSITION or fromPosition.x == CONTAINER_POSITION and toPosition.x ~= CONTAINER_POSITION then
            print("Moved")
        end
    end

    return true
end

ec:register()

The problem i got is that, if i move item to another container on the ground, it does not print("Moved") and when i move it from a container on the ground to my backpack. It does not print. Now it only prints when i move it from bp to ground and from ground to bp. Also it does not print if you move it inside the player which is correct.

I would like to print("Moved") when i move it to a bag in the ground or from a bag which is on the ground
 
Is this kind of limitation? Since i still dont get it to work.

It should only print if the item leaves the player or item gets to the player. Maybe only can be done through sources?
 
possible solution:
1683457362610.png


use the flags to distinguish tiles will have nolimit of cap right? :)


chatgpt:

To check if a player is removing an item from a certain container ID, you can use the onContainerUpdate event in the creaturescripts file. This event is triggered every time a player modifies the content of a container.

Here is an example code that checks if a player removes an item from a container with ID 123 and removes the container from the game after all items have been removed:

lua

function onContainerUpdate(cid, containerid, slot, olditem, newitem)
if containerid == 123 and olditem.id ~= newitem.id then -- check if container ID is 123 and an item was removed
local containerItems = getContainerItems(containerid)
if not containerItems or #containerItems == 0 then -- check if container is empty
removeContainer(containerid) -- remove container from game
end
end
end

This code first checks if the container ID is 123 and an item was removed from it. Then, it retrieves the current content of the container using the getContainerItems function and checks if it is empty. If it is, the container is removed from the game using the removeContainer function.

To use this code, simply add it to your creaturescripts file and restart the server.

my idea was to create monster Worm which would have body that look like worm etc and would hold inside multiple worms that once removed would remove the worm from the ground in the game.(interact)
 
Back
Top