From b92fba15ece0d8af1aad1ca63fcb1b878f10180a Mon Sep 17 00:00:00 2001 From: Garry Newman Date: Fri, 9 Jun 2017 10:40:04 +0100 Subject: [PATCH] Added Inventory.GenerateItem --- Facepunch.Steamworks/Interfaces/Inventory.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Facepunch.Steamworks/Interfaces/Inventory.cs b/Facepunch.Steamworks/Interfaces/Inventory.cs index 2efa8e7..c833d27 100644 --- a/Facepunch.Steamworks/Interfaces/Inventory.cs +++ b/Facepunch.Steamworks/Interfaces/Inventory.cs @@ -360,5 +360,24 @@ namespace Facepunch.Steamworks return new Result( this, resultHandle, true ); } + + /// + /// This is used to grant a specific item to the user. This should + /// only be used for development prototyping, from a trusted server, + /// or if you don't care about hacked clients granting arbitrary items. + /// This call can be disabled by a setting on Steamworks. + /// + public Result GenerateItem( Definition target, int amount ) + { + SteamNative.SteamInventoryResult_t resultHandle = -1; + + var newItems = new SteamNative.SteamItemDef_t[] { new SteamNative.SteamItemDef_t() { Value = target.Id } }; + var newItemC = new uint[] { (uint) amount }; + + if ( !inventory.GenerateItems( ref resultHandle, newItems, newItemC, 1 ) ) + return null; + + return new Result( this, resultHandle, true ); + } } }