Hi,
I do not use the IsCrafting :
Lua
=> Displays the message when the player does not craft.Code:if player.isCrafting then self:SendMessage(player, self.Config.Messages.Crafting) return end
C#
=> Type `BasePlayer' does not contain a definition for `IsCrafting' and no extension method `IsCrafting' of type `BasePlayer' could be found. Are you missing an assembly reference?Code:if (player.IsCrafting()) { SendReply(player, cantusewhilecraft); return; }
Using IsCrafting? (C#/Lua)
Discussion in 'Rust Development' started by Loup-des-Neiges, Feb 7, 2016.
-
There is field, property or method to use directly to see if a player is crafting or not, but you can check if the crafting queue is empty or not. The crafting queue is part of the ItemCrafter class and should be accessible by using `player.inventory.crafting.queue`.
-
Displays "self.Config.Messages.Crafting" in both cases : /Code:
#LUA if player.inventory.crafting.queue then self:SendMessage(player, self.Config.Messages.Crafting) return end -
That queue is an object of the type Queue<ItemCraftTask>, you still need to check if it has any values in it or not to determine if the user is crafting or not. just checking the queue will basically just do a null check and it won't every be null, it will always be a queue but it will just not always hold values.
-
Thank you !Code:
if player.inventory.crafting.queue.Count > 0 then
Last edited by a moderator: Feb 8, 2016
