This is the full script, not a snippet. I don't know where else to post this. Apparently i'm not qualified to post in the regular Scripts subforum. Whatever.
AFK Fish Farming is based on leaving your game while it constantly right clicks. This script will detect that by comparing the player's location with their previous one (mind that locations also include yaw and pitch!), whenever a player casts a fishing rod. The way the script is posted right now, players will get kicked after casting a fishing rod 10 time in a row without changing their location at all.
This will never affect players who are fishing regularly. If you are paranoid though, you could increase the needed infraction count.
tl;dr = kicks AFK-fish farmers, doesn't affect regular fishing
AFK Fish Farming is based on leaving your game while it constantly right clicks. This script will detect that by comparing the player's location with their previous one (mind that locations also include yaw and pitch!), whenever a player casts a fishing rod. The way the script is posted right now, players will get kicked after casting a fishing rod 10 time in a row without changing their location at all.
This will never affect players who are fishing regularly. If you are paranoid though, you could increase the needed infraction count.
tl;dr = kicks AFK-fish farmers, doesn't affect regular fishing
code_language.skript:
on script load:
delete {aaf.location::*} and {aaf.infractions::*}
on fish:
if {aaf.location::%event-player%} is not set:
set {aaf.location::%event-player%} to event-player's location
else if {aaf.location::%event-player%} = event-player's location:
add 1 to {aaf.infractions::%event-player%}
if {aaf.infractions::%event-player%} >= 10:
delete {aaf.infractions::%event-player%} and {aaf.location::%event-player%}
kick event-player due to "AFK-Fishing is not allowed"
# broadcast "&c%event-player% has been kicked for AFK-Fishing"
else if {aaf.location::%event-player%} != event-player's location:
delete {aaf.infractions::%event-player%} and {aaf.location::%event-player%}