Jump to content

(solved) add region world guard (or something else) check


AIGLE25

Recommended Posts

hello , i need to add region check to my script but i tried a lot of stuff but won't work :

on place of sponge:
      if "block under event-location" is air or sponge:
      cancel event

if possible i want it handles duplicate region names in different worlds and with permission luckyblock.place like this script:

# Configuration
options:
    permission: "sponge.place"
    canPlaceOutsideRegion: true

# Dependencies: WorldGuard

# Code

on place of sponge:
    event isn't cancelled
    # Permission check
    if player doesn't have permission {@permission}:
        cancel event
        send "<red>You do not have permission to do this!"
        exit

    # Region check
    set {_regions::*} to regions at event-location
    if {_regions::*} is empty:
        delete {_regions::*}
    if {_regions::*} is not set:
        if {@canPlaceOutsideRegion} is true:
            exit
        cancel event
        send "<red>You can not place sponge here!"
        exit

    # Loop over regions, this will handle overlapping regions
    loop {_regions::*}:
        set {_id} to loop-value
        if {sponge::%{_id}%::%player's uuid%} is not set:
            set {sponge::%{_id}%::%x coordinate of event-location%_%x coordinate of event-location%_%x coordinate of event-location%} to player's uuid
            set {sponge::%{_id}%::%player's uuid%} to "%x coordinate of event-location%_%x coordinate of event-location%_%x coordinate of event-location%"
            exit

    send "<red>You have already placed sponge in this region!"
    cancel event

on break of sponge:
    event isn't cancelled
    set {_regions::*} to regions at event-location
    loop {_regions::*}:
        set {_id} to loop-value
        # Has a player placed this sponge
        if {sponge::%{_id}%::%x coordinate of event-location%_%x coordinate of event-location%_%x coordinate of event-location%} is set:
            # Has this player placed the sponge
            if {sponge::%{_id}%::%player's uuid%} is "%x coordinate of event-location%_%x coordinate of event-location%_%x coordinate of event-location%":
                delete {sponge::%{_id}%::%x coordinate of event-location%_%x coordinate of event-location%_%x coordinate of event-location%}
                delete {sponge::%{_id}%::%player's uuid%}
                exit
            send "<red>That isn't your sponge!"
            cancel event
            exit

i'm using skript 2.6.5

Edited by AIGLE25
Link to comment
Share on other sites

i forgot to mark it as solved but i had to remove the if and use %region at event-location%

on right click:
        "%region at event-location%" contains "test"
        if targeted block is sponge:
                cancel event

and how can i mark as solved ?

Edited by AIGLE25
Link to comment
Share on other sites

  • AIGLE25 changed the title to (solved) add region world guard (or something else) check

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...