Hi, since the latest oxide mod update, my GiveItem function is not working anymore.
Code:Player.health = 50; Player.metabolism.calories.value = 100; Player.metabolism.hydration.value = 100; GiveItem(Player, ContainerType.Wear, "burlap.shirt", 1) GiveItem(Player, ContainerType.Wear, "burlap.trousers", 1) GiveItem(Player, ContainerType.Wear, "burlap.shoes", 1) GiveItem(Player, ContainerType.Belt, "torch", 1) GiveItem(Player, ContainerType.Belt, "stonehatchet", 1) GiveItem(Player, ContainerType.Belt, "stone.pickaxe", 1) GiveItem(Player, ContainerType.Belt, "bandage", 1) function GiveItem(Player, ContainerId, ItemName, Count) local Inventory = Player.inventory local Container = Inventory.containerMain if (ContainerId == ContainerType.Belt) then Container = Inventory.containerBelt elseif (ContainerId == ContainerType.Wear) then Container = Inventory.containerWear end local Item = global.ItemManager.CreateByName(ItemName, Count or 1) Inventory:GiveItem(Item, Container) end
GiveItem is not working anymore
Discussion in 'Rust Development' started by Inofix, Aug 14, 2015.
-
Wulf Community Admin
All of that is Rust code, so if it doesn't work anymore, it was from a Rust change.
-
Well I'm not on my main machine at the moment I don't have rust installed here. People on my server were complaining about the starting stuff that it doesn't work anymore. Player.inventory:Strip() doesn't work aswell, even tho Player is a valid object.
[DOUBLEPOST=1439577319][/DOUBLEPOST]Arite, when i run the code in "OnPlayerRespawned" delayed by 250ms, it's working fine.
Could it be possible that the OnPlayerSpawn hook pos gets called before the rust internal player gets initializied? -
For your first question about GiveItem it looks like it got broken so the way I get around that is by:
#Giving the player the item by itemID
BasePlayer.inventory.GiveItem(itemID, ammount, False)
#Getting the Item from inventory.
Item = BasePlayer.inventory.FindItemID(itemID)
#Moving the item to the container and slot I want it to go.
Item.MoveToContainer(inv.containerWear, 0, False)
