Anticheat Utility Snippets

  • 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!

Zoot

New Member
Oct 21, 2017
5
2
0
32
Tiered Potion
code_language.skript:
plural expression %player%'s active potion effects:
    get:
        return ...expression-1.getActivePotionEffects()

condition %player% (has|1¦does(n't| not) have) %potioneffecttype% %number%:
    check:
        if parse mark is 1:
            loop expression-1's active potion effects:
                if loop-value.getType() = expression-2:
                    if loop-value.getAmplifier() = expression-3:
                        negate the condition
            continue
        else:
            loop expression-1's active potion effects:
                if loop-value.getType() = expression-2:
                    if loop-value.getAmplifier() = expression-3:
                        continue
code_language.skript:
if player has speed 3:
if player doesn't have strength 1:
Skript latest && Skript-mirror latest

Square function in expression
code_language.skript:
expression [the] square of %number%:
    get:
        if expression-1 != 0:
            return (expression-1 * expression-1)
        else:
            return 0
        
expression %number% squared:
    get:
        if expression-1 != 0:
            return (expression-1 * expression-1)
        else:
            return 0
code_language.skript:
broadcast "%square of 5%"
if 5 squared = 25:
Skript latest && Skript-mirror latest

Better distance expressions
code_language.skript:
# Distance ignoring y-coordinate
expression horizontal distance between %location% and %location%:
    get:
        set {_x1} to x-coordinate of expression-1
        set {_z1} to z-coordinate of expression-1
        set {_x2} to x-coordinate of expression-2
        set {_z2} to z-coordinate of expression-2
        set {_x3} to square of ({_x2} - {_x1})
        set {_z3} to square of ({_z2} - {_z1})
        set {_final} to {_x3} + {_z3}
        set {_final} to sqrt({_final})
        return {_final}

# Distance ignoring x and z coordinates
expression vertical distance between %location% and %location%:
    get:
        set {_y1} to y-coordinate of expression-1
        set {_y2} to y-coordinate of expression-2
        return difference between {_y1} and {_y2}

# Returns an entity's location offset by his current velocity
expression %entity%'s location minus velocity:
    get:
        set {_location} to expression-1's location
        set {_velocity} to expression-1's velocity
        return {_location} ~ {_velocity}
    
# Gets the distance between two entities minus the victim's velocity. The second expression should be the victim
expression better entity distance between %entity% and %entity%:
    get:
        set {_first} to location of expression-1
        set {_second} to expression-2's location minus velocity
        return horizontal distance between {_first} and {_second}
code_language.skript:
on damage of player:
    if better entity distance between attacker and victim > 6:
        #
if horizontal distance between {_block1} and {_block2} = 1:
Skript && Skript-Mirror && Square expression above

Non full blocks (Blocks that would change your altitude)
code_language.skript:
condition %block% (is|1¦is not) a full block:
    check:
        if parse mark is 0:
            negate the condition
        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:
            continue
code_language.skript:
on any movement:
    if block under player is not a full block:
on left click:
    if clicked block is a full block:
Latest Skript && Skript-Mirror

Horizontal direction from location to location
code_language.skript:
expression horizontal direction from %location% to %location%:
    get:
        if world of expression-1 != world of expression-2:
            return {_null}
        else:
            set {_x1} to x-coordinate of expression-1
            set {_z1} to z-coordinate of expression-1
            set {_x2} to x-coordinate of expression-2
            set {_z2} to z-coordinate of expression-2
            # If first location is further South && second location is further North
            if {_z1} > {_z2}:
                # If first location is further East && second location is further West
                if {_x1} > {_x2}:
                    return "North West"
                # If first location is further West && second location is further East
                if {_x1} < {_x2}:
                    return "North East"
                # If first and second location are on the same X coordinate
                else:
                    return "North"
            # If first location is further North && second location is further South
            if {_z1} < {_z2}:
                # If first location is further East && second location is further West
                if {_x1} > {_x2}:
                    return "South West"
                # If first location is further West && second location is further East
                if {_x1} < {_x2}:
                    return "South East"
                # If first and second location are on the same X coordinate
                else:
                    return "South"
            # If first and second location are on the same Z coordinate
            else:
                # If first location is further East && second location is further West
                if {_x1} > {_x2}:
                    return "West"
                # If first location is further West && second location is further East
                if {_x1} < {_x2}:
                    return "East"
code_language.skript:
If horizontal direction from player's location and location of event-block = "North East":
    # 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_language.skript:
player property ground state:
    get:
        set {_p} to expression-1
        # Check if the ground packet is being sent by the player
        if {_p}.isOnGround() = true:
            # Could probably make this more advanced but this is fine
            if block at {_p} != air:
                return true
            else:
                set {_block} to block below {_p}
                set {_altdifference} to vertical distance between {_p} and {_block}
              
                # Check if the player is on a solid block
                if {_altdifference} = 0.5:
                    if {_block} != air:
                        return true
                    # If the block under the player isn't air, check all adjacent and diagonal blocks
                    else:
                        # Finds where the player is relative to the block under him
                        set {_direction} to horizontal direction from {_block} to {_p}
                        if {_direction} = "North East":
                            loop blocks within location of {_block} and location of block 1 north 1 east of {_block}:
                                if loop-block is not air:
                                    if horizontal distance between loop-block and {_block} = 1:
                                        if horizontal distance between loop-block and {_p} <= 1:
                                            return true
                                    else if horizontal distance between loop-block and {_block} > 1:
                                        if horizontal distance between loop-block and {_p} <= 1.5:
                                            return true
                        else if {_direction} = "North":
                            loop blocks within location of {_block} and location of block 1 north of {_block}:
                                if loop-block is not air:
                                    if horizontal distance between loop-block and {_block} = 1:
                                        if horizontal distance between loop-block and {_p} <= 1:
                                            return true
                                    else if horizontal distance between loop-block and {_block} > 1:
                                        if horizontal distance between loop-block and {_p} <= 1.5:
                                            return true
                        else if {_direction} = "North West":
                            loop blocks within location of {_block} and location of block 1 north 1 west of {_block}:
                                if loop-block is not air:
                                    if horizontal distance between loop-block and {_block} = 1:
                                        if horizontal distance between loop-block and {_p} <= 1:
                                            return true
                                    else if horizontal distance between loop-block and {_block} > 1:
                                        if horizontal distance between loop-block and {_p} <= 1.5:
                                            return true
                        else if {_direction} = "South East":
                            loop blocks within location of {_block} and location of block 1 south 1 east of {_block}:
                                if loop-block is not air:
                                    if horizontal distance between loop-block and {_block} = 1:
                                        if horizontal distance between loop-block and {_p} <= 1:
                                            return true
                                    else if horizontal distance between loop-block and {_block} > 1:
                                        if horizontal distance between loop-block and {_p} <= 1.5:
                                            return true
                        else if {_direction} = "South West":
                            loop blocks within location of {_block} and location of block 1 south 1 west of {_block}:
                                if loop-block is not air:
                                    if horizontal distance between loop-block and {_block} = 1:
                                        if horizontal distance between loop-block and {_p} <= 1:
                                            return true
                                    else if horizontal distance between loop-block and {_block} > 1:
                                        if horizontal distance between loop-block and {_p} <= 1.5:
                                            return true
                        else if {_direction} = "South":
                            loop blocks within location of {_block} and location of block 1 south of {_block}:
                                if loop-block is not air:
                                    if horizontal distance between loop-block and {_block} = 1:
                                        if horizontal distance between loop-block and {_p} <= 1:
                                            return true
                                    else if horizontal distance between loop-block and {_block} > 1:
                                        if horizontal distance between loop-block and {_p} <= 1.5:
                                            return true
                        else if {_direction} = "East":
                            loop blocks within location of {_block} and location of block 1 east of {_block}:
                                if loop-block is not air:
                                    if horizontal distance between loop-block and {_block} = 1:
                                        if horizontal distance between loop-block and {_p} <= 1:
                                            return true
                                    else if horizontal distance between loop-block and {_block} > 1:
                                        if horizontal distance between loop-block and {_p} <= 1.5:
                                            return true
                        else if {_direction} = "West":
                            loop blocks within location of {_block} and location of block 1 west of {_block}:
                                if loop-block is not air:
                                    if horizontal distance between loop-block and {_block} = 1:
                                        if horizontal distance between loop-block and {_p} <= 1:
                                            return true
                                    else if horizontal distance between loop-block and {_block} > 1:
                                        if horizontal distance between loop-block and {_p} <= 1.5:
                                            return true
                # Checks if the player is on a non solid block or entity; slabs, snow layers, fences, and etc.     
                else:
                    set {_block} to block above {_block}
                    set {_direction} to horizontal direction from {_block} to {_p}
                    if {_direction} = "North East":
                        loop blocks within location of {_block} and location of block 1 north 1 east of {_block}:
                            if loop-block is not a full block:
                                if horizontal distance between loop-block and {_block} = 1:
                                    if horizontal distance between loop-block and {_p} <= 1:
                                        return true
                                else if horizontal distance between loop-block and {_block} > 1:
                                    if horizontal distance between loop-block and {_p} <= 1.5:
                                        return true
                    else if {_direction} = "North":
                        loop blocks within location of {_block} and location of block 1 north of {_block}:
                            if loop-block is not a full block:
                                if horizontal distance between loop-block and {_block} = 1:
                                    if horizontal distance between loop-block and {_p} <= 1:
                                        return true
                                else if horizontal distance between loop-block and {_block} > 1:
                                    if horizontal distance between loop-block and {_p} <= 1.5:
                                        return true
                    else if {_direction} = "North West":
                        loop blocks within location of {_block} and location of block 1 north 1 west of {_block}:
                            if loop-block is not a full block:
                                if horizontal distance between loop-block and {_block} = 1:
                                    if horizontal distance between loop-block and {_p} <= 1:
                                        return true
                                else if horizontal distance between loop-block and {_block} > 1:
                                    if horizontal distance between loop-block and {_p} <= 1.5:
                                        return true
                    else if {_direction} = "South East":
                        loop blocks within location of {_block} and location of block 1 south 1 east of {_block}:
                            if loop-block is not a full block:
                                if horizontal distance between loop-block and {_block} = 1:
                                    if horizontal distance between loop-block and {_p} <= 1:
                                        return true
                                else if horizontal distance between loop-block and {_block} > 1:
                                    if horizontal distance between loop-block and {_p} <= 1.5:
                                        return true
                    else if {_direction} = "South West":
                        loop blocks within location of {_block} and location of block 1 south 1 west of {_block}:
                            if loop-block is not a full block:
                                if horizontal distance between loop-block and {_block} = 1:
                                    if horizontal distance between loop-block and {_p} <= 1:
                                        return true
                                else if horizontal distance between loop-block and {_block} > 1:
                                    if horizontal distance between loop-block and {_p} <= 1.5:
                                        return true
                    else if {_direction} = "South":
                        loop blocks within location of {_block} and location of block 1 south of {_block}:
                            if loop-block is not a full block:
                                if horizontal distance between loop-block and {_block} = 1:
                                    if horizontal distance between loop-block and {_p} <= 1:
                                        return true
                                else if horizontal distance between loop-block and {_block} > 1:
                                    if horizontal distance between loop-block and {_p} <= 1.5:
                                        return true
                    else if {_direction} = "East":
                        loop blocks within location of {_block} and location of block 1 east of {_block}:
                            if loop-block is not a full block:
                                if horizontal distance between loop-block and {_block} = 1:
                                    if horizontal distance between loop-block and {_p} <= 1:
                                        return true
                                else if horizontal distance between loop-block and {_block} > 1:
                                    if horizontal distance between loop-block and {_p} <= 1.5:
                                        return true
                    else if {_direction} = "West":
                        loop blocks within location of {_block} and location of block 1 west of {_block}:
                            if loop-block is not a full block:
                                if horizontal distance between loop-block and {_block} = 1:
                                    if horizontal distance between loop-block and {_p} <= 1:
                                        return true
                                else if horizontal distance between loop-block and {_block} > 1:
                                    if horizontal distance between loop-block and {_p} <= 1.5:
                                        return true
                    loop all entities of type boat in radius 2 around {_p}:
                        if loop-entity is boat:
                            return true
                return false
        else:
            set {_block} to block below {_p}
            set {_altdifference} to vertical distance between {_p} and {_block}
            if {_altdifference} = 0.5:
                if {_block} != air:
                    return true
            return false
code_language.skript:
on any movement:
    if player is on ground:
        if player's ground state = false:
            # Ground spoof
Latest Skript && Skript-Mirror && Horizontal direction above && Non full block expression above
 
Last edited:
  • Like
Reactions: Uzumaki