Hi all! I'm trying to close the study of blueprints.
Please tell me the following code will work correctly?
Maybe there is an easier way?Code:void OnConsumableUse(Item item) { if (item.IsBlueprint() && item.info.itemid != null) { BasePlayer player = item.GetOwnerPlayer(); if (player.userID != null) { var playerInfo = SingletonComponent<ServerMgr>.Instance.persistance.GetPlayerInfo(player.userID); if (playerInfo != null) { playerInfo.blueprints.complete.Remove(item.info.itemid); SingletonComponent<ServerMgr>.Instance.persistance.SetPlayerInfo(player.userID, playerInfo); player.SendNetworkUpdateImmediate(); //SendReply(player, "...") //player.inventory.GiveItem(ItemManager.CreateByItemID(item.info.itemid, 1, true)); } } } }
Solved Stopping study of blueprints?
Discussion in 'Rust Development' started by Antirelax, Feb 27, 2016.
-
I added you on steam, if I didnt add the right person here is my account : Steam Community :: DylanSMR
[DOUBLEPOST=1456615648][/DOUBLEPOST]I fixed it up a bit | If you want help add me via steam ^^^^^
Code:using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Runtime.CompilerServices; using UnityEngine;namespace Oxide.Plugins { [Info("Consume", "DylanSMR", "1.0.0")] [Description("test")] class Consume : RustPlugin { void OnConsumableUse(Item item) { if (item.HasFlag(Item.Flag.Blueprint)) { BasePlayer player = item.GetOwnerPlayer(); Erase(player); SendReply(player, "BPS erased"); } } void Erase(BasePlayer player) { var targetPlayer = player; var data = ServerMgr.Instance.persistance.GetPlayerInfo(targetPlayer.userID); data.blueprints = null; PlayerBlueprints.InitializePersistance(data); ServerMgr.Instance.persistance.SetPlayerInfo(targetPlayer.userID, data); targetPlayer.SendFullSnapshot(); SendReply(player, "BPS erased"); } } }
Last edited by a moderator: Feb 27, 2016 -
Your code perfectly clears the blueprints(all) of player, but I'm trying stopping the study of particular blueprint.
My code it's doing, but I'm not sure that 100% correct. -
Code:
namespace Oxide.Plugins { [Info("Consume", "DylanSMR", "1.0.0")] [Description("test")] class Consume : RustPlugin { void OnConsumableUse(Item item) { BasePlayer player = item.GetOwnerPlayer(); var playerInfo = SingletonComponent<ServerMgr>.Instance.persistance.GetPlayerInfo(player.userID); if (player.userID != null) { if (item.HasFlag(Item.Flag.Blueprint)) { playerInfo.blueprints.complete.Remove(item.info.itemid); SingletonComponent<ServerMgr>.Instance.persistance.SetPlayerInfo(player.userID, playerInfo); player.SendNetworkUpdateImmediate(); } else { return; } } } } }
Last edited by a moderator: Feb 28, 2016