Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

Sign up now!

Resolved [solved] filter more than 1 ID ?

Joined
Mar 27, 2018
Messages
6
hey guys,

im trying to filter NPCs with IDs but im stuck :/

i can filter 1 ID. but i need to filter 2 Id´s

working: (filtering/blacklisting the mob with ID 1234)
Code:
//private int blacklist[] = {1234, 5678};

final Npc Mob = Npcs.newQuery().filter(npc -> npc.getId() != 1234 ).results().nearest();

not working: (Operator '!=' cannot be apllied to 'int', 'int[]')
Code:
private int blacklist[] = {1234, 5678};

final Npc Mob = Npcs.newQuery().filter(npc -> npc.getId() != blacklist ).results().nearest();

somebody got a clue ?
thx for reading
Fabibassi
 
Joined
Jan 17, 2017
Messages
312
hey guys,

im trying to filter NPCs with IDs but im stuck :/

i can filter 1 ID. but i need to filter 2 Id´s

working: (filtering/blacklisting the mob with ID 1234)
Code:
//private int blacklist[] = {1234, 5678};

final Npc Mob = Npcs.newQuery().filter(npc -> npc.getId() != 1234 ).results().nearest();

not working: (Operator '!=' cannot be apllied to 'int', 'int[]')
Code:
private int blacklist[] = {1234, 5678};

final Npc Mob = Npcs.newQuery().filter(npc -> npc.getId() != blacklist ).results().nearest();

somebody got a clue ?
thx for reading
Fabibassi

Checking for ids requires a singular int, not multiple, just like the error indicates. You can however make a int with a loop that iterates through the ints, but loops aren't really recommended. @Squidl There are some specific npcs that are almost identical except for their ids and colour; Name, combat level, interaction options etc.
 
Joined
Mar 27, 2018
Messages
6
thx so far - is there an option for something like " .!actions("Talk-to") " so i can blacklist the one that i can talk to ?

the mobs that i try to filter got the same name, same level, nearly same interactions, same colors etc. so thats the tricky part ^.^
 
hmm, sad that the bot stucks on this small problem :p

so 2x .filter(xxx) does not work as exspected :/
 
Joined
May 24, 2016
Messages
1,113
Solution one:

Code:
private List<Integer> blacklist = Arrays.asList(123, 124);

final Npc mob = Npcs.newQuery().names("Sheep").filter(npc -> !blacklist.contains(npc.getId())).results().nearest();

Solution two:

Code:
final Npc mob = Npcs.newQuery().filter(npc -> {
    int id = npc.getId();
    return id != 1 && id != 2;
}).names("Sheep").results().nearest();

Solution three (preferred!):

Code:
final Npc mob = Npcs.newQuery().names("Sheep").filter(npc -> {
            NpcDefinition definition = npc.getDefinition();
            return definition != null && !definition.getActions().contains("Talk-to"); // No idea if getActions() can be null, but if it is, you know what to do.
        }).results().nearest();

Solution four:

Learn Java and read the API thoroughly.
 
Last edited:
Joined
Mar 27, 2018
Messages
6
hey @auxi ,

got it to work with

Code:
final Npc Mob = Npcs.newQuery().filter(npc -> npc.getId() != 1234 || npc.getId() != 1234 ).results().nearest();

but thanks for all your 4(!) solutions. Option 4 is my fav, :) and thats what im doing in my free time atm.
im coding in Runemate since like 1 Week, having just basic Java experience and trying to learn everthing by my self and just doing it.

thx for solution 3! didnt know how to use the full .getDefinition since now, and understanding it now :p

have a nice day
Fabibassi
 
Top