So I am trying to spawn in items on a player's hotbar but for some reason the ak spawns on the last slot while the rest of the items spawn in the correct slots just one down since the ak isnt there. I am using item.position = 1; to set the positition of the items but its not working.
Item item = ItemManager.CreateByName("rifle.ak", 1);
// If weapon fill magazine to capacity
var weapon = item.GetHeldEntity() as BaseProjectile;
if (weapon != null)
{
(item.GetHeldEntity() as BaseProjectile).primaryMagazine.contents = weapon.primaryMagazine.capacity;
}
//Attachments
bool silencer = true;
bool holosight = false;
if (silencer)
{
item.contents.AddItem(ItemManager.CreateByName("weapon.mod.silencer", 1).info, 1);
}
if (holosight)
{
item.contents.AddItem(ItemManager.CreateByName("weapon.mod.holosight", 1).info, 1);
}
// End Attachments
item.position = 1;
player.inventory.GiveItem(item);
//MEDS
Item item2 = ItemManager.CreateByName("syringe.medical", 2);
item.position = 2;
player.inventory.GiveItem(item2);
Item item3 = ItemManager.CreateByName("syringe.medical", 2);
item.position = 3;
player.inventory.GiveItem(item3);
Item item4 = ItemManager.CreateByName("syringe.medical", 2);
item.position = 4;
player.inventory.GiveItem(item4);
Item item5 = ItemManager.CreateByName("bandage", 3);
item.position = 5;
player.inventory.GiveItem(item5);