I am trying to find out, if combatant has certain weapon, and I ran out of optios.
for (int i = 0; i < ORK.Weapons.Count; i++) { if(player.Inventory.HasWeapon(i,1,0)) - ALWAYS TRUE { } if(player.Inventory.HasWeapon(i,1,1)) - ALWAYS FALSE { } }
What is that last 'n' variable for? Or, maybe, I should use some other function for that? My player has weapon with realID '30' in his inventory, and I want somehow to find it our via the code.
index is the ID/index of the weapon (so you've got that correct). lvl is the level, I'd recommend using -1 if you aren't looking for a specific level. n is the quantity the inventory has to contain at least, so 0 will always be true.
Also, keep in mind that equipped weapons aren't in the inventory.
Post edited by gamingislove on
Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found. If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
You're calling the function
public bool HasWeapon(int index, int lvl, int n)
index is the ID/index of the weapon (so you've got that correct).
lvl is the level, I'd recommend using -1 if you aren't looking for a specific level.
n is the quantity the inventory has to contain at least, so 0 will always be true.
Also, keep in mind that equipped weapons aren't in the inventory.
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!