mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2026-08-01 14:39:13 -06:00
check which bank is active, and change the secondbank flag to inactivebank
This commit is contained in:
parent
7b52dd1e6c
commit
ae028a20f3
1 changed files with 21 additions and 12 deletions
|
|
@ -264,30 +264,39 @@ class ContainerisedItem(val container: core.game.container.Container?, val itemI
|
|||
}
|
||||
|
||||
/**
|
||||
* Check if player has the specified item ID equipped, in inventory, in their bank, or in their POH storage.
|
||||
* Check if player has the specified item ID equipped, in inventory, in their active bank, or in their POH storage.
|
||||
* @param id The item ID to check
|
||||
* @param checkSecondBank Whether to check the player's second bank (default false).
|
||||
* @param checkInactiveBank Whether to check the player's inactive bank (default false).
|
||||
* @param checkPOH Whether to check a player's POH storage (default false).
|
||||
* @return A ContainerisedItem containing the container and the item ID if found, otherwise ContainerisedItem(null, -1) if not found
|
||||
*/
|
||||
@JvmOverloads
|
||||
fun hasAnItem(player: Player, id: Int, checkSecondBank: Boolean = false, checkPOH: Boolean = false): ContainerisedItem {
|
||||
return hasAnItem(player, arrayOf(id), checkSecondBank, checkPOH)
|
||||
fun hasAnItem(player: Player, id: Int, checkInactiveBank: Boolean = false, checkPOH: Boolean = false): ContainerisedItem {
|
||||
return hasAnItem(player, arrayOf(id), checkInactiveBank, checkPOH)
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if player has any of the specified item IDs equipped, in inventory, in their bank, or in their POH storage.
|
||||
* Check if player has any of the specified item IDs equipped, in inventory, in their active bank, or in their POH storage.
|
||||
* @param ids An array of item IDs to check
|
||||
* @param checkSecondBank Whether to check the player's second bank (default false).
|
||||
* @param checkInactiveBank Whether to check the player's inactive bank (default false).
|
||||
* @param checkPOH Whether to check a player's POH storage (default false).
|
||||
* @return A ContainerisedItem containing the container and the item ID if found, otherwise ContainerisedItem(null, -1) if not found
|
||||
*/
|
||||
fun hasAnItem(player: Player, ids: Array<Int>, checkSecondBank: Boolean = false, checkPOH: Boolean = false): ContainerisedItem {
|
||||
// Search bank/equip/inv and return if item is found there.
|
||||
val searchSpace = if (checkSecondBank) {
|
||||
arrayOf(player.inventory, player.equipment, player.bankPrimary, player.bankSecondary)
|
||||
fun hasAnItem(player: Player, ids: Array<Int>, checkInactiveBank: Boolean = false, checkPOH: Boolean = false): ContainerisedItem {
|
||||
// Gets which bank account is active.
|
||||
val (active, inactive) = if (isUsingSecondaryBankAccount(player)) {
|
||||
// Active // Inactive
|
||||
player.bankSecondary to player.bankPrimary
|
||||
} else {
|
||||
arrayOf(player.inventory, player.equipment, player.bankPrimary)
|
||||
// Active // Inactive
|
||||
player.bankPrimary to player.bankSecondary
|
||||
}
|
||||
|
||||
// Search bank/equip/inv and return if item is found there.
|
||||
val searchSpace = if (checkInactiveBank) {
|
||||
arrayOf(player.inventory, player.equipment, active, inactive)
|
||||
} else {
|
||||
arrayOf(player.inventory, player.equipment, active)
|
||||
}
|
||||
for (container in searchSpace) {
|
||||
for (id in ids) {
|
||||
|
|
@ -2784,7 +2793,7 @@ fun toggleBankAccount(player: Player) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Checks if a player is currentl using their secondary bank account.
|
||||
* Checks if a player is currently using their secondary bank account.
|
||||
*
|
||||
* @author vddCore
|
||||
* @param player The player whose bank account toggle state to inspect.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue