Search Unity

How can i save player inventory?? (UFPS + Easy save 2) (HELP !!)

Discussion in 'Scripting' started by okanust, Sep 5, 2017.

  1. okanust

    okanust

    Joined:
    May 22, 2017
    Posts:
    14
    Hi everyone,
    I'm new in forum and also c#. I have a problem about saving inventory.
    UFPS inventory.cs is like that.



    And all weapon in the HeroHD hierarchy. My problem is, i can't save item record when i change this area.
    I have searched web but all tutorials and examples are saving int, bool, string etc.. i can't find an example which shows how to save itemType or inventory.cs

    Maybe my problem is very easy for programmers but i don't know c# very much. The people who i have asked, gave short answers like do this, do that or try this, try that.
    Can anybody give me a more than others detailed solution?
    By the way, I wrote my issue both forums (UFPS and Easy save).
    Thanks..
     
  2. okanust

    okanust

    Joined:
    May 22, 2017
    Posts:
    14
    I think i wrote my issue in a wrong topic. sorry.. Can anyone move the right area? I think it should be in a "scripting"..
     
  3. fire7side

    fire7side

    Joined:
    Oct 15, 2012
    Posts:
    1,819
    This looks like some kind of game kit or something, so I think they would have thought of this problem. You might want to uncheck Reset on Respawn at the bottom, because it might be respawning in the next scene and you are losing the information.

    Otherwise it's a little tough to tell you what to do being it's some kind of kit or something and you are basically filling in the menu. It would be better to contact whoever you got it from.
     
  4. okanust

    okanust

    Joined:
    May 22, 2017
    Posts:
    14
    I wrote my issue both forum (easy save and UFPS) but nobody answered me..
     
  5. fire7side

    fire7side

    Joined:
    Oct 15, 2012
    Posts:
    1,819
    You can try posting the inventory script if it's not too long.
     
  6. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    I think in this particular situation, you might want to look up "DontDestroyOnLoad". That's what I would use for my inventory system, if it were meant to persist throughout the entire game.

    I think you should try to learn some scripting as you work in Unity. It will help you a lot. :)
     
  7. okanust

    okanust

    Joined:
    May 22, 2017
    Posts:
    14
    of course, but i will ask first to UFPS (opsive) because it's mercenary then do not get in trouble..

    I think this solution "DontDestroyOnLoad". it can work but the player buy the item in the shop then if he will quit the game, all inventory will disappear.. :(
     
  8. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    Right, well you were talking about leaving the area - i presumed you meant the scene. Of course to save to disk, is another story.. I've never used either of those 2 assets you're describing (mentioned). So maybe you want to try to figure that save asset first, and see if you can get it to work..? :)
     
  9. fire7side

    fire7side

    Joined:
    Oct 15, 2012
    Posts:
    1,819
    This is the trouble with these ready made solutions, the only people that can help you are the people that wrote them. If they won't answer, the only thing you can do is pour over the documentation and try to find a solution. Obviously, this has come up before and hopefully they have some kind of solution for it. It's hard to believe they have an fps game system that doesn't have some kind of game save.

    Go in the asset store, give it a one star rating, and complain that it either doesn't have a save system, or the documentation is written poorly. The guy seems to answer the posts in the asset store. And remember to mention you got no help in the forum.
     
    Last edited: Sep 11, 2017
  10. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Are you sure you got the right UFPS forum? @opsive is very responsive, often replying within a few minutes.

    Not every asset has or needs a save system. For example, with a shooter asset like UFPS, if you're making a deathmatch arena game, there's no need to save inventory.

    That said, if you have the Dialogue System for Unity, it has a general-purpose save system. It also has UFPS integration and EasySave integration, so you can use it to save UFPS inventory, stats, position, etc. If you don't have the Dialogue System, please feel free to download the free evaluation version and borrow the code from the included UFPS Support package. If only works as-is with the Dialogue System, but you can use whatever parts of the code you need in your own script if you like.
     
  11. okanust

    okanust

    Joined:
    May 22, 2017
    Posts:
    14
    Thanks for reply TonyLi. By the way opsive has answered the post in UFPS forum but we couldn't solve the problem as their suggestions.
     
  12. fire7side

    fire7side

    Joined:
    Oct 15, 2012
    Posts:
    1,819
    Then tell him that and ask why, or to give you another suggestion.
     
  13. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Ask them for a clarification. They may be able to suggest another solution. Then again it may be that what you're asking is outside the scope of the product. If that's the case, you can certainly ask them to consider expanding the scope of what the product is responsible for, but it's not appropriate to down-rate something for not including a feature that's out of scope. That's like leaving a bad review for a burger joint because they didn't also give you a free pizza with your burger.
     
  14. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    Thanks @TonyLi,

    I've been working with @okanust through email and I just don't have enough experience with save/load plugins. UFPS is a character controller so saving/loading is outside of the scope but at its core @okanust needs a solution that can use reflection to save the fields if an existing save system doesn't have direct UFPS integration. If @okanust plans on using the Dialogue System anyway that would be a good solution, otherwise if Easy Save can save using reflection then that should also work.
     
    TonyLi likes this.
  15. fire7side

    fire7side

    Joined:
    Oct 15, 2012
    Posts:
    1,819
    All he wants to do is save his inventory, I don't think it would be that hard for you to come up with a way.
     
  16. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Having written save subsystems (available in the Dialogue System) for several character controller assets, it's significantly more complicated than it would seem at first glance. There's quite a lot to synchronize to do it properly, and many users might not want the extra code in their character controller asset.
     
    opsive likes this.
  17. fire7side

    fire7side

    Joined:
    Oct 15, 2012
    Posts:
    1,819
    I doubt anyone will complain about a simple inventory save system. For most games like this, you save your inventory, save the scene you were in, and you can get by, sort of like a save point system. Now he basically has nothing.
     
    Last edited: Sep 14, 2017
  18. Laperen

    Laperen

    Joined:
    Feb 1, 2016
    Posts:
    1,065
    If it is possible to add objects into the inventory through script while in-game, its a matter of saving something onto playerprefs or some other persistent file. Maybe a string acting as a key, telling the inventory what was in it when the game starts.
     
  19. okanust

    okanust

    Joined:
    May 22, 2017
    Posts:
    14
    First of all, i never think about giving a low rate to UFPS beside this i think UFPS is a very great asset.. i told @opsive about this before.

    As @fire7side said i want to save inventory. UFPS is one of the most sold asset in store and used in a lot of game as a result of this, i thought that someone was solved this issue and could help me..But i think this is a big problem :)
     
  20. fire7side

    fire7side

    Joined:
    Oct 15, 2012
    Posts:
    1,819
    It's not a big problem. You only have to save a couple fields, but we can't do it for you without the code because we aren't telepathic. You have the code, instead of looking for easy save or whatever, just do some homework.
    https://unity3d.com/learn/tutorials/topics/scripting/persistence-saving-and-loading-data

    Your inventory script is vp_player inventory, and it probably has a list of items in it. You have to iterate the list and save the items, and then load them again by instantiating them, and adding them back into inventory. Granted this is something the author could easily do and he's just lazy, so take it upon yourself. And if you ask me, he took your money and ran. If I bought it and couldn't get help for an inventory save, I would give it zero stars.
    What do you do now? Buy how many save systems and hope for the best? Or make a game that can't even save between levels? If he didn't provide one, he should have made sure it was compatible with a popular one so you don't have to guess. UFPS fail.
     
    Last edited: Sep 14, 2017
  21. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Pardon the necro post, but this thread was left unresolved.

    As I mentioned earlier, saving and loading is more complicated than simply reading and writing data fields. When loading, components and other systems need to be put into their correct runtime states, too. There's now an inexpensive add-on that takes care of all that: Save System for UFPS
     
    opsive likes this.