Solved Platform Selection

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

Status
Not open for further replies.

ItsMCB

Member
May 20, 2018
46
1
8
23
www.vexel.media
Greetings. My server allows for Java and Bedrock players to join, and this skript is aimed at giving them a permission group (through Luck Perms) that will help tailor their experience depending on what platform they are using. Note this will be for a lobby server that will affect the whole network.

Goal:
When a player joins, their previous choice will be cleared. A vanilla GUI will pop up prompting them to select their platform. If they try to close out of the menu without making a selection, it will open again. If they choose to make a selection, a Luck perms command will go through giving them the permissions globally. They can then run around and click on an NPC to join a game and do whatever.

Permission Nodes (Luck Perms Groups):
group.minecraftjava - Java Players
group.minecraftbedrockmobile - BE Players on their phone / tablet
group.minecraftbedrockconsole - BE players on Win 10 or console

The Problem:
The vanilla GUI is fine for now. The problem is getting those permissions cleared when a player joins and forcing players to select an option before they can play.

What I have so far:
Code:
# Platform Selection Moduel
on any movement:
    loop all players:
        if loop-player doesn't have permission "group.minecraftjava or group.minecraftbedrockmobile or group.minecraftbedrockconsole":
            make player execute command "/platform"
            send "Forcing you to select your platform!"
on join:
    loop all players:
        if {skverify::%loop-player%} is true:
            set {_skveryify} to false
            wait 1 tick
        if {skverify::%loop-player%} is not set:
            make console execute command "lp user %loop-player% parent remove minecraftjava"
            make console execute command "lp user %loop-player% parent remove minecraftbedrockmobile"
            make console execute command "lp user %loop-player% parent remove minecraftbedrockconsole"
            set {_skveryify} to true
            stop
        if {skverify::%loop-player%} is false:
            make console execute command "lp user %loop-player% parent remove minecraftjava"
            make console execute command "lp user %loop-player% parent remove minecraftbedrockmobile"
            make console execute command "lp user %loop-player% parent remove minecraftbedrockconsole"
            set {_skveryify} to true
            stop

# INVENTORY SELECTOR
command /platform:
    description: The best way of doing something.
    trigger:
        set metadata tag "platform" of player to chest inventory with 3 rows named "&bSelect Your Platform"
        set slot 4 of metadata tag "platform" of player to player's skull named "&6%player%" with lore "&7Please select your platform below."
        set slot 21 of metadata tag "platform" of player to flower pot named "&6Java Edition"
        set slot 22 of metadata tag "platform" of player to bedrock named "&6Windows 10/Console Edition"
        set slot 23 of metadata tag "platform" of player to bedrock named "&6Phone/Tablet Edition"
        open (metadata tag "platform" of player) to player
 
on inventory click:
    if event-inventory = (metadata tag "platform" of player):
        cancel event
        #cancel the clicking. This makes the Item unstealable
        if index of event-slot is 21:
            send "&7You have selected &bJava &7as your platform. Switch at any time with &b/platform&7."
            make console execute command "lp user %player% parent add minecraftjava"
            make console execute command "lp user %player% parent remove minecraftbedrockmobile"
            make console execute command "lp user %player% parent remove minecraftbedrockconsole"
            close player's inventory
        if index of event-slot is 22:
            send "&7You have selected &bBedrock for Mobile Devices &7as your platform. Switch at any time with &b/platform&7."
            make console execute command "lp user %player% parent remove minecraftjava"
            make console execute command "lp user %player% parent add minecraftbedrockmobile"
            make console execute command "lp user %player% parent remove minecraftbedrockconsole"
            close player's inventory
        if index of event-slot is 23:
            send "&7You have selected &bBedrock for Windows 10 and Consoles &7as your platform. Switch at any time with &b/platform&7."
            make console execute command "lp user %player% parent remove minecraftjava"
            make console execute command "lp user %player% parent remove minecraftbedrockmobile"
            make console execute command "lp user %player% parent add minecraftbedrockconsole"
            close player's inventory


        else if index of event-slot is 1:
            if event-click type is right mouse button:
                #check if the player right clicks the item
                set {_playerHead} to uncolored name of event-slot parsed as player
                give event-slot to player
                send "&6Player %player% has received a skull of you!" to {_playerHead}

Thank you for reading my post :emoji_slight_smile:
 
Status
Not open for further replies.