///-----------------\\\ // [ ON ITEM CRAFT ] \\ ///-----------------\\\ #region [ ON ITEM CRAFT ] private void OnItemCraft(ItemCraftTask task, BasePlayer player, BasePlayer crafter) { if (!PlayerExists(player)) { InitPlayerData(player); } if (!playerSkinData.Players[player.userID].skinIDS.Contains(task.skinID.ToString()) && task.skinID != 0) { InternalItemInfo e = new InternalItemInfo(); int skinIDIndex = skinListIDS.IndexOf(Convert.ToUInt32(task.skinID)); e.Shortname = skinListSHORTNAMES[skinIDIndex]; if (skinListWIDS[skinIDIndex] > 0) { e.SkinWID = skinListWIDS[skinIDIndex]; } else { e.SkinWID = skinListIDS[skinIDIndex]; } e.SkinID = skinListIDS[skinIDIndex]; playerSkinData.Players[player.userID].skinWIDS.Add(e.SkinWID.ToString()); playerSkinData.Players[player.userID].skinIDS.Add(e.SkinID.ToString()); playerSkinData.Players[player.userID].skinShortnames.Add(e.Shortname.ToString()); playerSkinData.Players[player.userID].skinNames.Add(skinListNAMES[skinIDIndex]); PrintMessage(player, "SkinAddOnCraft", skinListNAMES[skinIDIndex], e.SkinID, playerSkinData.Players[player.userID].skinIDS.Count); } }
public bool FastTrackTask(int taskID) { if (queue.Count == 0) { return(false); } ItemCraftTask value = queue.First.Value; if (value == null) { return(false); } ItemCraftTask itemCraftTask = queue.FirstOrDefault((ItemCraftTask x) => x.taskUID == taskID && !x.cancelled); if (itemCraftTask == null) { return(false); } if (itemCraftTask == value) { return(false); } value.endTime = 0f; queue.Remove(itemCraftTask); queue.AddFirst(itemCraftTask); itemCraftTask.owner.Command("note.craft_fasttracked", taskID); return(true); }
private static bool InstantBulkCraft(BasePlayer player, ItemCraftTask task) { int amount = task.amount * task.blueprint.amountToCreate; int stacksize = task.blueprint.targetItem.stackable; var stacks = Enumerable.Repeat(stacksize, amount / stacksize); // credit Norn if (amount % stacksize > 0) { stacks = stacks.Concat(Enumerable.Repeat(amount % stacksize, 1)); } if (stacks.Count() > 1) { foreach (int stack_amount in stacks) { Item item = ItemManager.CreateByItemID(task.blueprint.targetItem.itemid, stack_amount); if (!player.inventory.GiveItem(item)) { item.Drop(player.GetDropPosition(), player.GetDropVelocity()); } else { player.Command(string.Concat(new object[] { "note.inv ", task.blueprint.targetItem.itemid, " ", stack_amount }), new object[0]); } } } else { player.inventory.GiveItem(ItemManager.CreateByItemID(task.blueprint.targetItem.itemid, amount)); player.Command(string.Concat(new object[] { "note.inv ", task.blueprint.targetItem.itemid, " ", amount }), new object[0]); } return(false); }
private void OnItemCraftCancelled(ItemCraftTask task) { BasePlayer player = task.owner; ItemDefinition item = task.blueprint.targetItem; Log("crafting", "CraftingCancelled", player.displayName.Sanitize(), player.UserIDString, task.amount, item.displayName.english); }
/// <summary> /// Gets called when a player finished crafting an item /// </summary> /// <param name="task">The item crafting task info.</param> /// <param name="item">The crafted item.</param> void OnItemCraftFinished(ItemCraftTask task, Item item) { if (!task.owner.IPlayer.HasPermission(PERM_USE)) { return; } ulong skinId; var userSettings = _settings[task.owner.userID]; if (userSettings.Skins.TryGetValue(item.info.shortname, out skinId)) { // } else { if (!userSettings.RandomCraftingSkin) { return; } var skins = GetSkinsForItem(item.info.shortname); if (skins == null) { return; } skinId = GetRandomElement(skins).WorkshopdId; } SetSkin(item, skinId); }
object OnItemCraft(ItemCraftTask task) { if (!enabled) { return(null); } ItemDefinition def = task.blueprint.targetItem; if (isBlocked(def.displayName.english, def.shortname)) { task.cancelled = true; if (craftRefund) { RefundIngredients(task.blueprint, task.owner, task.amount); } if (sendMessages) { SendReply(task.owner, messages["You may not craft this (restricted)"]); } return(false); } return(null); }
private void GiveItem(BasePlayer player, ItemCraftTask task, ItemDefinition def, List <int> stacks, int taskSkinID) { var skin = ItemDefinition.FindSkin(def.itemid, taskSkinID); if (config.split == false) { var final = 0; foreach (var stack in stacks) { final += stack; } var item = ItemManager.Create(def, final, skin); player.GiveItem(item); Interface.CallHook("OnItemCraftFinished", task, item); } else { foreach (var stack in stacks) { var item = ItemManager.Create(def, stack, skin); player.GiveItem(item); Interface.CallHook("OnItemCraftFinished", task, item); } } }
private object OnItemCraft(ItemCraftTask task, BasePlayer crafter) { var itemname = task.blueprint.targetItem.displayName.english; if (AdminInstantCraft && task.owner.net.connection.authLevel == 2) { task.endTime = 1f; } if (ModeratorInstantCraft && task.owner.net.connection.authLevel == 1) { task.endTime = 1f; } if (!BlockedItems.Contains(itemname)) { return(null); } task.cancelled = true; SendChatMessage(crafter, CraftBlockedItem, itemname); foreach (var amount in task.blueprint.ingredients) { crafter.inventory.GiveItem(ItemManager.CreateByItemID(amount.itemid, (int)amount.amount * task.amount)); } return(false); }
public SerializedItemCraftTask(ItemCraftTask craftTask) { amount = craftTask.amount; skinDefinition = craftTask.skinID; itemID = craftTask.blueprint.targetItem.itemid; TakenItems = craftTask.takenItems; SerializeItems(); }
void AdjustCraftingTime(BasePlayer player, ItemBlueprint bp, ItemCraftTask task) { var multipler = 1.0f; if (!c_craftingMultiplierBlacklist.Contains(bp.targetItem.shortname) && player.net.connection.authLevel >= c_craftingMultiplierAuthLevel) { multipler = bp.targetItem.shortname == "gunpowder" ? c_gunpowderMultiplier : c_craftingMultiplier; } if (UserIsAuthorizedOnAnyCupboard(player) && !c_benchMultiplierBlacklist.Contains(bp.targetItem.shortname) && player.net.connection.authLevel >= c_benchMultiplierAuthLevel) { multipler *= c_benchMultiplier; } var crafter = player.inventory.crafting; if (CanBulk(player) && !c_bulkCraftBlacklist.Contains(bp.targetItem.shortname)) { int amount = task.blueprint.amountToCreate * task.amount; int stackable = 1; try { stackable = GetStackSize(task.blueprint.targetItem.shortname); } catch { } if (amount / stackable > 30) { player.ChatMessage($"Could not bulkcraft {task.blueprint.targetItem.displayName.translated} X{amount}, try a smaller amount."); return; } var tick = DateTime.Now; GiveItemsToPlayer(player, task.blueprint.targetItem.shortname, task.skinID, amount); var elapsed = (DateTime.Now - tick).TotalMilliseconds; if (elapsed > 10) { Puts($"Warning: Bulkcraft took {elapsed} ms"); } crafter.CancelTask(task.taskUID, false); task.cancelled = true; return; } float stockTime = 0; var ret = r_blueprintTimes.TryGetValue(bp.targetItem.itemid, out stockTime); if (ret) { bp.time = stockTime * multipler; } else { Puts($"Dictionary access error trying to get stock crafting time for <{bp.targetItem.shortname}>"); } }
private void OnItemCraftFinished(ItemCraftTask task, Item item) { if (configData.Debug) { Puts("OnItemCraftFinished called!"); } if (!(item.GetHeldEntity() is BaseProjectile)) { return; } if (!HasAnyRight(task.owner)) { return; } WeaponStats weaponStats = new WeaponStats(); if (configData.Weapons.ContainsKey(item.info.shortname)) { weaponStats = configData.Weapons[item.info.shortname]; } if (!weaponStats.settingactive) { return; } BaseProjectile bp = item.GetHeldEntity() as BaseProjectile; if (bp != null) { if (HasRight(task.owner, "maxammo") || HasRight(task.owner, "all")) { bp.primaryMagazine.capacity = weaponStats.maxammo; } if (HasRight(task.owner, "preload") || HasRight(task.owner, "all")) { bp.primaryMagazine.contents = weaponStats.preload; } if (HasRight(task.owner, "ammotype") || HasRight(task.owner, "all")) { ItemDefinition ammo = ItemManager.FindItemDefinition(weaponStats.ammotype); if (ammo != null) { bp.primaryMagazine.ammoType = ammo; } } if (HasRight(task.owner, "maxcondition") || HasRight(task.owner, "all")) { item._maxCondition = Convert.ToSingle(weaponStats.maxcondition); item._condition = Convert.ToSingle(weaponStats.maxcondition); } if (weaponStats.skinid > 0) { item.skin = Convert.ToUInt64(weaponStats.skinid); item.GetHeldEntity().skinID = Convert.ToUInt64(weaponStats.skinid); } } }
private void ReturnCraft(ItemCraftTask task, BasePlayer crafter) { task.cancelled = true; Message(crafter.IPlayer, "NoInvSpace"); foreach (var item in task.takenItems.Where(x => x.amount > 0)) { task.owner.GiveItem(item); } }
// scale the task based on the tickrate and boost/penalty void ScaleTask(ItemCraftTask task, float factor, bool requireBench) { task.endTime -= (tickrate * factor); // update player with remaining time (adjusted for current crafting rate) float remaining = (task.endTime - Time.realtimeSinceStartup) / (1f + factor); task.owner.Command("note.craft_start", new object[] { task.taskUID, remaining, task.amount }); }
object OnItemCraft(ItemCraftTask task, BasePlayer player) { SendReply(player, RAPrefix + "<color=red>Crafting is not allowed!</color>" + RASuffix); task.cancelled = true; foreach (var amount in task.blueprint.ingredients) { player.inventory.GiveItem(amount.itemid, (int)amount.amount * task.amount, false); } return(false); }
void OnItemCraftCancelled(ItemCraftTask task) { ulong skinid; if (!skinupdate.TryGetValue(task, out skinid)) { return; } skinupdate.Remove(task); }
private object OnItemCraft(ItemCraftTask task, BasePlayer player, Item item) { var @event = new RustPlayerCraftingItemEvent(new RustPlayer(player), task.blueprint, task.amount) { IsCancelled = task.cancelled }; Emit(@event); return(@event.IsCancelled ? (object)false : null); }
private void OnItemCraftCancelled(ItemCraftTask task) { foreach (var entry in task.takenItems) { if (componentList.ContainsKey(entry.info.shortname)) { timer.Once(0.01f, () => entry.RemoveFromContainer()); } } }
// ItemCrafter.CraftItem() public static bool PlayerStartCrafting(ItemCrafter self, ItemBlueprint bp, BasePlayer owner, ProtoBuf.Item.InstanceData instanceData = null) { ItemBlueprint bpcopy = new ItemBlueprint(); bpcopy.amountToCreate = bp.amountToCreate; bpcopy.defaultBlueprint = bp.defaultBlueprint; bpcopy.ingredients = bp.ingredients; bpcopy.rarity = bp.rarity; bpcopy.targetItem = bp.targetItem; bpcopy.time = bp.time / Server.GetInstance().CraftingTimeScale; bpcopy.userCraftable = bp.userCraftable; CraftEvent ce = new CraftEvent(self, bpcopy, owner, instanceData); OnPlayerStartCrafting.OnNext(ce); if (!self.CanCraft(bpcopy, 1)) { return(false); } if (ce.Cancel) { if (ce.cancelReason != "") { owner.SendConsoleCommand("chat.add", 0, String.Format("{0}: {1}", Server.server_message_name.ColorText("fa5"), ce.cancelReason)); } return(false); } self.taskUID++; ItemCraftTask itemCraftTask = new ItemCraftTask(); itemCraftTask.blueprint = bpcopy; if (!ce.FreeCraft) { foreach (ItemAmount current in bpcopy.ingredients) { float amount = current.amount; foreach (ItemContainer current2 in self.containers) { amount -= current2.Take(itemCraftTask.ingredients, current.itemid, (int)amount); } } } itemCraftTask.endTime = 0; itemCraftTask.taskUID = self.taskUID; itemCraftTask.owner = owner; itemCraftTask.instanceData = instanceData; self.queue.Enqueue(itemCraftTask); if (itemCraftTask.owner != null) { itemCraftTask.owner.Command(String.Format("note.craft_add {0} {1}", itemCraftTask.taskUID, itemCraftTask.blueprint.targetItem.itemid)); } return(true); }
private object OnItemCraft(ItemCraftTask itemCraftTask, BasePlayer player, Item item) { if (player == null) { return(null); } if (!permission.UserHasPermission(player.UserIDString, PERMISSION_USE)) { return(null); } int multiplier; if (enabledMultiplier.TryGetValue(player.userID, out multiplier) && multiplier > 1) { var itemCrafter = player.inventory.crafting; if (itemCrafter == null) { return(null); } var blueprint = itemCraftTask.blueprint; if (blueprint == null || blueprint.targetItem == null) { return(null); } var existing = configData.itemList.Contains(blueprint.targetItem.shortname); if (configData.useBlacklist ? existing : !existing) { Print(player, Lang("IsBlocked", player.UserIDString)); return(null); } var amount = itemCraftTask.amount * multiplier; if (CanAffordCraftMultiplier(itemCrafter, blueprint, amount - itemCraftTask.amount)) { CollectIngredients(itemCrafter, blueprint, itemCraftTask, amount - itemCraftTask.amount, player); itemCraftTask.amount = amount; } else { Print(player, Lang("CantAfford", player.UserIDString)); return(null); } itemCrafter.queue.AddLast(itemCraftTask); if (itemCraftTask.owner != null) { itemCraftTask.owner.Command("note.craft_add", itemCraftTask.taskUID, itemCraftTask.blueprint.targetItem.itemid, itemCraftTask.amount, itemCraftTask.skinID); } return(false); } return(null); }
void OnItemCraftFinished(ItemCraftTask task, Item item) { if (item.info.itemid != papermapdef.itemid) { return; } var player = task.owner; if (player == null) { return; } var steamid = player.userID.ToString(); if (cfg_auto_message) { SendReply(player, GetMsg("You may use /pmap to save and load personnal saved maps.", steamid)); } string reason = string.Empty; MapEntity map = null; reason = GetMapEntity(item, out map); if (reason != string.Empty) { SendReply(player, GetMsg(reason, steamid)); return; } if (cfg_map_user_auto) { var PlayerData = new Dictionary <string, PaperMap>(); var success = PlayerDatabase.Call("GetPlayerDataRaw", player.userID.ToString(), "PersonnalMap"); if (success is string) { PlayerData = JsonConvert.DeserializeObject <Dictionary <string, PaperMap> >((string)success); } if (PlayerData.ContainsKey("auto")) { map.fogImages = PlayerData["auto"].ImageFog; map.paintImages = PlayerData["auto"].ImagePaint; return; } } if (cfg_auto_default_map && default_map != null) { map.fogImages = default_map.ImageFog; map.paintImages = default_map.ImagePaint; } }
void OnItemCraftFinished(ItemCraftTask task, Item item) { BasePlayer player = task.owner; if (player.inventory.containerMain.itemList.Count > 23 && player.inventory.containerBelt.itemList.Count > 5) { task.cancelled = true; SendReply(player, GetMessage("CPB_CantCraft", player.UserIDString)); Puts(player.displayName + " tried to craft an item, but their inventory was full!"); } }
private void OnItemCraftFinished(ItemCraftTask task, Item item) { var player = task.owner; if (player == null) { return; } Log("crafting", Lang("ItemCrafted", null, player.displayName, player.UserIDString, item.amount, item.info.displayName.english)); }
void OnItemCraftFinished(ItemCraftTask task, Item item) { BasePlayer player = task.owner; var crafter = player.inventory.crafting; if (crafter.queue.Count == 0) { return; } AdjustCraftingTime(player, crafter.queue.First().blueprint, task); }
private void OnItemCraftCancelled(ItemCraftTask task) { foreach (Item item in task.takenItems.ToList()) { if (_config.Options.BlockedItems.Contains(item.info.shortname)) { task.takenItems.Remove(item); item.Remove(); } } }
private void OnItemCraft(ItemCraftTask task, BasePlayer crafter) { var skins = GetSkins(task.blueprint.targetItem); if (skins.Count < 1 || task.skinID != 0) { return; } randomizedTasks.Add(task.taskUID); task.skinID = skins.GetRandom(); }
void OnItemCraftFinished(ItemCraftTask task, Item item) { try{ BasePlayer spelaren = (BasePlayer)task.owner; Puts(spelaren.userID.ToString() + " earned " + (craftmoney).ToString() + " coins from crafting a item."); addcoin(spelaren.userID.ToString(), craftmoney); } catch (System.Exception e) { Puts("Tried doing task.owner on a none player crafted item."); } }
public void FinishCrafting(ItemCraftTask task) { task.amount--; task.numCrafted++; ulong skin = ItemDefinition.FindSkin(task.blueprint.targetItem.itemid, task.skinID); Item item = ItemManager.CreateByItemID(task.blueprint.targetItem.itemid, 1, skin); item.amount = task.blueprint.amountToCreate; if (item.hasCondition && task.conditionScale != 1f) { item.maxCondition *= task.conditionScale; item.condition = item.maxCondition; } item.OnVirginSpawn(); foreach (ItemAmount ingredient in task.blueprint.ingredients) { int num = (int)ingredient.amount; if (task.takenItems == null) { continue; } foreach (Item takenItem in task.takenItems) { if (takenItem.info == ingredient.itemDef) { int num2 = Mathf.Min(takenItem.amount, num); takenItem.UseItem(num); num -= num2; } int num3 = 0; } } Facepunch.Rust.Analytics.Crafting(task.blueprint.targetItem.shortname, task.skinID); task.owner.Command("note.craft_done", task.taskUID, 1, task.amount); Interface.CallHook("OnItemCraftFinished", task, item); if (task.instanceData != null) { item.instanceData = task.instanceData; } if (!string.IsNullOrEmpty(task.blueprint.UnlockAchievment)) { task.owner.GiveAchievement(task.blueprint.UnlockAchievment); } if (task.owner.inventory.GiveItem(item)) { task.owner.Command("note.inv", item.info.itemid, item.amount); return; } ItemContainer itemContainer = containers.First(); task.owner.Command("note.inv", item.info.itemid, item.amount); task.owner.Command("note.inv", item.info.itemid, -item.amount); item.Drop(itemContainer.dropPosition, itemContainer.dropVelocity); }
public void FinishCrafting(ItemCraftTask task) { --task.amount; ++task.numCrafted; ulong skin = ItemDefinition.FindSkin(task.blueprint.targetItem.itemid, task.skinID); Item byItemId = ItemManager.CreateByItemID(task.blueprint.targetItem.itemid, 1, skin); byItemId.amount = task.blueprint.amountToCreate; if (byItemId.hasCondition && (double)task.conditionScale != 1.0) { byItemId.maxCondition *= task.conditionScale; byItemId.condition = byItemId.maxCondition; } byItemId.OnVirginSpawn(); foreach (ItemAmount ingredient in task.blueprint.ingredients) { int amount = (int)ingredient.amount; if (task.takenItems != null) { foreach (Item takenItem in task.takenItems) { if (Object.op_Equality((Object)takenItem.info, (Object)ingredient.itemDef)) { int num = Mathf.Min(takenItem.amount, amount); takenItem.UseItem(amount); amount -= num; } } } } Analytics.Crafting(task.blueprint.targetItem.shortname, task.skinID); task.owner.Command("note.craft_done", (object)task.taskUID, (object)1, (object)task.amount); Interface.CallHook("OnItemCraftFinished", (object)task, (object)byItemId); if (task.instanceData != null) { byItemId.instanceData = task.instanceData; } if (!string.IsNullOrEmpty(task.blueprint.UnlockAchievment)) { task.owner.GiveAchievement(task.blueprint.UnlockAchievment); } if (task.owner.inventory.GiveItem(byItemId, (ItemContainer)null)) { task.owner.Command("note.inv", (object)byItemId.info.itemid, (object)byItemId.amount); } else { ItemContainer itemContainer = this.containers.First <ItemContainer>(); task.owner.Command("note.inv", (object)byItemId.info.itemid, (object)byItemId.amount); task.owner.Command("note.inv", (object)byItemId.info.itemid, (object)-byItemId.amount); byItemId.Drop(itemContainer.dropPosition, itemContainer.dropVelocity, (Quaternion)null); } }
private void Merge(ItemCraftTask task, ref List <TempData> data) { var amount = task.amount; var item = task.blueprint.targetItem; foreach (var p in data.Where(x => x.Uid == item.itemid && x.Stack - x.Amount > 0)) { if (amount == 0) { break; } var toStack = p.Stack - p.Amount; if (amount > toStack) { p.Amount += toStack; amount -= toStack; } else { p.Amount += amount; amount = 0; break; } } if (amount != 0) { var count = amount / item.stackable; for (var i = 0; i < count; i++) { data.Add(new TempData { Uid = item.itemid, Amount = item.stackable, Stack = item.stackable }); } if (amount % item.stackable != 0) { data.Add(new TempData { Uid = item.itemid, Amount = amount % item.stackable, Stack = item.stackable }); } } }
void OnItemCraftFinished(ItemCraftTask task, Item item) { bool alreadyHasStack = false; ItemContainer belt = task.owner.inventory.containerBelt; ItemContainer main = task.owner.inventory.containerMain; foreach (Item item2 in main.itemList) { if (item.info.itemid == item2.info.itemid) { if (item2.info.stackable > 1) { alreadyHasStack = true; } } } if (alreadyHasStack == false) { if (item.info.category == ItemCategory.Weapon || item.info.category == ItemCategory.Tool || item.info.category == ItemCategory.Medical || item.info.category == ItemCategory.Food || item.info.category == ItemCategory.Construction) { if (!belt.SlotTaken(0)) { timer.Once(0.1f, () => item.MoveToContainer(belt, 0)); } else if (!belt.SlotTaken(1)) { timer.Once(0.1f, () => item.MoveToContainer(belt, 1)); } else if (!belt.SlotTaken(2)) { timer.Once(0.1f, () => item.MoveToContainer(belt, 2)); } else if (!belt.SlotTaken(3)) { timer.Once(0.1f, () => item.MoveToContainer(belt, 3)); } else if (!belt.SlotTaken(4)) { timer.Once(0.1f, () => item.MoveToContainer(belt, 4)); } else if (!belt.SlotTaken(5)) { timer.Once(0.1f, () => item.MoveToContainer(belt, 5)); } } } }
// ItemCrafter.CraftItem() public static bool PlayerStartCrafting(ItemCrafter self, ItemBlueprint bp, BasePlayer owner, ProtoBuf.Item.InstanceData instanceData = null, int amount = 1) { /*ItemBlueprint bpcopy = new ItemBlueprint(); bpcopy.amountToCreate = bp.amountToCreate; bpcopy.defaultBlueprint = bp.defaultBlueprint; bpcopy.ingredients = bp.ingredients; bpcopy.rarity = bp.rarity; bpcopy.targetItem = bp.targetItem; bpcopy.time = bp.time / Server.GetInstance().CraftingTimeScale; bpcopy.userCraftable = bp.userCraftable;*/ CraftEvent ce = new CraftEvent(self, bp, owner, instanceData, amount); OnPlayerStartCrafting.OnNext(ce); if (!self.CanCraft(bp, 1)) { return false; } if (ce.Cancel) { if (ce.cancelReason != "") owner.SendConsoleCommand("chat.add", 0, String.Format("{0}: {1}", Server.server_message_name.ColorText("fa5"), ce.cancelReason)); return false; } self.taskUID++; ItemCraftTask itemCraftTask = new ItemCraftTask(); itemCraftTask.blueprint = bp; if (!ce.FreeCraft) { List<Item> list = new List<Item>(); foreach (ItemAmount current in bp.ingredients) { int amount2 = (int)current.amount * amount; foreach (ItemContainer current2 in self.containers) { amount2 -= current2.Take(list, current.itemid, amount2); } } foreach (Item current2 in list) { current2.Remove(0f); } } itemCraftTask.endTime = 0; itemCraftTask.taskUID = self.taskUID; itemCraftTask.owner = owner; itemCraftTask.instanceData = instanceData; itemCraftTask.amount = amount; self.queue.Enqueue(itemCraftTask); if (itemCraftTask.owner != null) { itemCraftTask.owner.Command("note.craft_add", new object[] { itemCraftTask.taskUID, itemCraftTask.blueprint.targetItem.itemid, amount }); } return true; }
public ItemCraftTask OnItemCraft(ItemCraftTask item) { var itemName = item.blueprint.targetItem.displayName.translated; if (!ItemTable.ContainsKey(itemName)) return null; var blueprintTime = ItemTable[itemName].BlueprintTime; BasePlayer player = item.owner; var rpgInfo = RPGInfo(player); float craftingTime = blueprintTime; float craftingReducer = RPGHelper.GetCraftingReducer(rpgInfo); var amountToReduce = (craftingTime*craftingReducer); float reducedCraftingTime = craftingTime - amountToReduce; item.blueprint.time = reducedCraftingTime; if(rpgInfo.Preferences.ShowCraftMessage) ChatMessage(player, String.Format("Crafting will end in {0:F} seconds. Reduced in {1:F} seconds", reducedCraftingTime, amountToReduce)); return item; }
private void OnItemCraft(ItemCraftTask item) { HookCalled("OnItemCraft"); // TODO: Print item crafting }
object OnItemCraft(ItemCraftTask task, BasePlayer player) { SendReply(player, RAPrefix + "<color=red>Crafting is not allowed!</color>" + RASuffix); task.cancelled = true; foreach (var amount in task.blueprint.ingredients) player.inventory.GiveItem(amount.itemid, (int)amount.amount * task.amount, false); return false; }