crate skript

  • 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 our Wiki for downloads and any other information about Skript!

NickQr

New Member
Oct 2, 2023
8
0
1
23
im kind of new to skript but i dont get what is wrong with this skript.

options:
KeyType: TRIPWIREHOOK
KeyName: "&7&lUncommon kulcs"
keyLore: "&a&lJobb klikk a &7&lUncommon ládára"

on rightclick on chest:
if block under event-block is gold block:
cancel event
if player is holding {@KeyType} named {@KeyName} with lore {@KeyLore}:

set {_random} to a random integer from 1 to 100
if {_random} is between 1 and 50:
set {_item} to diamond block
if {_random} is between 51 and 80:
set {_item} to netherite block
if {_random} is between 81 and 100:
set {_item} to netherite sword
give player 1 of {_item}
send "&a&lKaptál egy %{_item}%"
play sound "BLOCK_CHEST_OPEN" at volume 100 and pitch 0.5 for player
remove 1 of {@KeyType} named {@KeyName} with lore {@KeyLore} from player's inventory
else:
send "&c&lNincs &7&lUncommon kulcsod!"

command /kulcs:
permission: op
trigger:
give player 1 {@KeyType} named {@KeyName} with lore {@KeyLore}
 

Attachments

  • sajatcrate.sk
    976 bytes · Views: 31
It's rather difficult to say whats the exact issue without seeing the error that you're getting, but I suppose it definitely has something to do with indentation.
If this version didn't help, try posting the error please.
 

Attachments

  • sajatcrate.sk
    1.1 KB · Views: 26
im kind of new to skript but i dont get what is wrong with this skript.

options:
KeyType: TRIPWIREHOOK
KeyName: "&7&lUncommon kulcs"
keyLore: "&a&lJobb klikk a &7&lUncommon ládára"

on rightclick on chest:
if block under event-block is gold block:
cancel event
if player is holding {@KeyType} named {@KeyName} with lore {@KeyLore}:

set {_random} to a random integer from 1 to 100
if {_random} is between 1 and 50:
set {_item} to diamond block
if {_random} is between 51 and 80:
set {_item} to netherite block
if {_random} is between 81 and 100:
set {_item} to netherite sword
give player 1 of {_item}
send "&a&lKaptál egy %{_item}%"
play sound "BLOCK_CHEST_OPEN" at volume 100 and pitch 0.5 for player
remove 1 of {@KeyType} named {@KeyName} with lore {@KeyLore} from player's inventory
else:
send "&c&lNincs &7&lUncommon kulcsod!"

command /kulcs:
permission: op
trigger:
give player 1 {@KeyType} named {@KeyName} with lore {@KeyLore}
You have several errors with your current code. Check out the parser (At the top bar, right after Docs)! I ran your code through the parser and found you have exactly eight errors (Plus another minor issue I mention). I will provide the errors the lines are on and a spoiler of the fixes for them as well.

Line 1: Empty configuration section
Line 3, 4 and 5: Invalid Line (Code needs to be put into triggers)
Line 10: Empty configuration section
Line 21: Undefined Option
Line 22: 'Else' has to be placed after an 'if' statement
Line 28: Indentation error
Additional issue: Line 10 & 22. This is due to how you could check if a player has a key instead if they're holding one to make opening crates more accessible. Not necessarily something you have to do but will make your code overall more effective and have the error if a player doesn't have a key make more sense.

New Code With Fixes:
Code:
options:
#! KULCSOK
   KeyType: TRIPWIRE HOOK # Indented all of these lines
   KeyName: "&7&lUncommon kulcs"
   KeyLore: "&a&lJobb klikk a &7&lUncommon ládára"

on rightclick on chest:
  if block under event-block is gold block:
    cancel event
    if player has 1 of {@KeyType} named {@KeyName} with lore {@KeyLore}: # Checks if player HAS a key, not if they're holding one
      set {_random} to a random integer from 1 to 100 # More indentation here
      if {_random} is between 1 and 50:
        set {_item} to diamond block
      if {_random} is between 51 and 80:
        set {_item} to netherite block
      if {_random} is between 81 and 100:
        set {_item} to netherite sword
      give player 1 of {_item}
      send "&a&lKaptál egy %{_item}%"
      play sound "BLOCK_CHEST_OPEN" at volume 100 and pitch 0.5 for player
      remove 1 of {@KeyType} named {@KeyName} with lore {@KeyLore} from player's inventory
    else:
      send "&c&lNincs &7&lUncommon kulcsod!" to player # ALWAYS add 'to player' at the end of a send event unless you want all players to see this message
      
command /kulcs:
    permission: op
    trigger:
        give player 1 {@KeyType} named {@KeyName} with lore {@KeyLore} # More indenting
 
  • Like
Reactions: Doodle