[help] Kiki's source - Saving Inventory

Joined
Aug 14, 2006
Messages
144
Reaction score
9
I would just like to know how to go about saving the players inventory on logout etc. I have it saving all their character info etc, im just not sure about what to do for the inventory.
So far i got in Player::save() for the inventory items:
Code:
    int invSize = inv->getItemsSize();
    for(int i=0;i<invSize;i++){
        Item* item = inv->getItem(i);
            //Do saving equipment stuff here
    }
If you must know, it is v11, not v6.

Although im not sure if it will work yet, as i havnt tested it.
Would be great if someone could point me in the right direction.
 
Re: Kiki's source - Saving Inventory

I think it would not be the best solution, but I think you could do this:
before the "for" that goes into all slots and seeing if the item exists and what item is, etc... make a delete from inventory where user_id = id and bag = -1.
then, into the "for" you make the inserts. to dont make a lot of inserts, you could try and see if its possible to make "insert blablabla; insert blablablabla2; insert blablabla3; ... ; insert into blablablaN;" and execute it outside after the "for".
Like I said, its not the better solution, but would work great(in theory at least).
 
Re: Kiki's source - Saving Inventory

Wow, man. someone actually figured out the code! Well, I personally haven't started saving through isc yet, but thats what you need to do. it has to be done on the character server on log out. the control for disconnect is in the connection project files.
 
Thanks for the input, i wasnt sure my method was the right way to go, and i also wasnt sure whether to delete all the entries in the table and re-insert them, or whether to check if they already exist.

And it saves everything on logout, except for the inventory, which i am working on right now.
 
Back