Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function sortAmmoQueueByQuantity(int ammoQ)
- debug.trace("iEquip_AmmoScript sortAmmoQueueByQuantity() called")
- int queueLength = jArray.count(ammoQ)
- int tempAmmoQ = jArray.objectWithSize(queueLength)
- int tempAmmoQReversed = jArray.objectWithSize(queueLength)
- int i = 0
- int ammoCount
- while i < queueLength
- ammoCount = jMap.getInt(jArray.getObj(ammoQ, i), "Count")
- jArray.setInt(tempAmmoQ, i, ammoCount)
- i += 1
- endWhile
- jArray.sort(tempAmmoQ)
- i = 0
- int iIndex = queueLength - 1
- while i < queueLength
- jArray.setInt(tempAmmoQReversed, i, iIndex)
- i += 1
- iIndex -= 1
- endWhile
- i = 0
- bool found
- while i < queueLength
- ammoCount = jArray.getInt(tempAmmoQReversed, i)
- iIndex = 0
- found = false
- while iIndex < queueLength && !found
- if ammoCount != jMap.getInt(jArray.getObj(ammoQ, iIndex), "Count")
- iIndex += 1
- else
- found = true
- endIf
- endWhile
- if i != iIndex
- jArray.swapItems(ammoQ, i, iIndex)
- endIf
- i += 1
- endWhile
- WC.selectBestAmmo()
- i = 0
- while i < queueLength
- debug.trace("iEquip_AmmoScript - sortAmmoQueueByQuantity(), sorted ammo array - i: " + i + ", " + jMap.getStr(jArray.getObj(ammoQ, i), "Name") + ", Count: " + jMap.getInt(jArray.getObj(ammoQ, i), "Count"))
- i += 1
- endWhile
- endFunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement