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

TFS 1.X+ Check how much item with weaponType have in bag.

leoloves2

New Member
Joined
Jan 2, 2018
Messages
25
Reaction score
4
I would like to know if there is a function or way to check how many items with weaponType (sword, axe or club) are in the player's bag.
On my server, my idea is that each weapon has its spells and cooldown, so that's why I want to limit the number of weapons that the player can have inside the bag.
I tried using onMoveItem, but I couldn't understand how it works properly. My idea was to use a storage to know whether or not the player can pick up another weapon. So if the item went to the bag it added 1 to the storage value, if the item left the bag it removed 1 from the storage. But I couldn't understand how the function works, especially fromPosition, toPosition, fromCylinder, toCylinder.
I'm wondering if there's a way to check if there's a certain type of weapon inside the bag because that way it'll be easier to see if the player can get the item or not.

Sorry if it wasn't very clear, I'm using the translator. Thanks anyway.
 
I would like to know if there is a function or way to check how many items with weaponType (sword, axe or club) are in the player's bag.
On my server, my idea is that each weapon has its spells and cooldown, so that's why I want to limit the number of weapons that the player can have inside the bag.
I tried using onMoveItem, but I couldn't understand how it works properly. My idea was to use a storage to know whether or not the player can pick up another weapon. So if the item went to the bag it added 1 to the storage value, if the item left the bag it removed 1 from the storage. But I couldn't understand how the function works, especially fromPosition, toPosition, fromCylinder, toCylinder.
I'm wondering if there's a way to check if there's a certain type of weapon inside the bag because that way it'll be easier to see if the player can get the item or not.

Sorry if it wasn't very clear, I'm using the translator. Thanks anyway.
Logically, I wouldn't do it this way.

The issue is that checking all items in a container(and deeper if recursive), is just too heavy for a heavily executed callback such as onMoveItem. It's a huge waste of computation.

What I would do instead is, create a custom item attribute called "cooldown", and then in onMoveItem, if the toCylinder is a slot, and the item has a cooldown, reject it.

Or dont use custom attributes at all, and just use a table in memory to store the timestamps/cooldowns, you can create keys such as "playerId:itemUUID"
 
Logically, I wouldn't do it this way.

The issue is that checking all items in a container(and deeper if recursive), is just too heavy for a heavily executed callback such as onMoveItem. It's a huge waste of computation.

What I would do instead is, create a custom item attribute called "cooldown", and then in onMoveItem, if the toCylinder is a slot, and the item has a cooldown, reject it.

Or dont use custom attributes at all, and just use a table in memory to store the timestamps/cooldowns, you can create keys such as "playerId:itemUUID"
i will try, thanks for support
 
Back
Top