Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Wipe Items

Hello again,
What i'm looking for is the hash which all items are stored in, so I can delete all of a user's items (I have an online game)
Simply because it saves data (switches, etc) in the save file, but items are received from the server.
So yeah, where is it stored and what's the most efficient way of clearing it?
I only ask because I'm sick of going through and comparing variables, aha.
Thanks guys.
 

Ares

Member

I am guessing you're using rmxp? It's very useful to mention the engine in either the title or the first post.

If it is rmxp:
Items are stored in $game_party.items, but you need an attribute accessor for it before you can modify it.
so in class Game_Party add:
[rgss]attr_accessor :items
[/rgss]
Then you can do the following to delete all the user's items:
[rgss]$game_party.items.clear
[/rgss]

note: $game_party.items returns a hash with the following structure:
[rgss]@items = { item_id => amount, item_id => amount }
[/rgss]
note 2: This was done from the top of my head so there might be some things did wrong but essentially it works like this.
 
I cant believe myself. . . I've been using $game_party.items constantly and never though of that. . . makes me really doubt my scripts now!
Thanks a heap Ares!
*Mental note: don't ask for help at 3 in the morning*
Oh, and yes, sorry. I am using RMXP.
Thanks for your understanding :)

1 more thing,
If I don't want the Items + Armours + Weapons to save to the file, how would I go about excluding them from the save?
I can't just remove the Marshal.dump($game_party, file)
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top