Add Item Gun Custom Slot & Condition

C#:
Inventory Pinventory = player.Inventory.InternalInventory
#Get Player inventory
ItemDataBlock itemlookup = DatablockDictionary.GetByName("M4");
#Look up weapon

IInventoryItem itemdata = Pinventory.AddItem(itemlookup, int slot, int amount);
#Add weapon to player inventory

itemdata.SetUses(int count);
#Set how much ammo is loaded in the weapon
itemdata.SetTotalModSlotCount(int count);
#Set how many mods slots you'd like
itemdata.SetCondition(float amount);
#Set the condition of the weapon

ItemDataBlock weaponmod = DatablockDictionary.GetByName("Holo sight");
#Lookup attachments to add
itemdata.AddMod(weaponmod);
#Add it
weaponmod = DatablockDictionary.GetByName("Silencer");
#Repeat for more mods
itemdata.AddMod(weaponmod);
weaponmod = DatablockDictionary.GetByName("Laser Sight");
itemdata.AddMod(weaponmod);
Something like this
 
  • Winner
Reactions: salva
C#:
Inventory Pinventory = player.Inventory.InternalInventory
#Get Player inventory
ItemDataBlock itemlookup = DatablockDictionary.GetByName("M4");
#Look up weapon

IInventoryItem itemdata = Pinventory.AddItem(itemlookup, int slot, int amount);
#Add weapon to player inventory

itemdata.SetUses(int count);
#Set how much ammo is loaded in the weapon
itemdata.SetTotalModSlotCount(int count);
#Set how many mods slots you'd like
itemdata.SetCondition(float amount);
#Set the condition of the weapon

ItemDataBlock weaponmod = DatablockDictionary.GetByName("Holo sight");
#Lookup attachments to add
itemdata.AddMod(weaponmod);
#Add it
weaponmod = DatablockDictionary.GetByName("Silencer");
#Repeat for more mods
itemdata.AddMod(weaponmod);
weaponmod = DatablockDictionary.GetByName("Laser Sight");
itemdata.AddMod(weaponmod);
Something like this

Not Found method : itemdata.SetTotalModSlot & itemdata.AddMod

Thank
 
Not Found method : itemdata.SetTotalModSlot & itemdata.AddMod

Thank
Do you need to add weapon mods? If not use this:
C#:
Inventory Pinventory = player.Inventory.InternalInventory
#Get Player inventory
ItemDataBlock itemlookup = DatablockDictionary.GetByName("M4");
#Look up weapon

IInventoryItem itemdata = Pinventory.AddItem(itemlookup, int slot, int amount);
#Add weapon to player inventory

itemdata.SetUses(int count);
#Set how much ammo is loaded in the weapon
itemdata.SetCondition(float amount);
#Set the condition of the weapon
 
Do you need to add weapon mods? If not use this:
C#:
Inventory Pinventory = player.Inventory.InternalInventory
#Get Player inventory
ItemDataBlock itemlookup = DatablockDictionary.GetByName("M4");
#Look up weapon

IInventoryItem itemdata = Pinventory.AddItem(itemlookup, int slot, int amount);
#Add weapon to player inventory

itemdata.SetUses(int count);
#Set how much ammo is loaded in the weapon
itemdata.SetCondition(float amount);
#Set the condition of the weapon

i need add weapon mods & slot
 
Maybe this?
C#:
ItemDataBlock weapon = DatablockDictionary.GetByName("M4");
#Look up weapon

weapon.ITEM_TYPE.SetUses(int count);
#Set how much ammo is loaded in the weapon
weapon.ITEM_TYPE.SetTotalModSlotCount(int count);
#Set how many mods slots you'd like
weapon.ITEM_TYPE.SetCondition(float amount);
#Set the condition of the weapon

ItemDataBlock weaponmod = DatablockDictionary.GetByName("Holo sight");
#Lookup attachments to add
weapon.ITEM_TYPE.AddMod(weaponmod);
#Add it
weaponmod = DatablockDictionary.GetByName("Silencer");
#Repeat for more mods
weapon.ITEM_TYPE.AddMod(weaponmod);
weaponmod = DatablockDictionary.GetByName("Laser Sight");
weapon.ITEM_TYPE.AddMod(weaponmod);

