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);
Not Found method : itemdata.SetTotalModSlot & itemdata.AddModSomething like thisC#: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);
Do you need to add weapon mods? If not use this:Not Found method : itemdata.SetTotalModSlot & itemdata.AddMod
Thank
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 & slotDo 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 don't exactly know if there is a way to add slots, there must be.i need add weapon mods & slot
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 typeMaybe 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 barslotMaybe 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()
So it adds mods to the weapon?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
No - the modifier I added - it was added to the weapon, but on the model itself it appears after rebooting the weaponSo 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)
What's the code you're using?No - the modifier I added - it was added to the weapon, but on the model itself it appears after rebooting the weapon
I already found a method - you can even use weapons to eat food in inventory: DI 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.
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();