Solved When the player holds the item, execute the command (Help Me!)

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

Danic

Member
Jul 23, 2020
42
0
6
Korea
www.youtube.com
I created a GUI Store and succeeded in getting it to work successfully.
However, I faced an unexpected problem. (It may be because I have a bad head, haha.)

Anyway I used the code below to run a successful GUI store.
But I want to make a phrase so that I can get 64 emeralds only when I have a diamond.

"If the player has a diamond: "

Code:
format slot 32 of player with diamond named "diamond 1" with lore "64 emeralds" to close then run [execute command "/give %player% minecraft:emerald 64" and "/clear %player% minecraft:diamond 1"]

What is the Skript syntax that does the same thing?
 
try:
also i used 2 spaces and not a tab

Code:
format slot 32 of player with diamond named "diamond 1" with lore "64 emeralds" to close then run [execute command "/name) %player%"


command /(name) [<player>]:
  permission:sk.admin
  trigger:
    if player has a diamond:
      give player 64 emeralds
      remove 1 diamond from player
    else:
      send "You need a diamond"
 
I created a GUI Store and succeeded in getting it to work successfully.
However, I faced an unexpected problem. (It may be because I have a bad head, haha.)

Anyway I used the code below to run a successful GUI store.
But I want to make a phrase so that I can get 64 emeralds only when I have a diamond.

"If the player has a diamond: "

Code:
format slot 32 of player with diamond named "diamond 1" with lore "64 emeralds" to close then run [execute command "/give %player% minecraft:emerald 64" and "/clear %player% minecraft:diamond 1"]

What is the Skript syntax that does the same thing?
As @Killerz1243 said, TuSKe and Vanillas inventories are more efficient and do not bring the bugs that SkQuery inventories bring.

Depending on what you are telling me, what you want would be something like this:

Vanilla:
code_language.skript:
command /emerald:
    trigger:
        open chest inventory with (number of rows) row[s] named "Store" to player
        set {_d} to diamond named "diamond 1"
        set line 1 of lore of {_d} to "64 emeralds"
        wait a tick
        set slot 32 of player's current inventory to {_d}

on inventory click:
    clicked inventory isn't player's inventory #optional
    if inventory name of player's current inventory is "Store":
        if clicked slot is 32:
            if player's inventory contains diamonds:
                give 64 emeralds to player's inventory
                remove 1 diamond from player's inventory
            else:
                send "&cYou cant" to player
            close player's inventory

TuSKe:
code_language.skript:
command /emerald:
    trigger:
        open virtual chest inventory with size (number of rows) named "Store" to player
        set {_d} to diamond named "diamond 1"
        set line 1 of lore of {_d} to "64 emeralds"
        format a gui slot 32 of player with {_d} to close:
            if player's inventory contains diamonds:
                give 64 emeralds to player's inventory
                remove 1 diamond from player's inventory
            else:
                send "&cYou cant" to player
 
try:
also i used 2 spaces and not a tab

Code:
format slot 32 of player with diamond named "diamond 1" with lore "64 emeralds" to close then run [execute command "/name) %player%"


command /(name) [<player>]:
  permission:sk.admin
  trigger:
    if player has a diamond:
      give player 64 emeralds
      remove 1 diamond from player
    else:
      send "You need a diamond"

Hey, Listen to my say.

I have to use this code.
Code:
format slot 32 of player with diamond named "diamond 1" with lore "64 emeralds" to close then run [execute command "/give %player% minecraft:emerald 64" and "/clear %player% minecraft:diamond 1"]

This is only part of my numerous code. I have to code what I said in that code.
Please help me in that code. Or tell me a new way to replace that code. I am using GUI.
[doublepost=1595854452,1595854221][/doublepost]
Don't use skquery for guis, it is buggy and items can be duplicated. You should learn vanilla guis as they are more efficient and less buggy. Heres an tutorial on vanilla guis.
https://forums.skunity.com/threads/vanilla-guis.8939/

However, I cannot afford time. It would be helpful for me in order that you come up with a specific solution, sir.
Thanks to you, I understand that vanilla is much better than skQuery. Please help me to adapt as soon as possible, or suggest a solution to my situation, respected creator!
[doublepost=1595854723][/doublepost]
As @Killerz1243 said, TuSKe and Vanillas inventories are more efficient and do not bring the bugs that SkQuery inventories bring.

Depending on what you are telling me, what you want would be something like this:

Vanilla:
code_language.skript:
command /emerald:
    trigger:
        open chest inventory with (number of rows) row[s] named "Store" to player
        set {_d} to diamond named "diamond 1"
        set line 1 of lore of {_d} to "64 emeralds"
        wait a tick
        set slot 32 of player's current inventory to {_d}

on inventory click:
    clicked inventory isn't player's inventory #optional
    if inventory name of player's current inventory is "Store":
        if clicked slot is 32:
            if player's inventory contains diamonds:
                give 64 emeralds to player's inventory
                remove 1 diamond from player's inventory
            else:
                send "&cYou cant" to player
            close player's inventory

TuSKe:
code_language.skript:
command /emerald:
    trigger:
        open virtual chest inventory with size (number of rows) named "Store" to player
        set {_d} to diamond named "diamond 1"
        set line 1 of lore of {_d} to "64 emeralds"
        format a gui slot 32 of player with {_d} to close:
            if player's inventory contains diamonds:
                give 64 emeralds to player's inventory
                remove 1 diamond from player's inventory
            else:
                send "&cYou cant" to player

As I said above, I have to fix this with the code I've presented and not enough time. If I have to use vanilla, help me to get used to it as soon as possible or use <format slot 32 of player with diamond named "diamond 1" with lore "64 emeralds" to close then run [blah blah blah]"> Please give me a plan, I'm sorry to express my urgency!
 
Something like this should work:
Code:
format slot 32 of player with diamond named "diamond 1" with lore "64 emeralds" to close then run [execute console command "/give %player% minecraft:emerald 64"] -> [execute console command "/clear %player% minecraft:diamond 1"]
But I would highly recommend you to use Vanilla or TusKe... (as a lot o' people said above)
 
Something like this should work:
Code:
format slot 32 of player with diamond named "diamond 1" with lore "64 emeralds" to close then run [execute console command "/give %player% minecraft:emerald 64"] -> [execute console command "/clear %player% minecraft:diamond 1"]
But I would highly recommend you to use Vanilla or TusKe... (as a lot o' people said above)

Hey, man.
Let me ask you one.
I think I am seriously misunderstanding.
Does it mean to switch to vanilla, not to download the program, but to change the syntax?
 
Last edited:
Status
Not open for further replies.