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

Solved How to detekt if item has left the bag or added to bag?

whitevo

Feeling good, thats what I do.
Joined
Jan 2, 2015
Messages
3,454
Solutions
1
Reaction score
627
Location
Estonia
I want to reduce cap of item or player if its moved to certain bag and increase the cap of item or player if item leaves the bag.

Is it possible with LUA? If not, what do I need to do then?
What functions can I use? (moveitem and removeitem is not working)
 
Combination of movement scripts and database functions.

I have no clue to how to script it, but generally I would check the movement of the item, either going in or out of the inventory, then increase/decrease the cap of the player with a sql/database query.

in 0.3.7 these are functions I'd attempt to use..

Code:
function onAddItem(cid, moveitem, tileitem, position)
function onRemoveItem(cid, moveitem, tileitem, position)
getContainerSize(uid)
getContainerCap(uid)
getContainerCapById(itemid)
getContainerItem(uid, slot)
doPlayerSetMaxCapacity(cid, cap)
isItemContainer(itemid)
isContainer(uid)
getItemWeight(uid[, precise])
getItemWeightById(itemid, count[, precise])

Unsure if 1.x has these functions, but they probably have them, just under different names possibly.

Good luck!

Xikini
 
Events:
Code:
function Player:onMoveItem(item, count, fromPosition, toPosition)
end

if x == 65535 then is from player (or bags?), y = slot, and I think z is used when you move it to any (z) slot INSIDE a container.
if x ~= 65535 then is from floor or wherever, like any coord I guess.
 
Events:
Code:
function Player:onMoveItem(item, count, fromPosition, toPosition)
end

if x == 65535 then is from player (or bags?), y = slot, and I think z is used when you move it to any (z) slot INSIDE a container.
if x ~= 65535 then is from floor or wherever, like any coord I guess.
moveEvent, does not execute for me, when i move item to bag or from bag to another container.

Combination of movement scripts and database functions.

I have no clue to how to script it, but generally I would check the movement of the item, either going in or out of the inventory, then increase/decrease the cap of the player with a sql/database query.

in 0.3.7 these are functions I'd attempt to use..

Code:
function onAddItem(cid, moveitem, tileitem, position)
function onRemoveItem(cid, moveitem, tileitem, position)
getContainerSize(uid)
getContainerCap(uid)
getContainerCapById(itemid)
getContainerItem(uid, slot)
doPlayerSetMaxCapacity(cid, cap)
isItemContainer(itemid)
isContainer(uid)
getItemWeight(uid[, precise])
getItemWeightById(itemid, count[, precise])

Unsure if 1.x has these functions, but they probably have them, just under different names possibly.

Good luck!

Xikini
as i stated above, moveitem and removeitem event does not seem to work.
and rest of them are functions what require what i cant initialize without event happening before.

Anyone has clue how toes TFS or client detect when coin is moved to bag?
 
Do you mind posting your script? Mine is working on every item move (Just printing values).

05c9150afa.png
 
Do you mind posting your script? Mine is working on every item move (Just printing values).

05c9150afa.png
does it work on moving the item from floor to BAG or BAG to BAG?
Because for me it dost not work.

What TFS you are using? (i use TFS 1.0)

The script (i tested all kinds of things)
Code:
function onAddItem(moveitem, tileitem, position)
    Uprint("moveitem",moveitem)
    Uprint("tileitem", tileitem)
    Uprint("position", position)
end

function onEquip(cid, item, slot)
    print(cid)
    Uprint("item",item)
    Uprint("slot", slot)
end

function onRemoveItem(moveitem, tileitem, pos)
    Uprint("moveitem",moveitem)
    Uprint("tileitem", tileitem)
    Uprint("position", pos)
end
 
I'm using TFS 1.2 (Latest I guess?) and yeah, it works moving for bag to bag.

First print: From player backpack to floor.
Second print: From a bag on the floor to another bag on the floor.
Third print: From ammo slot to floor.
Fourth print: From player backpack (from slot 2 of container), to ammo slot.
 
Oh i just realized player has some events too.

Player:onMoveItem(item, count, fromPosition, toPosition)

i think they should work.

Tomorrow will check it out.
 
yeah. It is the right thing what i was looking for xD
Code:
Player:onMoveItem(item, count, fromPosition, toPosition)
Most of the time I use the movements.xml for moving things.
I totally forgot about the player one, even though I have some system attached to it xD

Ty for help.
 
Back
Top