Solved On inventory help

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

varboosted

Active Member
Apr 20, 2020
50
3
8
24
Hello there is a skript that can do like this example:

on inventory:
if name of event-item is "&5&lKIT SELECTOR":
send "&aPlayer didn't select a kit" to victim
disable damage
wait 1 minute
enable damage
 
this should disable damage when a player is choosing a kit (not tested)
Code:
on respawn:
    set {invaluable::%player%} to 30
    open chest with 1 row named "Your GUI name" to player
    set slot 0 of player's current inventory to diamond "kit diamond" with lore "get your diamonds here!"

on inventory click:
    if name of player's current inventory is "Your GUI name":
        cancel event
        if clicked slot is 0:
            set {invaluable::%loop-player%} to 0
            execute console command "kit diamond %player%"

on damage:
    if name of player's current inventory is "Your GUI name":
        if {invaluable::%player%} is > 0:
            cancel event
            send "%victim% is in the middle of choosing a kit" to attacker
            
every second:
    loop all players:
        if {invaluable::%loop-player%} > 0:
            remove 1 from {invaluable::%loop-player%}
 
I don't need to create a server selector since i already have
upload_2020-5-23_16-43-32.png



So when someone died he is teleporting to random location at the map so i want that no one will be able to damage him, and if someone is trying to damage him so he will recieve a message "&a&lThis player has not selected a kit", and after 30 seconds everyone can damage him for no AFK's in the map
 
this should do the trick
Code:
options:
    min.x: -500
    max.x: 500
    min.z: -500
    max.z: 500
    avoid: air or water block or lava block


on death:
    set {_loc::new} to location at random number between {@min.x} and {@max.x}, 0, random number between {@min.z} and {@max.z}
    loop blocks above {_loc::new}:
        if loop-block and block above loop-block are air:
            if block under loop-block is not {@avoid}:
                set {_loc::new} to location of loop-block
                teleport player to {_loc::new}
                set {invaluable::%player%} to 30
                if light level at player <= 2:
                    set block at player to ground torch

on damage:
    if name of victims's current inventory is "Your GUI name":
        if {invaluable::%player%} is > 0:
            cancel event
            send "%victim% is in the middle of choosing a kit" to attacker
          
every second:
    loop all players:
        if {invaluable::%loop-player%} > 0:
            remove 1 from {invaluable::%loop-player%}
 
this should do the trick
Code:
options:
    min.x: -500
    max.x: 500
    min.z: -500
    max.z: 500
    avoid: air or water block or lava block


on death:
    set {_loc::new} to location at random number between {@min.x} and {@max.x}, 0, random number between {@min.z} and {@max.z}
    loop blocks above {_loc::new}:
        if loop-block and block above loop-block are air:
            if block under loop-block is not {@avoid}:
                set {_loc::new} to location of loop-block
                teleport player to {_loc::new}
                set {invaluable::%player%} to 30
                if light level at player <= 2:
                    set block at player to ground torch

on damage:
    if name of victims's current inventory is "Your GUI name":
        if {invaluable::%player%} is > 0:
            cancel event
            send "%victim% is in the middle of choosing a kit" to attacker
         
every second:
    loop all players:
        if {invaluable::%loop-player%} > 0:
            remove 1 from {invaluable::%loop-player%}

The plugin already teleports randomly, already have a gui and kits, the plugin called kitbattle.
 
Code:
on damage:
    if victim has a golden sword named "&bKit Selector" #or your golden sword's name
    cancel event
    send "&cThe player you attacked is selecting a kit!" to attacker
If this doesn't work (in some spigot versions skript can't check if player has an item):
Code:
on damage:
    loop all items in inventory of victim:
        if loop-item is golden sword named "&bKit Selector": #or your golden sword's name
            cancel event
            send "&cThe player you attacked is selecting a kit!" to attacker
 
  • Like
Reactions: varboosted
on damage:
loop all items in inventory of victim:
if loop-item is diamond sword named "&bKit Selector &7(Right-click)": #or your golden sword's name
cancel event
send "&cThe player you attacked is selecting a kit!" to attacker

How can I do that if you have also that the enemy cant get attacked by the victim?
And after 30 seconds people can attack him and he will recieve a message "your shield is disabled" thank you!
 
Last edited:
Code:
on damage:
    if victim has a golden sword named "&bKit Selector": #or your golden sword's name
        cancel event
        send "&cThe player you attacked is selecting a kit!" to attacker
    if attacker hasa golden sword named "&bKit Selector": #or your golden sword's name
        cancel event
        send "&cYou are selecting a kit!" to attacker
That 30 seconds thing depends on how your kit selection system works and how you want it to work.
Code:
on (the event that makes player select a kit):
    set {selecting::%player%} to true
    wait 30 seconds
    set {selecting::%player%} to false
    send "&cYour shield is disabled" to player
and you should change the code above like:
Code:
on damage:
    if victim has a golden sword named "&bKit Selector": #or your golden sword's name
        if {selecting::%victim%} is true:
            cancel event
            send "&cThe player you attacked is selecting a kit!" to attacker
    if attacker hasa golden sword named "&bKit Selector": #or your golden sword's name
        if {selecting::%attacker%} is true:
            cancel event
            send "&cYou are selecting a kit!" to attacker
 
Code:
on damage:
    if victim has a golden sword named "&bKit Selector": #or your golden sword's name
        cancel event
        send "&cThe player you attacked is selecting a kit!" to attacker
    if attacker hasa golden sword named "&bKit Selector": #or your golden sword's name
        cancel event
        send "&cYou are selecting a kit!" to attacker
That 30 seconds thing depends on how your kit selection system works and how you want it to work.
Code:
on (the event that makes player select a kit):
    set {selecting::%player%} to true
    wait 30 seconds
    set {selecting::%player%} to false
    send "&cYour shield is disabled" to player
and you should change the code above like:
Code:
on damage:
    if victim has a golden sword named "&bKit Selector": #or your golden sword's name
        if {selecting::%victim%} is true:
            cancel event
            send "&cThe player you attacked is selecting a kit!" to attacker
    if attacker hasa golden sword named "&bKit Selector": #or your golden sword's name
        if {selecting::%attacker%} is true:
            cancel event
            send "&cYou are selecting a kit!" to attacker

on (the event that makes player select a kit):
Its a jar file (KITBATTLE PLUGIN)
 
Then replace "(the event that makes player select a kit)" with "on respawn". If player also gets to select kit when uses /join command, copy the code and paste again by replacing "on respawn" with "on command "/join"".
 
Then replace "(the event that makes player select a kit)" with "on respawn". If player also gets to select kit when uses /join command, copy the code and paste again by replacing "on respawn" with "on command "/join"".
So I mean if players joins the game at the first try people can attack him because he didn't respawn ?
 
If player has to select kit after joining, no, people won't be able to attack him. If player doesn't select a kit after joining, do this:
Code:
on command "/join":
    set {selecting::%player%} to true
    wait 30 seconds
    set {selecting::%player%} to false
    send "&cYour shield is disabled" to player
 
If player has to select kit after joining, no, people won't be able to attack him. If player doesn't select a kit after joining, do this:
Code:
on command "/join":
    set {selecting::%player%} to true
    wait 30 seconds
    set {selecting::%player%} to false
    send "&cYour shield is disabled" to player

That doesn't works, so can i just do

loop all items in inventory of player:
if loop-item is diamond sword named "&bKit Selector &7(Right-click)":
wait 30 seconds
kick %player% you need to select a kit!
 
Status
Not open for further replies.