Advertisement
Hygcgggnngff

gtag anti cheat

Aug 4th, 2024
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.53 KB | None | 0 0
  1. using UnityEngine;
  2.  
  3. public class GorillaTagAntiCheat : MonoBehaviour
  4. {
  5.     public float maxSpeed = 12f;          // Maximum speed the player is allowed to move
  6.     public float maxTeleportDistance = 10f;  // Maximum distance the player can move in a single frame without being flagged
  7.  
  8.     private Vector3 lastPosition;
  9.     private float lastCheckTime;
  10.  
  11.     void Start()
  12.     {
  13.         lastPosition = transform.position;
  14.         lastCheckTime = Time.time;
  15.     }
  16.  
  17.     void Update()
  18.     {
  19.         CheckPlayerSpeed();
  20.         CheckForTeleportation();
  21.     }
  22.  
  23.     void CheckPlayerSpeed()
  24.     {
  25.         float distanceTraveled = Vector3.Distance(lastPosition, transform.position);
  26.         float timeElapsed = Time.time - lastCheckTime;
  27.  
  28.         float currentSpeed = distanceTraveled / timeElapsed;
  29.  
  30.         if (currentSpeed > maxSpeed)
  31.         {
  32.             Debug.LogWarning("Speed hack detected!");
  33.             HandleCheating();
  34.         }
  35.  
  36.         lastPosition = transform.position;
  37.         lastCheckTime = Time.time;
  38.     }
  39.  
  40.     void CheckForTeleportation()
  41.     {
  42.         float distanceMoved = Vector3.Distance(lastPosition, transform.position);
  43.  
  44.         if (distanceMoved > maxTeleportDistance)
  45.         {
  46.             Debug.LogWarning("Teleportation detected!");
  47.             HandleCheating();
  48.         }
  49.  
  50.         lastPosition = transform.position;
  51.     }
  52.  
  53.     void HandleCheating()
  54.     {
  55.         // Handle cheating by logging, kicking, or taking other actions
  56.         Debug.Log("Cheating action handled.");
  57.     }
  58. }
  59.  
Tags: Anti
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement