crazykid080 14 Posted October 1, 2020 I've been trying to grab a reference to Zaff in Varrock but for some reason it keeps returning null even when I'm in his shop. I've tried filtering by name and ID, but neither works, am I missing something? For reference this is my filter code Entity zaff = GameObjects.closest(check -> check.getName().contains("Zaff"));
Neffarion 486 Posted October 1, 2020 You should try null checking the "check" before doing the name verification
crazykid080 14 Author Posted October 1, 2020 I'm not 100% sure what you mean by null checking the check, I assume it's not as simple as just adding check != null correct?
AsBakedAsCake 204 Posted October 1, 2020 6 minutes ago, crazykid080 said: I've been trying to grab a reference to Zaff in Varrock but for some reason it keeps returning null even when I'm in his shop. I've tried filtering by name and ID, but neither works, am I missing something? For reference this is my filter code Entity zaff = GameObjects.closest(check -> check.getName().contains("Zaff")); Also, why are you using GameObject? Zaff is an NPC/Shop, not an object. NPC Zaff = NPCs.closest("Zaff")); if(Zaff ! = null){ interact(); } This is pretty basic stuff, I'd recommend checking out some scripting tutorials
Hmm 31 Posted October 1, 2020 11 minutes ago, crazykid080 said: I'm not 100% sure what you mean by null checking the check, I assume it's not as simple as just adding check != null correct? Yes, he meant that. NPC zaff = NPCs.closest(check -> check != null && check.getName().contains("Zaff")); Then you can interact by doing: zaff.interact("Trade"); - if you wanted to trade him.
crazykid080 14 Author Posted October 1, 2020 9 minutes ago, AsBakedAsCake said: Also, why are you using GameObject? Zaff is an NPC/Shop, not an object. I knew I was missing something! I've looked at some of the tutorials but I didn't see anything about NPCs, probably just missed it
Recommended Posts
Archived
This topic is now archived and is closed to further replies.