![]() |
Creating Stackable Items?
What would be the best way to create stackable items while still having different ID numbers on the items? I can't seem to figure out a way to do this, any ideas? Should I stack by name? I'm not really worried so much about weapons but things like lets say arrows, bullets, or whatever else that is stackable that you can't just put 1 in each inventory slot. I'm sure there is a way to do it, I'm just clueless on how. I haven't started scripting anything yet because I wanted to get all the details first so I don't get stuck half way through and have to start over. I'm currently just making something simple with no real purpose to learn from and expand on until I feel comfortable enough to do something for real. Any ideas on what the most efficient way would be to solve this?
Edit: Corrected some of my wording. |
I have thought about doing this, something like
NPC Code: 241234412414 being the ID. The only problem I see with doing it like that is if someone picks up more of an item they already have with a different ID how could I get it to stack? |
Why have a different ID for all items when you could just store type and quantity like normal people?
|
Oh O figured having unique ID's prevented duping, I guess I could just check the quantity of the item before dropping and such. From what I have seen a lot of people use ID's for items. If they can just check to see the quantity why do servers make ID's for items?
|
Quote:
|
so doing something like clientr.item.itemname = itemtype, quantity would be fine?
edit: also is it better to load all the item information for an item on login or as the player needs it? |
Quote:
Quote:
Just make sure if you change it later that it won't break scripts that assume that all items are already loaded. |
On Zodiac V2, I use a variable in my arcs called stackable as well as stack size.
If it's stackable, look for an empty stack based on the archetype and add to it taking into account max stack size, and creating a new stack if necessary. |
@mallard: I'll probably just do it when needed if it's not really that big of a deal. Thanks for the help.
Quote:
|
But it's kind of useless doing stacks if you don't implement a items held / bag restriction so that should be something else to consider before bothering with it.
|
Well, it could also be used to limit the amount of 1 item you can have couldn't it? like say you can have a maximum of 20 potions or something you could set the max stack. Also I had planned implementing a maximum amount of items held.
|
Yeah it could, so yeah you'll be fine :)
|
Alright, thanks to both of you.
|
Could someone tell me which one of these is right, or if both of them are wrong?
NPC Code: NPC Code: |
Quote:
If the player you want to manipulate has focus you would do something like this: PHP Code:
edit: Ideally it would probably be better to have the itemtype in the array, and have clientr.items.itemname = {itemtype, etc, etc}; That way, you can easily get all of the players items doing something like temp.items = clientr.items.getDynamicVarNames(); I have to go to class, hope this helped. |
Oh that was a typo, it was itemtype but i changed it to this clientr.item.(@ itemrealname) right after I posted because I thought of what you just mentioned. Also everything is currently serverside and everything is loading from an array.
|
| All times are GMT +2. The time now is 05:19 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.