Ofcourse.. you should make a object for every item, thats how you do it.
|
Hey guys, I've developed a game where each "item" had its own serial code. Meaning every time I spawned an item, it was its own item.
So lets say I spawned an item, it would have a serial code: 001. Then I spawned the same item again, and this item would have serial code: 002. Even when I restart server code, the serial code stays.
I was wondering if this was achievable in RSPS? I tried a couple of times doing it but I could never get my head around it :/
I know there are several people smarter than me at Java and some just have a mind for thinking outside the box. Maybe one of you can suggest a way this may be possible
Reason why I would like this: Would make "Draining", "Corrupting", and other sorts of things like this much easier to do.
Ofcourse.. you should make a object for every item, thats how you do it.
Creating an object wouldnt wok as it would just be destroyed when the server restarted.
You will need to have a data file that when the server is restarted it will populate the file with the necessary information for when the server is back online you read the file and build the objects from the given information, then spawn them.
Its pretty obvious that the item should be saved to the character file on logout, just like every rsps released does. Didn't think I had to point that out. Ever heard of Json object serialization?
Create a object of a item, ex:
Now on logout loop trough the container the item is in and save it ex:Code:addItem(new Item(id, amount));
From here its simple to add more things such as 'charge'.Code:for (Item item : inventoryContainer.items) { item.getId() item.getSize() }
Or just use the Json libary for object serialization, it saves the state of the object in Json format.
Okay I understand what you all mean, but this would mean that I would have to tell the server, or save the name of the player along with the item eh to indicate who has what with what charge right?
If this game you've developed was also in Java wouldn't it make sense to use the same concept with the RSPS item container system?
don't bother putting all that effort into something like this. it'd be extremely difficult to maintain, and you'd just end up wasting memory and resources for something that isn't even needed
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |