1. 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!

  2. LOOKING FOR A VERSION OF SKRIPT?

    You can always check out our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved On inventory help

Discussion in 'Skript' started by varboosted, May 19, 2020.

  1. varboosted

    varboosted Member

    Joined:
    Apr 20, 2020
    Messages:
    16
    Likes Received:
    1
    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

     
  2. Best Answer:
    Post #8 by rustedst, May 28, 2020 at 3:38 PM
  3. Viktor Tim Aggerholm

    Supporter

    Joined:
    Dec 29, 2019
    Messages:
    182
    Likes Received:
    12
    Be more speficic. What do you want done?
     
  4. varboosted

    varboosted Member

    Joined:
    Apr 20, 2020
    Messages:
    16
    Likes Received:
    1
    I have an FFA game that when you respawn you need to select a kit, so i want to disable damage if you have a golden sword called "kit selector" and after 30 sec of not selecting a kit enable damage
     
  5. Viktor Tim Aggerholm

    Supporter

    Joined:
    Dec 29, 2019
    Messages:
    182
    Likes Received:
    12
    this should disable damage when a player is choosing a kit (not tested)
    Code (Text):
    1. on respawn:
    2.     set {invaluable::%player%} to 30
    3.     open chest with 1 row named "Your GUI name" to player
    4.     set slot 0 of player's current inventory to diamond "kit diamond" with lore "get your diamonds here!"
    5.  
    6. on inventory click:
    7.     if name of player's current inventory is "Your GUI name":
    8.         cancel event
    9.         if clicked slot is 0:
    10.             set {invaluable::%loop-player%} to 0
    11.             execute console command "kit diamond %player%"
    12.  
    13. on damage:
    14.     if name of player's current inventory is "Your GUI name":
    15.         if {invaluable::%player%} is > 0:
    16.             cancel event
    17.             send "%victim% is in the middle of choosing a kit" to attacker
    18.            
    19. every second:
    20.     loop all players:
    21.         if {invaluable::%loop-player%} > 0:
    22.             remove 1 from {invaluable::%loop-player%}
     
  6. varboosted

    varboosted Member

    Joined:
    Apr 20, 2020
    Messages:
    16
    Likes Received:
    1
    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
     
  7. Viktor Tim Aggerholm

    Supporter

    Joined:
    Dec 29, 2019
    Messages:
    182
    Likes Received:
    12
    this should do the trick
    Code (Text):
    1. options:
    2.     min.x: -500
    3.     max.x: 500
    4.     min.z: -500
    5.     max.z: 500
    6.     avoid: air or water block or lava block
    7.  
    8.  
    9. on death:
    10.     set {_loc::new} to location at random number between {@min.x} and {@max.x}, 0, random number between {@min.z} and {@max.z}
    11.     loop blocks above {_loc::new}:
    12.         if loop-block and block above loop-block are air:
    13.             if block under loop-block is not {@avoid}:
    14.                 set {_loc::new} to location of loop-block
    15.                 teleport player to {_loc::new}
    16.                 set {invaluable::%player%} to 30
    17.                 if light level at player <= 2:
    18.                     set block at player to ground torch
    19.  
    20. on damage:
    21.     if name of victims's current inventory is "Your GUI name":
    22.         if {invaluable::%player%} is > 0:
    23.             cancel event
    24.             send "%victim% is in the middle of choosing a kit" to attacker
    25.          
    26. every second:
    27.     loop all players:
    28.         if {invaluable::%loop-player%} > 0:
    29.             remove 1 from {invaluable::%loop-player%}
     
  8. varboosted

    varboosted Member

    Joined:
    Apr 20, 2020
    Messages:
    16
    Likes Received:
    1
    The plugin already teleports randomly, already have a gui and kits, the plugin called kitbattle.
     
  9. rustedst

    rustedst Well-Known Member

    Joined:
    Apr 24, 2020
    Messages:
    79
    Likes Received:
    3
    Code (Text):
    1. on damage:
    2.     if victim has a golden sword named "&bKit Selector" #or your golden sword's name
    3.     cancel event
    4.     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 (Text):
    1. on damage:
    2.     loop all items in inventory of victim:
    3.         if loop-item is golden sword named "&bKit Selector": #or your golden sword's name
    4.             cancel event
    5.             send "&cThe player you attacked is selecting a kit!" to attacker
     
    • Like Like x 1
  10. varboosted

    varboosted Member

    Joined:
    Apr 20, 2020
    Messages:
    16
    Likes Received:
    1
    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!
     
    #9 varboosted, May 30, 2020 at 9:08 AM
    Last edited: May 30, 2020 at 12:28 PM
  11. rustedst

    rustedst Well-Known Member

    Joined:
    Apr 24, 2020
    Messages:
    79
    Likes Received:
    3
    Code (Text):
    1. on damage:
    2.     if victim has a golden sword named "&bKit Selector": #or your golden sword's name
    3.         cancel event
    4.         send "&cThe player you attacked is selecting a kit!" to attacker
    5.     if attacker hasa golden sword named "&bKit Selector": #or your golden sword's name
    6.         cancel event
    7.         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 (Text):
    1. on (the event that makes player select a kit):
    2.     set {selecting::%player%} to true
    3.     wait 30 seconds
    4.     set {selecting::%player%} to false
    5.     send "&cYour shield is disabled" to player
    and you should change the code above like:
    Code (Text):
    1. on damage:
    2.     if victim has a golden sword named "&bKit Selector": #or your golden sword's name
    3.         if {selecting::%victim%} is true:
    4.             cancel event
    5.             send "&cThe player you attacked is selecting a kit!" to attacker
    6.     if attacker hasa golden sword named "&bKit Selector": #or your golden sword's name
    7.         if {selecting::%attacker%} is true:
    8.             cancel event
    9.             send "&cYou are selecting a kit!" to attacker
     
  12. varboosted

    varboosted Member

    Joined:
    Apr 20, 2020
    Messages:
    16
    Likes Received:
    1
    on (the event that makes player select a kit):
    Its a jar file (KITBATTLE PLUGIN)
     
  13. rustedst

    rustedst Well-Known Member

    Joined:
    Apr 24, 2020
    Messages:
    79
    Likes Received:
    3
    I mean, when does the player start selecting a kit? On join? On respawn? On command?
     
  14. varboosted

    varboosted Member

    Joined:
    Apr 20, 2020
    Messages:
    16
    Likes Received:
    1
  15. rustedst

    rustedst Well-Known Member

    Joined:
    Apr 24, 2020
    Messages:
    79
    Likes Received:
    3
    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"".
     
  16. varboosted

    varboosted Member

    Joined:
    Apr 20, 2020
    Messages:
    16
    Likes Received:
    1
    So I mean if players joins the game at the first try people can attack him because he didn't respawn ?
     
  17. rustedst

    rustedst Well-Known Member

    Joined:
    Apr 24, 2020
    Messages:
    79
    Likes Received:
    3
    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 (Text):
    1. on command "/join":
    2.     set {selecting::%player%} to true
    3.     wait 30 seconds
    4.     set {selecting::%player%} to false
    5.     send "&cYour shield is disabled" to player
     
  18. varboosted

    varboosted Member

    Joined:
    Apr 20, 2020
    Messages:
    16
    Likes Received:
    1
    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!
     
Loading...