Solved skQuery not working?

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

Shroomz

Supporter +
Jun 22, 2017
44
0
6
25
I was doing custom GUI with skQuery but some reason it does not want to work (or I am shitting on myself)

It does close it if I want it to but it does not run the command..

Small snip from my skript:
code_language.skript:
format slot 1 of player with book named "&6New account book" with lore "&5With this you can create a copy of the existing||&5bank account's book. Remember to get||&5the new account book fee!" to run "/account book"
format slot 3 of player with player head named "&6Add User" with lore "&5You can add user to bank account||&5Remember to check that account's owner is asking this!" to close then run "account add"
 
I was doing custom GUI with skQuery but some reason it does not want to work (or I am shitting on myself)

It does close it if I want it to but it does not run the command..

Small snip from my skript:
code_language.skript:
format slot 1 of player with book named "&6New account book" with lore "&5With this you can create a copy of the existing||&5bank account's book. Remember to get||&5the new account book fee!" to run "/account book"
format slot 3 of player with player head named "&6Add User" with lore "&5You can add user to bank account||&5Remember to check that account's owner is asking this!" to close then run "account add"

If you really want to use skQuery's format slot expression, you'll need to use lambdas; something like this:
code_language.skript:
format slot 1 of player with book named "&6New account book" with lore "&5With this you can create a copy of the existing||&5bank account's book. Remember to get||&5the new account book fee!" to run [make player execute command "/account book"]
format slot 3 of player with player head named "&6Add User" with lore "&5You can add user to bank account||&5Remember to check that account's owner is asking this!" to close then run [make player execute command "/account add"]

But honestly, don't use format slot (unless you really really really need to use lambdas, which most of the time is unnecessary).

Use Skript's set slot function; it's more reliable. As for converting to it, it's syntax is pretty similar to skQuery's:

code_language.skript:
set slot 1 of player to book named "&6New account book" with lore "&5With this you can create a copy of the existing||&5bank account's book. Remember to get||&5the new account book fee!"
set slot 3 of player to player head named "&6Add User" with lore "&5You can add user to bank account||&5Remember to check that account's owner is asking this!"

on inventory click:
    name of player's current inventory is "Inventory Name!"
    cancel event
    clicked slot is 1:
        make player execute command "/account book"
    clicked slot is 3:
        make player execute command "/account add"

All the command stuffs is done in an "on inventory click" event
 
If you really want to use skQuery's format slot expression, you'll need to use lambdas; something like this:
code_language.skript:
format slot 1 of player with book named "&6New account book" with lore "&5With this you can create a copy of the existing||&5bank account's book. Remember to get||&5the new account book fee!" to run [make player execute command "/account book"]
format slot 3 of player with player head named "&6Add User" with lore "&5You can add user to bank account||&5Remember to check that account's owner is asking this!" to close then run [make player execute command "/account add"]

But honestly, don't use format slot (unless you really really really need to use lambdas, which most of the time is unnecessary).

Use Skript's set slot function; it's more reliable. As for converting to it, it's syntax is pretty similar to skQuery's:

code_language.skript:
set slot 1 of player to book named "&6New account book" with lore "&5With this you can create a copy of the existing||&5bank account's book. Remember to get||&5the new account book fee!"
set slot 3 of player to player head named "&6Add User" with lore "&5You can add user to bank account||&5Remember to check that account's owner is asking this!"

on inventory click:
    name of player's current inventory is "Inventory Name!"
    cancel event
    clicked slot is 1:
        make player execute command "/account book"
    clicked slot is 3:
        make player execute command "/account add"

All the command stuffs is done in an "on inventory click" event
Well that "set" works super badly... when you close the "GUI" the blocks and items stay in players inventory :I
 
Well that "set" works super badly... when you close the "GUI" the blocks and items stay in players inventory :I
Whoops; sorry.

code_language.skript:
set slot 1 of player's current inventory to book named "&6New account book" with lore "&5With this you can create a copy of the existing||&5bank account's book. Remember to get||&5the new account book fee!"
set slot 3 of player's current inventoryto player head named "&6Add User" with lore "&5You can add user to bank account||&5Remember to check that account's owner is asking this!"
 
on inventory click:
    name of player's current inventory is "Inventory Name!"
    cancel event
    clicked slot is 1:
        make player execute command "/account book"
    clicked slot is 3:
        make player execute command "/account add"

If you do ever plan on using set slot, formatting a gui needs player's current inventory rather than just player
 
Whoops; sorry.

code_language.skript:
set slot 1 of player's current inventory to book named "&6New account book" with lore "&5With this you can create a copy of the existing||&5bank account's book. Remember to get||&5the new account book fee!"
set slot 3 of player's current inventoryto player head named "&6Add User" with lore "&5You can add user to bank account||&5Remember to check that account's owner is asking this!"
 
on inventory click:
    name of player's current inventory is "Inventory Name!"
    cancel event
    clicked slot is 1:
        make player execute command "/account book"
    clicked slot is 3:
        make player execute command "/account add"

If you do ever plan on using set slot, formatting a gui needs player's current inventory rather than just player
and one more thing... it puts those items in players hotbar. Not in the opened GUI :I formatting slot has worked well... only the running commands is the not working part
 
and one more thing... it puts those items in players hotbar. Not in the opened GUI :I formatting slot has worked well... only the running commands is the not working part

Eh, to each their own; player's current inventory shouldn't format the slots in the player's hotbar, as it's not the player's actual inventory. Maybe it's an addon, idk.

Honestly, if you want to use format slot, go ahead; it can be useful, despite what people say about it. Using lambdas should make running commands work though, as I did in my original reply
 
@Scarlet

Examples codes of what you can do with Tuske.

code_language.skript:
open virtual chest inventory with size 6 named "Hi, this is the title" to player
#The size is only for chest and goes from 1 to 6. (You can use others numbers, but it will be a glitched inventory).
create a gui slot 1 of player with potato to close with left click
create a gui slot 2 of player with paper to run player command "opCommandHere" with permission "*"
create a gui slot 3 of player with diamond to run console command "CommandHere"
create a gui slot 4 of player with gravel to run function giveItems(player) with cursor item stone

on right click on enchantment table:
    make a gui slot 1 of player with lapis lazuli to do nothing
on enchant:
    wait a tick  
    make a gui slot 1 of player with lapis lazuli to do nothing
 
@Scarlet

Examples codes of what you can do with Tuske.

code_language.skript:
open virtual chest inventory with size 6 named "Hi, this is the title" to player
#The size is only for chest and goes from 1 to 6. (You can use others numbers, but it will be a glitched inventory).
create a gui slot 1 of player with potato to close with left click
create a gui slot 2 of player with paper to run player command "opCommandHere" with permission "*"
create a gui slot 3 of player with diamond to run console command "CommandHere"
create a gui slot 4 of player with gravel to run function giveItems(player) with cursor item stone

on right click on enchantment table:
    make a gui slot 1 of player with lapis lazuli to do nothing
on enchant:
    wait a tick
    make a gui slot 1 of player with lapis lazuli to do nothing
How can I do that it runs command and then closes the GUI?
 
Status
Not open for further replies.