Hmm, maybe this is how RuneScape does it.

It uses the walking packet to check if you're close to a wilderness area THEN uses process when you are close to the entrance/exit of wilderness.

Then it also checks if you are in wilderness in attack button like:

Code:
if (wilderness()) {
attackPlayer();
} else {
sendMessage("You cannot attack players when you're not in the wilderness!");
}
amirite

then if you leave area while lagging it might not remove button cuz ur too far.