player.Inventory.InternalInventory.AddItem(weapon, int slot, int amount);
#Add weapon to player inventory
#Setting the amount to a weapon being spawned in the hotbar, will override SetUses()
 
Maybe this?
C#:
ItemDataBlock weapon = DatablockDictionary.GetByName("M4");
#Look up weapon

weapon.ITEM_TYPE.SetUses(int count);
#Set how much ammo is loaded in the weapon
weapon.ITEM_TYPE.SetTotalModSlotCount(int count);
#Set how many mods slots you'd like
weapon.ITEM_TYPE.SetCondition(float amount);
#Set the condition of the weapon

ItemDataBlock weaponmod = DatablockDictionary.GetByName("Holo sight");
#Lookup attachments to add
weapon.ITEM_TYPE.AddMod(weaponmod);
#Add it
weaponmod = DatablockDictionary.GetByName("Silencer");
#Repeat for more mods
weapon.ITEM_TYPE.AddMod(weaponmod);
weaponmod = DatablockDictionary.GetByName("Laser Sight");
weapon.ITEM_TYPE.AddMod(weaponmod);

player.Inventory.InternalInventory.AddItem(weapon, int slot, int amount);
#Add weapon to player inventory
#Setting the amount to a weapon being spawned in the hotbar, will override SetUses()
what do you mean by ITEM_TYPE? - if you take the M4 has a type of bullet - although the weapon does not have this type
 
Maybe this?
C#:
ItemDataBlock weapon = DatablockDictionary.GetByName("M4");
#Look up weapon

weapon.ITEM_TYPE.SetUses(int count);
#Set how much ammo is loaded in the weapon
weapon.ITEM_TYPE.SetTotalModSlotCount(int count);
#Set how many mods slots you'd like
weapon.ITEM_TYPE.SetCondition(float amount);
#Set the condition of the weapon

ItemDataBlock weaponmod = DatablockDictionary.GetByName("Holo sight");
#Lookup attachments to add
weapon.ITEM_TYPE.AddMod(weaponmod);
#Add it
weaponmod = DatablockDictionary.GetByName("Silencer");
#Repeat for more mods
weapon.ITEM_TYPE.AddMod(weaponmod);
weaponmod = DatablockDictionary.GetByName("Laser Sight");
weapon.ITEM_TYPE.AddMod(weaponmod);

player.Inventory.InternalInventory.AddItem(weapon, int slot, int amount);
#Add weapon to player inventory
#Setting the amount to a weapon being spawned in the hotbar, will override SetUses()
I made a function for adding mods on a weapon,but can't yet how to update view model - mod well added,but to see him to draw a weapon in barslot
 
I made a function for adding mods on a weapon,but can't yet how to update view model - mod well added,but to see him to draw a weapon in barslot
So it adds mods to the weapon?
But can't get it to spawn in hotbar?
Try spawning it in slot 36 I think is the first slot in the hotbar (Check code of battlefield server kit for slot numbers)
 
So it adds mods to the weapon?
But can't get it to spawn in hotbar?
Try spawning it in slot 36 I think is the first slot in the hotbar (Check code of battlefield server kit for slot numbers)
No - the modifier I added - it was added to the weapon, but on the model itself it appears after rebooting the weapon
 
I think months ago I found something about the slot system, it was sorta complicated. I will see if I can dig it up on the week.
I already found a method - you can even use weapons to eat food in inventory: D
 
Which was the slot editing?


C#:
ItemDataBlock weapon = DatablockDictionary.GetByName(shootEvent.Player.Inventory.ActiveItem.Name);
Debug.Log(weapon);
ItemModDataBlock weaponmod = DatablockDictionary.GetByName("Holo sight")as ItemModDataBlock;
shootEvent.IBulletWeaponItem.AddMod(weaponmod);
weaponmod = DatablockDictionary.GetByName("Silencer")as ItemModDataBlock;
shootEvent.IBulletWeaponItem.AddMod(weaponmod);
weaponmod = DatablockDictionary.GetByName("Laser Sight")as ItemModDataBlock;
shootEvent.IBulletWeaponItem.AddMod(weaponmod)
shootEvent.IBulletWeaponItem.OnDeactivate();
shootEvent.IBulletWeaponItem.OnActivate();

@remove.tk
 
Last edited: