public interface IHeldItem : IInventoryItem
function On_Command(PLayer, cmd, args) {
if(cmd == "showmods") {
var itemmods = Player.Inventory.InternalInventory.activeItem.itemMods;
for(var i=0; i < itemmods.length; i++) {
Player.Message("Mod" + i + ": " + itemmods[i].name);
}
}
}
Only in the active item ? And there's no way in the world to get the mods from the others ? That's a shame :CThe Interface for HeldItem extends the Interface for InventoryItem.C#:public interface IHeldItem : IInventoryItem
That means you will only find this IHeldItem object when a player is holding the item, which means you can find the mod attached through this object, only when the player is holding the weapon.
I know where it's located:
JavaScript:function On_Command(PLayer, cmd, args) { if(cmd == "showmods") { var itemmods = Player.Inventory.InternalInventory.activeItem.itemMods; for(var i=0; i < itemmods.length; i++) { Player.Message("Mod" + i + ": " + itemmods[i].name); } } }
Well, thanks a lot !I don't know if there is another way. I just shared what I knew.
How can we ?At runtime(with jint, magma, ironpython), you can get it for any weapon, but at compile time you would need to cast the IInventoryItems to a type of: BulletWeaponDataBlock+ITEM_TYPE...
function On_Command(Player, cmd, args) {
if(cmd == "showmods") {
var items = Player.Inventory.Items;
var barItems = Player.Inventory.BarItems;
var imods;
for(var i=0; i < items.Length; i++) {
try { imods = items[i].RInventoryItem.itemMods; } catch (ignore) { }
for(var j = 0; j < imods.Length; j++) {
if(imods[j].name != null) UnityEngine.Debug.Log(items[i].Name + " has " + imods[j].name);
}
}
for(var k=0; k < barItems.Length; k++) {
try { imods = barItems[k].RInventoryItem.itemMods; } catch (ignore) { }
for(var l = 0; l < imods.Length; l++) {
if(imods[l].name != null) UnityEngine.Debug.Log(barItems[k].Name + " has " + imods[l].name);
}
}
}
}
[DEBUG] [CHAT-CMD] "Balu" executed "/showmods"
M4 has Flashlight Mod
M4 has Holo sight
M4 has Silencer
M4 has Laser Sight
Bolt Action Rifle has Laser Sight
Bolt Action Rifle has Holo sight
Bolt Action Rifle has Flashlight Mod
Bolt Action Rifle has Silencer
9mm Pistol has Silencer
9mm Pistol has Flashlight Mod
9mm Pistol has Holo sight
9mm Pistol has Laser Sight
Shotgun has Silencer
Shotgun has Holo sight
Shotgun has Flashlight Mod
No wayyyyyyy ! You are a genius !! I'm gonna test this out right now.JavaScript:function On_Command(Player, cmd, args) { if(cmd == "showmods") { var items = Player.Inventory.Items; var barItems = Player.Inventory.BarItems; var imods; for(var i=0; i < items.Length; i++) { try { imods = items[i].RInventoryItem.itemMods; } catch (ignore) { } for(var j = 0; j < imods.Length; j++) { if(imods[j].name != null) UnityEngine.Debug.Log(items[i].Name + " has " + imods[j].name); } } for(var k=0; k < barItems.Length; k++) { try { imods = barItems[k].RInventoryItem.itemMods; } catch (ignore) { } for(var l = 0; l < imods.Length; l++) { if(imods[l].name != null) UnityEngine.Debug.Log(barItems[k].Name + " has " + imods[l].name); } } } }INI:[DEBUG] [CHAT-CMD] "Balu" executed "/showmods" M4 has Flashlight Mod M4 has Holo sight M4 has Silencer M4 has Laser Sight Bolt Action Rifle has Laser Sight Bolt Action Rifle has Holo sight Bolt Action Rifle has Flashlight Mod Bolt Action Rifle has Silencer 9mm Pistol has Silencer 9mm Pistol has Flashlight Mod 9mm Pistol has Holo sight 9mm Pistol has Laser Sight Shotgun has Silencer Shotgun has Holo sight Shotgun has Flashlight Mod
Do a pull req with C# code. You may want to create a method like that in the Util, or in the Inv classJavaScript:function On_Command(Player, cmd, args) { if(cmd == "showmods") { var items = Player.Inventory.Items; var barItems = Player.Inventory.BarItems; var imods; for(var i=0; i < items.Length; i++) { try { imods = items[i].RInventoryItem.itemMods; } catch (ignore) { } for(var j = 0; j < imods.Length; j++) { if(imods[j].name != null) UnityEngine.Debug.Log(items[i].Name + " has " + imods[j].name); } } for(var k=0; k < barItems.Length; k++) { try { imods = barItems[k].RInventoryItem.itemMods; } catch (ignore) { } for(var l = 0; l < imods.Length; l++) { if(imods[l].name != null) UnityEngine.Debug.Log(barItems[k].Name + " has " + imods[l].name); } } } }INI:[DEBUG] [CHAT-CMD] "Balu" executed "/showmods" M4 has Flashlight Mod M4 has Holo sight M4 has Silencer M4 has Laser Sight Bolt Action Rifle has Laser Sight Bolt Action Rifle has Holo sight Bolt Action Rifle has Flashlight Mod Bolt Action Rifle has Silencer 9mm Pistol has Silencer 9mm Pistol has Flashlight Mod 9mm Pistol has Holo sight 9mm Pistol has Laser Sight Shotgun has Silencer Shotgun has Holo sight Shotgun has Flashlight Mod
that's what I'm talking about:Do a pull req with C# code. You may want to create a method like that in the Util, or in the Inv class
'ITEM_TYPE' is a private sealed class in BulletWeaponDataBlock, I don't know how to cast to that type at compile timeAt runtime(with jint, magma, ironpython), you can get it for any weapon, but at compile time you would need to cast the IInventoryItems to a type of: BulletWeaponDataBlock+ITEM_TYPE...
function On_Command(Player, cmd, args) {
if(cmd == "showmods") {
var type;
Util.TryFindType("SaveableInventory");
var saveable = UnityEngine.Object.FindObjectsOfType(type);
var imods;
for(var i=0; i < saveable.Length; i++) {
// ?
}
}
}
You must patch the assembly to make it public, same as was done for all the private fields we need to access.that's what I'm talking about:
'ITEM_TYPE' is a private sealed class in BulletWeaponDataBlock, I don't know how to cast to that type at compile time
Util.TryFindType("SaveableInventory", type);JavaScript:function On_Command(Player, cmd, args) { if(cmd == "showmods") { var type; Util.TryFindType("SaveableInventory"); var saveable = UnityEngine.Object.FindObjectsOfType(type); var imods; for(var i=0; i < saveable.Length; i++) { // ? } } }
function On_Command(Player, cmd, args) {
if(cmd == "showmods") {
var type;
Util.TryFindType("SaveableInventory", type);
// var type = Util.TryFindReturnType("SaveableInventory");
var saveables = UnityEngine.Object.FindObjectsOfType(type);
var imods;
var currentItem;
for(var i=0; i < saveables.Length; i++) {
for(var j = 0; j < saveables[i].slotCount; j++) {
if(saveables[i].GetItem(j, currentItem)) {
try { imods = currentItem.itemMods; } catch (ignore) { }
for(var l = 0; l < imods.Length; l++) {
if(imods[l].name != null) UnityEngine.Debug.Log(currentItem.datablock.name + " has " + imods[l].name);
}
}
}
}
}
}
I tried quite a few things by now, no luck. I will try to gather some cecil doc on that tomorrow.You must patch the assembly to make it public, same as was done for all the private fields we need to access.
I'm changing these now.that's what I'm talking about:
'ITEM_TYPE' is a private sealed class in BulletWeaponDataBlock, I don't know how to cast to that type at compile time