• 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 TFS(0.4) - How to track item count?

Lava Titan

Developer
Joined
Jul 25, 2009
Messages
1,529
Solutions
1
Reaction score
85
Location
Portugal
Hello, I'm working on this small script to avoid players throwing junk or lose thrown items by mistake in some places but I'm having an issue in how to track the amount of items thrown..
I'm not sure if there's another way to do this but this is what I came up with xd

Example: If some1 throws 69 coins into the tile, I have to return 69 coins back.

At this moment all the coins are removed but I can't figure out how to return the amount thrown

Lua:
function onAddItem(moveitem, tileitem, position, cid)
        doPlayerAddItem(cid, getItemIdByName(getItemName(moveitem.uid)), 1, true)
        doRemoveItem(moveitem.uid)
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
        doPlayerSendCancel(cid, "You can't throw items there.")
    return true
end
 
Solution
That's a good idea xD but what other function is there to teleport stuff than "doTeleportThing" ? cuz like this it's not working :(

Lua:
function onAddItem(moveitem, tileitem, position, cid)
        doTeleportThing(cid, getCreaturePosition(cid))
        doSendMagicEffect(position, CONST_ME_TELEPORT)
        doPlayerSendCancel(cid, "You can't throw items there.")
    return true
end



I'd do it but I'm kinda afraid of messing stuff in sources since I don't have much experience yet
Lua:
function onAddItem(moveitem, tileitem, position, cid)
      doTeleportThing(moveitem.uid, getCreaturePosition(cid))
      doSendMagicEffect(position, CONST_ME_TELEPORT)
      doPlayerSendCancel(cid, "You can't throw items there.")
      return true...
I just figured out if someone drops a container with items inside the items will be gone, I totally forgot this part xD, does anyone have any idea how can I fix this?
 
You could teleport the container/items under cid?

That's a good idea xD but what other function is there to teleport stuff than "doTeleportThing" ? cuz like this it's not working :(

Lua:
function onAddItem(moveitem, tileitem, position, cid)
        doTeleportThing(cid, getCreaturePosition(cid))
        doSendMagicEffect(position, CONST_ME_TELEPORT)
        doPlayerSendCancel(cid, "You can't throw items there.")
    return true
end

Just add to sources "onThrow" function from higher version. Copy and paste to yours. It will be easier to work on.

I'd do it but I'm kinda afraid of messing stuff in sources since I don't have much experience yet
 
That's a good idea xD but what other function is there to teleport stuff than "doTeleportThing" ? cuz like this it's not working :(

Lua:
function onAddItem(moveitem, tileitem, position, cid)
        doTeleportThing(cid, getCreaturePosition(cid))
        doSendMagicEffect(position, CONST_ME_TELEPORT)
        doPlayerSendCancel(cid, "You can't throw items there.")
    return true
end



I'd do it but I'm kinda afraid of messing stuff in sources since I don't have much experience yet
Lua:
function onAddItem(moveitem, tileitem, position, cid)
      doTeleportThing(moveitem.uid, getCreaturePosition(cid))
      doSendMagicEffect(position, CONST_ME_TELEPORT)
      doPlayerSendCancel(cid, "You can't throw items there.")
      return true
end
 
Solution
Back
Top