1. Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Anticheat Utility Snippets

Discussion in 'Snippets' started by Zoot, May 16, 2018.

  1. Zoot

    Zoot New Member

    Joined:
    Oct 21, 2017
    Messages:
    5
    Likes Received:
    2
    Medals:
    Tiered Potion
    Code (Skript):
    1. plural expression %player%'s active potion effects:
    2.     get:
    3.         return ...expression-1.getActivePotionEffects()
    4.  
    5. condition %player% (has|1¦does(n't| not) have) %potioneffecttype% %number%:
    6.     check:
    7.         if parse mark is 1:
    8.             loop expression-1's active potion effects:
    9.                 if loop-value.getType() = expression-2:
    10.                     if loop-value.getAmplifier() = expression-3:
    11.                         negate the condition
    12.             continue
    13.         else:
    14.             loop expression-1's active potion effects:
    15.                 if loop-value.getType() = expression-2:
    16.                     if loop-value.getAmplifier() = expression-3:
    17.                         continue
    Code (Skript):
    1. if player has speed 3:
    2. if player doesn't have strength 1:
    Skript latest && Skript-mirror latest

    Square function in expression
    Code (Skript):
    1. expression [the] square of %number%:
    2.     get:
    3.         if expression-1 != 0:
    4.             return (expression-1 * expression-1)
    5.         else:
    6.             return 0
    7.        
    8. expression %number% squared:
    9.     get:
    10.         if expression-1 != 0:
    11.             return (expression-1 * expression-1)
    12.         else:
    13.             return 0
    Code (Skript):
    1. broadcast "%square of 5%"
    2. if 5 squared = 25:
    Skript latest && Skript-mirror latest

    Better distance expressions
    Code (Skript):
    1. # Distance ignoring y-coordinate
    2. expression horizontal distance between %location% and %location%:
    3.     get:
    4.         set {_x1} to x-coordinate of expression-1
    5.         set {_z1} to z-coordinate of expression-1
    6.         set {_x2} to x-coordinate of expression-2
    7.         set {_z2} to z-coordinate of expression-2
    8.         set {_x3} to square of ({_x2} - {_x1})
    9.         set {_z3} to square of ({_z2} - {_z1})
    10.         set {_final} to {_x3} + {_z3}
    11.         set {_final} to sqrt({_final})
    12.         return {_final}
    13.  
    14. # Distance ignoring x and z coordinates
    15. expression vertical distance between %location% and %location%:
    16.     get:
    17.         set {_y1} to y-coordinate of expression-1
    18.         set {_y2} to y-coordinate of expression-2
    19.         return difference between {_y1} and {_y2}
    20.  
    21. # Returns an entity's location offset by his current velocity
    22. expression %entity%'s location minus velocity:
    23.     get:
    24.         set {_location} to expression-1's location
    25.         set {_velocity} to expression-1's velocity
    26.         return {_location} ~ {_velocity}
    27.    
    28. # Gets the distance between two entities minus the victim's velocity. The second expression should be the victim
    29. expression better entity distance between %entity% and %entity%:
    30.     get:
    31.         set {_first} to location of expression-1
    32.         set {_second} to expression-2's location minus velocity
    33.         return horizontal distance between {_first} and {_second}
    Code (Skript):
    1. on damage of player:
    2.     if better entity distance between attacker and victim > 6:
    3.         #
    4. if horizontal distance between {_block1} and {_block2} = 1:
    Skript && Skript-Mirror && Square expression above

    Non full blocks (Blocks that would change your altitude)
    Code (Skript):
    1. condition %block% (is|1¦is not) a full block:
    2.     check:
    3.         if parse mark is 0:
    4.             negate the condition
    5.         if expression-1 = any slab:0-7 or stairs or soul sand or cobblestone walls or snow layer or pistons or cobweb or ladder or vine or any trapdoor or any fence or any fence gate or lily pad or ender portal frame or enchantment table or ender chest or chest or trapped chest or anvil or daylight sensor or daylight detector inverted or hopper or any stained glass pane or any carpet or plain glass pane or cactus or cake block or redstone repeater or redstone comparator or brewing stand:
    6.             continue
    Code (Skript):
    1. on any movement:
    2.     if block under player is not a full block:
    3. on left click:
    4.     if clicked block is a full block:
    Latest Skript && Skript-Mirror

    Horizontal direction from location to location
    Code (Skript):
    1. expression horizontal direction from %location% to %location%:
    2.     get:
    3.         if world of expression-1 != world of expression-2:
    4.             return {_null}
    5.         else:
    6.             set {_x1} to x-coordinate of expression-1
    7.             set {_z1} to z-coordinate of expression-1
    8.             set {_x2} to x-coordinate of expression-2
    9.             set {_z2} to z-coordinate of expression-2
    10.             # If first location is further South && second location is further North
    11.             if {_z1} > {_z2}:
    12.                 # If first location is further East && second location is further West
    13.                 if {_x1} > {_x2}:
    14.                     return "North West"
    15.                 # If first location is further West && second location is further East
    16.                 if {_x1} < {_x2}:
    17.                     return "North East"
    18.                 # If first and second location are on the same X coordinate
    19.                 else:
    20.                     return "North"
    21.             # If first location is further North && second location is further South
    22.             if {_z1} < {_z2}:
    23.                 # If first location is further East && second location is further West
    24.                 if {_x1} > {_x2}:
    25.                     return "South West"
    26.                 # If first location is further West && second location is further East
    27.                 if {_x1} < {_x2}:
    28.                     return "South East"
    29.                 # If first and second location are on the same X coordinate
    30.                 else:
    31.                     return "South"
    32.             # If first and second location are on the same Z coordinate
    33.             else:
    34.                 # If first location is further East && second location is further West
    35.                 if {_x1} > {_x2}:
    36.                     return "West"
    37.                 # If first location is further West && second location is further East
    38.                 if {_x1} < {_x2}:
    39.                     return "East"
    Code (Skript):
    1. If horizontal direction from player's location and location of event-block = "North East":
    2.     # Player is north east of the event-block
    Latest Skript && Skript-Mirror

    Advanced ground check (70% of movement cheats can be detected with this)
    Code (Skript):
    1. player property ground state:
    2.     get:
    3.         set {_p} to expression-1
    4.         # Check if the ground packet is being sent by the player
    5.         if {_p}.isOnGround() = true:
    6.             # Could probably make this more advanced but this is fine
    7.             if block at {_p} != air:
    8.                 return true
    9.             else:
    10.                 set {_block} to block below {_p}
    11.                 set {_altdifference} to vertical distance between {_p} and {_block}
    12.              
    13.                 # Check if the player is on a solid block
    14.                 if {_altdifference} = 0.5:
    15.                     if {_block} != air:
    16.                         return true
    17.                     # If the block under the player isn't air, check all adjacent and diagonal blocks
    18.                     else:
    19.                         # Finds where the player is relative to the block under him
    20.                         set {_direction} to horizontal direction from {_block} to {_p}
    21.                         if {_direction} = "North East":
    22.                             loop blocks within location of {_block} and location of block 1 north 1 east of {_block}:
    23.                                 if loop-block is not air:
    24.                                     if horizontal distance between loop-block and {_block} = 1:
    25.                                         if horizontal distance between loop-block and {_p} <= 1:
    26.                                             return true
    27.                                     else if horizontal distance between loop-block and {_block} > 1:
    28.                                         if horizontal distance between loop-block and {_p} <= 1.5:
    29.                                             return true
    30.                         else if {_direction} = "North":
    31.                             loop blocks within location of {_block} and location of block 1 north of {_block}:
    32.                                 if loop-block is not air:
    33.                                     if horizontal distance between loop-block and {_block} = 1:
    34.                                         if horizontal distance between loop-block and {_p} <= 1:
    35.                                             return true
    36.                                     else if horizontal distance between loop-block and {_block} > 1:
    37.                                         if horizontal distance between loop-block and {_p} <= 1.5:
    38.                                             return true
    39.                         else if {_direction} = "North West":
    40.                             loop blocks within location of {_block} and location of block 1 north 1 west of {_block}:
    41.                                 if loop-block is not air:
    42.                                     if horizontal distance between loop-block and {_block} = 1:
    43.                                         if horizontal distance between loop-block and {_p} <= 1:
    44.                                             return true
    45.                                     else if horizontal distance between loop-block and {_block} > 1:
    46.                                         if horizontal distance between loop-block and {_p} <= 1.5:
    47.                                             return true
    48.                         else if {_direction} = "South East":
    49.                             loop blocks within location of {_block} and location of block 1 south 1 east of {_block}:
    50.                                 if loop-block is not air:
    51.                                     if horizontal distance between loop-block and {_block} = 1:
    52.                                         if horizontal distance between loop-block and {_p} <= 1:
    53.                                             return true
    54.                                     else if horizontal distance between loop-block and {_block} > 1:
    55.                                         if horizontal distance between loop-block and {_p} <= 1.5:
    56.                                             return true
    57.                         else if {_direction} = "South West":
    58.                             loop blocks within location of {_block} and location of block 1 south 1 west of {_block}:
    59.                                 if loop-block is not air:
    60.                                     if horizontal distance between loop-block and {_block} = 1:
    61.                                         if horizontal distance between loop-block and {_p} <= 1:
    62.                                             return true
    63.                                     else if horizontal distance between loop-block and {_block} > 1:
    64.                                         if horizontal distance between loop-block and {_p} <= 1.5:
    65.                                             return true
    66.                         else if {_direction} = "South":
    67.                             loop blocks within location of {_block} and location of block 1 south of {_block}:
    68.                                 if loop-block is not air:
    69.                                     if horizontal distance between loop-block and {_block} = 1:
    70.                                         if horizontal distance between loop-block and {_p} <= 1:
    71.                                             return true
    72.                                     else if horizontal distance between loop-block and {_block} > 1:
    73.                                         if horizontal distance between loop-block and {_p} <= 1.5:
    74.                                             return true
    75.                         else if {_direction} = "East":
    76.                             loop blocks within location of {_block} and location of block 1 east of {_block}:
    77.                                 if loop-block is not air:
    78.                                     if horizontal distance between loop-block and {_block} = 1:
    79.                                         if horizontal distance between loop-block and {_p} <= 1:
    80.                                             return true
    81.                                     else if horizontal distance between loop-block and {_block} > 1:
    82.                                         if horizontal distance between loop-block and {_p} <= 1.5:
    83.                                             return true
    84.                         else if {_direction} = "West":
    85.                             loop blocks within location of {_block} and location of block 1 west of {_block}:
    86.                                 if loop-block is not air:
    87.                                     if horizontal distance between loop-block and {_block} = 1:
    88.                                         if horizontal distance between loop-block and {_p} <= 1:
    89.                                             return true
    90.                                     else if horizontal distance between loop-block and {_block} > 1:
    91.                                         if horizontal distance between loop-block and {_p} <= 1.5:
    92.                                             return true
    93.                 # Checks if the player is on a non solid block or entity; slabs, snow layers, fences, and etc.    
    94.                 else:
    95.                     set {_block} to block above {_block}
    96.                     set {_direction} to horizontal direction from {_block} to {_p}
    97.                     if {_direction} = "North East":
    98.                         loop blocks within location of {_block} and location of block 1 north 1 east of {_block}:
    99.                             if loop-block is not a full block:
    100.                                 if horizontal distance between loop-block and {_block} = 1:
    101.                                     if horizontal distance between loop-block and {_p} <= 1:
    102.                                         return true
    103.                                 else if horizontal distance between loop-block and {_block} > 1:
    104.                                     if horizontal distance between loop-block and {_p} <= 1.5:
    105.                                         return true
    106.                     else if {_direction} = "North":
    107.                         loop blocks within location of {_block} and location of block 1 north of {_block}:
    108.                             if loop-block is not a full block:
    109.                                 if horizontal distance between loop-block and {_block} = 1:
    110.                                     if horizontal distance between loop-block and {_p} <= 1:
    111.                                         return true
    112.                                 else if horizontal distance between loop-block and {_block} > 1:
    113.                                     if horizontal distance between loop-block and {_p} <= 1.5:
    114.                                         return true
    115.                     else if {_direction} = "North West":
    116.                         loop blocks within location of {_block} and location of block 1 north 1 west of {_block}:
    117.                             if loop-block is not a full block:
    118.                                 if horizontal distance between loop-block and {_block} = 1:
    119.                                     if horizontal distance between loop-block and {_p} <= 1:
    120.                                         return true
    121.                                 else if horizontal distance between loop-block and {_block} > 1:
    122.                                     if horizontal distance between loop-block and {_p} <= 1.5:
    123.                                         return true
    124.                     else if {_direction} = "South East":
    125.                         loop blocks within location of {_block} and location of block 1 south 1 east of {_block}:
    126.                             if loop-block is not a full block:
    127.                                 if horizontal distance between loop-block and {_block} = 1:
    128.                                     if horizontal distance between loop-block and {_p} <= 1:
    129.                                         return true
    130.                                 else if horizontal distance between loop-block and {_block} > 1:
    131.                                     if horizontal distance between loop-block and {_p} <= 1.5:
    132.                                         return true
    133.                     else if {_direction} = "South West":
    134.                         loop blocks within location of {_block} and location of block 1 south 1 west of {_block}:
    135.                             if loop-block is not a full block:
    136.                                 if horizontal distance between loop-block and {_block} = 1:
    137.                                     if horizontal distance between loop-block and {_p} <= 1:
    138.                                         return true
    139.                                 else if horizontal distance between loop-block and {_block} > 1:
    140.                                     if horizontal distance between loop-block and {_p} <= 1.5:
    141.                                         return true
    142.                     else if {_direction} = "South":
    143.                         loop blocks within location of {_block} and location of block 1 south of {_block}:
    144.                             if loop-block is not a full block:
    145.                                 if horizontal distance between loop-block and {_block} = 1:
    146.                                     if horizontal distance between loop-block and {_p} <= 1:
    147.                                         return true
    148.                                 else if horizontal distance between loop-block and {_block} > 1:
    149.                                     if horizontal distance between loop-block and {_p} <= 1.5:
    150.                                         return true
    151.                     else if {_direction} = "East":
    152.                         loop blocks within location of {_block} and location of block 1 east of {_block}:
    153.                             if loop-block is not a full block:
    154.                                 if horizontal distance between loop-block and {_block} = 1:
    155.                                     if horizontal distance between loop-block and {_p} <= 1:
    156.                                         return true
    157.                                 else if horizontal distance between loop-block and {_block} > 1:
    158.                                     if horizontal distance between loop-block and {_p} <= 1.5:
    159.                                         return true
    160.                     else if {_direction} = "West":
    161.                         loop blocks within location of {_block} and location of block 1 west of {_block}:
    162.                             if loop-block is not a full block:
    163.                                 if horizontal distance between loop-block and {_block} = 1:
    164.                                     if horizontal distance between loop-block and {_p} <= 1:
    165.                                         return true
    166.                                 else if horizontal distance between loop-block and {_block} > 1:
    167.                                     if horizontal distance between loop-block and {_p} <= 1.5:
    168.                                         return true
    169.                     loop all entities of type boat in radius 2 around {_p}:
    170.                         if loop-entity is boat:
    171.                             return true
    172.                 return false
    173.         else:
    174.             set {_block} to block below {_p}
    175.             set {_altdifference} to vertical distance between {_p} and {_block}
    176.             if {_altdifference} = 0.5:
    177.                 if {_block} != air:
    178.                     return true
    179.             return false
    Code (Skript):
    1. on any movement:
    2.     if player is on ground:
    3.         if player's ground state = false:
    4.             # Ground spoof
    Latest Skript && Skript-Mirror && Horizontal direction above && Non full block expression above
     
    #1 Zoot, May 16, 2018
    Last edited: May 20, 2018
    • Like Like x 1

Share This Page

Loading...