UCC Inventory Save

Piyush

Member
Hello Sir
Can you please tell me how can i save inventory of my game?
I am using Just UCC and playerprefs to save (I am using anticheat toolkit actually but its similar to playerprefs so lets take that as example here)
My game inventory has only 3-5 items
Let's say Torch, Axe, Grenade.

What i am trying to do is, when user pick up torch i save it as some variable using playerprefs that player has torch.
So how can i access that number of torch (grenades) user has in his inventory?
And when user quits the game start game again next time, I want to load the playerprefs and add the items to the inventory as last saved values
I hope you understand exactly what i meant Sir, Please guide. :)
I checked docs but i end up with no solutions
 
One more Important Question Sir,
When i pick up item via trigger I want to run a script to turn off my custom UI
But i can't do it
I am able to do OnTriggerEnter to show UI
But The moment i pick it up gameobject turns off and I cant turn off the UI
Can you please guide me on this in details, I saw some events that might help but I am not sure how to use them
 
So how can i access that number of torch (grenades) user has in his inventory?
The bottom of this page gives an example:


Can you please guide me on this in details, I saw some events that might help but I am not sure how to use them
You can use the OnInventoryPickupItemIdentifier event. The events page shows how you can use these events: https://opsive.com/support/documentation/ultimate-character-controller/programming-concepts/events/
 
The bottom of this page gives an example:



You can use the OnInventoryPickupItemIdentifier event. The events page shows how you can use these events: https://opsive.com/support/documentation/ultimate-character-controller/programming-concepts/events/
Okay Sir i will check events right now
For the above one i am using same example as given in the bottom
But in that it loops through all the items in the current inventory of the user, looping them all again and again might lead to performance issue i guess so i was thinking isnt there a direct line that gives exact number of grenades user has in its current inventory??
I mean no more looping and finding the item then comparing item definition (i did that compare item def to make sure got right item so save its number) and then saving
 
But in that it loops through all the items in the current inventory of the user, looping them all again and again might lead to performance issue i guess so i was thinking isnt there a direct line that gives exact number of grenades user has in its current inventory??
Looping is the correct approach. You are not going to see any sort of performance issues with that code.
 
Looping is the correct approach. You are not going to see any sort of performance issues with that code.
Oh Okay Sir, great then Thank you Sir :love:
I will try with events then if any issue i will let you know, it's first time i am going to use events in that way.

I am thinking to use EventHandler.RegisterEvent<IItemIdentifier, int, int>(m_Character, "OnInventoryAdjustItemIdentifierAmount", OnAdjustItemIdentifierAmount);
This event so whenever anything is updated in the inventory it will run the function to turn off UI and save latest inventory
 
Top