I know anti cheats are not needed but I want to fix it up, This function works all well no problems it successfully prevents unauthorized teleportation, But when the player run and jumps then ceases all keyboard input the player is falsely flagged, How can I prevent this? Also player.getName(); is a prototype function
function Check_Packet_Behavior(player) {
try {
if (Database.get('cpbtoggle') !== 1 || player.hasTag(configuration.staff_tag)) return;
let last_x = scoreTest(player, 'lastpos_x');
let last_y = scoreTest(player, 'lastpos_y');
let last_z = scoreTest(player, 'lastpos_z');
const x = Math.floor(Math.abs(player.location.x));
const y = Math.floor(Math.abs(player.location.y));
const z = Math.floor(Math.abs(player.location.z));
const movementValue = 0.00;
let p_velocity = player.getVelocity();
const xyVelocity = Math.abs(p_velocity.x) + Math.abs(p_velocity.z);
const yVelocity = Math.abs(p_velocity.y);
// Anti-teleport.
if (xyVelocity <= movementValue && yVelocity <= movementValue) {
if (Math.abs(last_x - x) > movementValue || Math.abs(last_y - y) > movementValue || Math.abs(last_z - z) > movementValue) {
let name = player.getName();
tellrawStaff(`§¶§cUAC STAFF §6Bad Packet §b► §d${name} §¶§bflaged for Teleporting to\nX§7: §c${last_x} §bZ§7: §c${last_z}`);
TellRB(`flag_1`, `UAC Bad Packet ► ${name} flaged for invalid Position Spoof to x: ${x} zV: ${z}`);
tp(player, last_x, last_y, last_z);
return;
}
}
} catch (e) {
console.warn(JSON.stringify(e.stack), e);
}
};
export { Check_Packet_Behavior };