Function errors

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

83y

New Member
Nov 7, 2019
8
0
1
20
Skript Version: 2.4.1
Minecraft Version: 1.15.2

Full Code:

Code:
options:
    AMOUNT_Grass: 8
    SINGLE_Grass: 5
    AMOUNT_Dirt: 8
    SINGLE_Dirt: 3
    AMOUNT_Redstone: 8
    SINGLE_Redstone: 10
    BUY_Redstone: %{@AMOUNT_Redstone}*{@SINGLE_Redstone}%

function setShop(slot: integer, player: player, amount: integer, item: item, buy: number, menu: string):
    if inventory name of {_player}'s current inventory is "&2{_menu}":
        if event-slot is {_slot}:
            if {_player}'s balance is more than {_buy}:
                if {_player} can hold {_amount} {_item}:
                    remove {_buy} from {_player}'s balance
                    give {_player} {_amount} {_item}
                else:
                    send "&cYou do not have enough inventory space."
                    play sound "ENTITY_VILLAGER_NO" at player
            else:
                send "&cYou do not have the suffcient funds."
                play sound "ENTITY_VILLAGER_NO" at player

command /shop [<text>]:
    trigger:
        if arg 1 is "blocks":
            open virtual chest with size 5 named "&2Blocks" to player
            set {_slot} to 0
            loop 45 times:
                format a gui slot {_slot} of player with dark gray stained glass pane named "&f" to do nothing
                add 1 to {_slot}
            format a gui slot 10 of player with {@AMOUNT_Grass} grass block named "&2Grass Block" with lore "&a$%{@AMOUNT_Grass}*{@SINGLE_Grass}%"
            format a gui slot 11 of player with {@AMOUNT_Dirt} dirt block named "&2Dirt" with lore "&a$%{@AMOUNT_Dirt}*{@SINGLE_Dirt}%"
            format a gui slot 40 of player with barrier named "&cBack" to run player command "/shop"
        if arg 1 is "redstone":
            open virtual chest with size 5 named "&2Redstone" to player
            set {_slot} to 0
            loop 45 times:
                format a gui slot {_slot} of player with dark gray stained glass pane named "&f" to do nothing
                format a gui slot 10 of player with {@AMOUNT_Redstone} redstone item named "&2Redstone" with lore "&a$%{@AMOUNT_Redstone}*{@SINGLE_Redstone}%"
                format a gui slot 40 of player with barrier named "&cBack" to run player command "/shop"
                add 1 to {_slot}
        if arg 1 is not set:
            open chest with 1 row named "&2Shop" to player
            format a gui slot 0 of player with grass block named "&2Blocks" to run player command "/shop blocks"
            format a gui slot 1 of player with redstone item named "&2Redstone" to run player command "/shop redstone"

on inventory click:
    setShop(10, player, 8, grass block, {@BUY_Redstone}, blocks)

on inventory click:
    set {_click} to clicked slot
    set {_click2} to clicked item
    broadcast "%{_click}%"
    broadcast "%{_click2}%"

Errors on reload:
https://ibb.co/gvxsxh4

Addons using (including versions): Skellet , SkExtras's, SkQuery, skRayFall, Skript, TuSKe

Troubleshooting:

Have you tried searching the docs? Yes
Have you tried searching the forums? Yes
What other methods have you tried to fix it? i searched the errors up and nothing came up
 
u write function but using event-slot, really ?
[doublepost=1579962937,1579962520][/doublepost]delete line 12 and change the event like this

Code:
on inventory click:
    if inventory name of player's current inventory is "name":
        if event-slot is 10:
            "your function"

edit:
wait, i dont think u need a function, u can just do it in the event
 
I changed it to this, but it still doesnt work.

Code:
options:
    AMOUNT_Grass: 8
    SINGLE_Grass: 5
    AMOUNT_Dirt: 8
    SINGLE_Dirt: 3
    AMOUNT_Redstone: 8
    SINGLE_Redstone: 10
    BUY_Redstone: %{@AMOUNT_Redstone}*{@SINGLE_Redstone}%

function setShop(player: player, amount: integer, item: item, buy: number):
    if {_player}'s balance is more than {_buy}:
        if {_player} can hold {_amount} {_item}:
            remove {_buy} from {_player}'s balance
            give {_player} {_amount} {_item}
        else:
            send "&cYou do not have enough inventory space."
            play sound "ENTITY_VILLAGER_NO" at {_player}
    else:
        send "&cYou do not have the suffcient funds."
        play sound "ENTITY_VILLAGER_NO" at {_player}

command /shop [<text>]:
    trigger:
        if arg 1 is "blocks":
            open virtual chest with size 5 named "&2Blocks" to player
            set {_slot} to 0
            loop 45 times:
                format a gui slot {_slot} of player with dark gray stained glass pane named "&f" to do nothing
                add 1 to {_slot}
            format a gui slot 10 of player with {@AMOUNT_Grass} grass block named "&2Grass Block" with lore "&a$%{@AMOUNT_Grass}*{@SINGLE_Grass}%"
            format a gui slot 11 of player with {@AMOUNT_Dirt} dirt block named "&2Dirt" with lore "&a$%{@AMOUNT_Dirt}*{@SINGLE_Dirt}%"
            format a gui slot 40 of player with barrier named "&cBack" to run player command "/shop"
        if arg 1 is "redstone":
            open virtual chest with size 5 named "&2Redstone" to player
            set {_slot} to 0
            loop 45 times:
                format a gui slot {_slot} of player with dark gray stained glass pane named "&f" to do nothing
                format a gui slot 10 of player with {@AMOUNT_Redstone} redstone item named "&2Redstone" with lore "&a$%{@AMOUNT_Redstone}*{@SINGLE_Redstone}%"
                format a gui slot 40 of player with barrier named "&cBack" to run player command "/shop"
                add 1 to {_slot}
        if arg 1 is not set:
            open chest with 1 row named "&2Shop" to player
            format a gui slot 0 of player with grass block named "&2Blocks" to run player command "/shop blocks"
            format a gui slot 1 of player with redstone item named "&2Redstone" to run player command "/shop redstone"

on inventory click:
    if inventory name of player's current inventory is "&2blocks":
        if event-slot is 10:
            setShop(player, 8, grass block, {@BUY_Redstone})
        
on inventory click:
    set {_click} to clicked slot
    set {_click2} to clicked item
    broadcast "%{_click}%"
    broadcast "%{_click2}%"

Errors:
https://ibb.co/gSC4ZYv
https://ibb.co/q07bnjJ
 
1. is there syntax called "can hold" ?
2. change all player with {_player} and change send to send " " to {_player}
 
Status
Not open for further replies.