How to check player at surface

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

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

gloatymadn

Member
Feb 9, 2024
13
0
1
22
How to check is player at surface?

Code:
on consume of apple:
  if name of event-item is "§cThe apple of Zeus":

    #if player on surface? how check if a player
    #is in a mine or if there is a block above his head?
   
    strike lightning at the player
    send "§aYou feel electrified." to player
 
maybe make a region that is on surface and only let the boss be there and use
Code:
if event-region is (your region):
    strike lightning at player
 
maybe make a region that is on surface and only let the boss be there and use
Code:
if event-region is (your region):
    strike lightning at player
this solution will not work, since this script is used for custom item and it isn't possible to make regions everywhere at surface.
 
This solution should work, if you don't want the event to cancel just delete that line, and of course, edit the message to your will.

JavaScript:
on consume of apple:
  if name of event-item is "§cThe apple of Zeus":

    block above player is not air:
 
        strike lightning at the player
        send "§aYou feel electrified." to player
    else:
        message "&cThe ceiling above blocks the power of Zeus"
        cancel event
Code untested unless stated otherwise.
 
Last edited:
This solution should work, if you don't want the event to cancel just delete that line, and of course, edit the message to your will.

JavaScript:
on consume of apple:
  if name of event-item is "§cThe apple of Zeus":

    block above player is not air:
 
        strike lightning at the player
        send "§aYou feel electrified." to player
    else:
        message "&cThe ceiling above blocks the power of Zeus"
        cancel event
Code untested unless stated otherwise.
how check ALL the blocks above the player's head?
i.e. loop all blocks above the player , like.... loop a column of blocks above the player's head?
 
how check ALL the blocks above the player's head?
i.e. loop all blocks above the player , like.... loop a column of blocks above the player's head?
I normally use this:
JavaScript:
set {_y1} to block 20 blocks above player #change this number to make the column taller
set {_y2} to block above player
loop blocks between {_y1} and {_y2}:
    #rest of code
but I think this might also work:
JavaScript:
loop blocks between block above player and block 20 blocks above player:
    #rest of code

The first one works, however, the second, I haven't tested.
 
Last edited: