Help with shop 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 skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

Ceravia

Member
Apr 17, 2017
18
0
0
26
This give me no errors, my economy script can be added, subtracted, etc. So my economy is parsed correctly but these functions don't do anything. I can pull up the GUI with lore but nothing in it works. Running 2.2 fixes v8b

code_language.skript:
function purchaseItem(p: Player, cost: integer, i: item):
    if {bean.money.%{_p}%} >= {_cost}:
        remove {_cost} parsed as integer from {bean.money.%{_p}%}
        give {_item} parsed as item to {_p}
    else:
        broadcast "{@p}You cannot afford this item!"
function sellItem(p: Player, earn: integer, i: item):
    if {_p} has {_item}:
        remove {_item} from {_p}'s inventory
        add {_earn} to {bean.money.%{_p}%}   
    
on rightclick on villager:
    cancel event
    if name of player's target entity contains "&aBlacksmith":
        wait 1 tick
        open virtual chest inventory with size 6 named "&aShop" to player
        wait 1 tick
        set {_diamondHelm} to diamond helmet
        set line 1 of lore of {_diamondHelm} to "&eLeft click to &aBuy 1"
        set line 2 of lore of {_diamondHelm} to "&eCosts &f$2500"
        set line 3 of lore of {_diamondHelm} to "&cRight click &aSell 1"
        set line 4 of lore of {_diamondHelm} to "&eEarns &f$1250"
        format gui slot 0 of player with {_diamondHelm} to run function purchaseItem(player, 2500, diamond helmet) with "left" click
        format gui slot 0 of player with {_diamondHelm} to run function sellItem(player, 1250, diamond helmet) with "right" click
 
Any error? I would say change "item" on functions to "item type" or "material" but im not sure. if that fix your problem please mark as solved
 
Last edited by a moderator:
This give me no errors, my economy script can be added, subtracted, etc. So my economy is parsed correctly but these functions don't do anything. I can pull up the GUI with lore but nothing in it works. Running 2.2 fixes v8b

code_language.skript:
function purchaseItem(p: Player, cost: integer, i: item):
    if {bean.money.%{_p}%} >= {_cost}:
        remove {_cost} parsed as integer from {bean.money.%{_p}%}
        give {_item} parsed as item to {_p}
    else:
        broadcast "{@p}You cannot afford this item!"
function sellItem(p: Player, earn: integer, i: item):
    if {_p} has {_item}:
        remove {_item} from {_p}'s inventory
        add {_earn} to {bean.money.%{_p}%}  
   
on rightclick on villager:
    cancel event
    if name of player's target entity contains "&aBlacksmith":
        wait 1 tick
        open virtual chest inventory with size 6 named "&aShop" to player
        wait 1 tick
        set {_diamondHelm} to diamond helmet
        set line 1 of lore of {_diamondHelm} to "&eLeft click to &aBuy 1"
        set line 2 of lore of {_diamondHelm} to "&eCosts &f$2500"
        set line 3 of lore of {_diamondHelm} to "&cRight click &aSell 1"
        set line 4 of lore of {_diamondHelm} to "&eEarns &f$1250"
        format gui slot 0 of player with {_diamondHelm} to run function purchaseItem(player, 2500, diamond helmet) with "left" click
        format gui slot 0 of player with {_diamondHelm} to run function sellItem(player, 1250, diamond helmet) with "right" click

Setting an item to a variable and giving/taking the variable doesn't work (its never worked for me atleast... idk if someone knows a way around it)
 
This is working: Change item type to string and parse it when u are trying to give the item
code_language.skript:
on load:
    set {item} to "diamond sword"

function test2(p: player):
    give ("%{item}%" parsed as item type) to {_p}

Please mark as solved if it fixed ur problem.
 
This is working: Change item type to string and parse it when u are trying to give the item
code_language.skript:
on load:
    set {item} to "diamond sword"

function test2(p: player):
    give ("%{item}%" parsed as item type) to {_p}

Please mark as solved if it fixed ur problem.
The issues is he's using the wrong variable names in the function. @Op you should be using the names not the types
 
Status
Not open for further replies.