SignShop.sk

Created by YoshYz

Just so you know, we don't know the file format for every file. If it's just a bunch of random characters, it's probably a .zip or .jar.


#  ____    _                   ____    _                     
# / ___|  (_)   __ _   _ __   / ___|  | |__     ___    _ __  
# \___ \  | |  / _` | | '_ \  \___ \  | '_ \   / _ \  | '_ \ 
#  ___) | | | | (_| | | | | |  ___) | | | | | | (_) | | |_) |
# |____/  |_|  \__, | |_| |_| |____/  |_| |_|  \___/  | .__/ 
#              |___/                                  |_|    


#●▬▬▬▬๑۩ Informations ۩๑▬▬▬▬▬●
#
#Author: YoshYz
#Version: 1.1 Release
#
#●▬▬▬▬๑۩ Informations ۩๑▬▬▬▬▬●

#=====================================|
#
# SKRIPT LOAD
#
#=====================================| 
	
on skript load:
#Variables Fix
    remove "SignShop" from {signshop::itemslist::*}
    add "SignShop" to {signshop::itemslist::*}
#Config.yml
    set {_prefix} to yaml value "Prefix" from file "plugins/SignShop/Config.yml"
    if {_prefix} isn't set:
        set yaml value "Prefix" from file "plugins/SignShop/Config.yml" to "&3&lSIGN&f&lSHOP&r"
    set {_defaultbuyprice} to yaml value "Default.SellPrice" from file "plugins/SignShop/Config.yml"
    if {_defaultbuyprice} isn't set:
        set yaml value "Default.BuyPrice" from file "plugins/SignShop/Config.yml" to ("20" parsed as number)
    set {_defaultsellprice} to yaml value "Default.SellPrice" from file "plugins/SignShop/Config.yml"
    if {_defaultsellprice} isn't set:
        set yaml value "Default.SellPrice" from file "plugins/SignShop/Config.yml" to ("10" parsed as number)
#Sign.yml
    set {_line-1} to yaml value "Line.1" from file "plugins/SignShop/Sign.yml"
    if {_line-1} isn't set:
        set yaml value "Line.1" from file "plugins/SignShop/Sign.yml" to "&9&lSHOP"
#Prefix set
    set {signshop::prefix} to yaml value "Prefix" from file "plugins/SignShop/Config.yml"
	
#=====================================|
#
# COMMANDS
#
#=====================================| 
				
command /ss [<text>] [<text>] [<text>] [<number>]:
    aliases: /signshop, /signs or /sshop
    trigger:
        if argument-1 is "info":
            loop 2 times:
                message ""
            message " %{signshop::prefix}% &3Version &c1.1 &8[&9Author YoshYz&8]"
            loop 2 times:
                message ""
        if argument-1 is "help":
            if player has permission "signshop.help" or "signshop.admin":
                message ""
                message " %{signshop::prefix}%"
                message ""
                message "&7Commands List&8:"
                message " &9▪ &b/ss add/remove [item]"
                message " &9▪ &b/ss set sellprice [item] [price]"
                message " &9▪ &b/ss set buyprice [item] [price]"
                message " &9▪ &b/ss list"
                message ""
        if argument-1 is "add":
            if player has permission "signshop.add" or "signshop.admin":
                if argument-2 is set:
                    if {signshop::item::%arg-2%} isn't set:
                        set {signshop::item::%arg-2%} to "%arg-2%"
                        set {signshop::item::%arg-2%::buyprice} to yaml value "Default.BuyPrice" from file "plugins/SignShop/Config.yml"
                        set {signshop::item::%arg-2%::sellprice} to yaml value "Default.SellPrice" from file "plugins/SignShop/Config.yml"
                        set yaml value "Items.%arg-2%" from file "plugins/SignShop/Items.yml" to "-"
                        message " %{signshop::prefix}% &7You have added &a%arg-2% &7into the items list."
                        stop
                    else:
                        message " %{signshop::prefix}% &c%arg-2% &7is already in the list."
                        stop
                else:
                    message " %{signshop::prefix}% &cYou need to write the name of the item."
                    stop
        if argument-1 is "remove":
            if player has permission "signshop.remove" or "signshop.admin":
                if argument-2 is set:
                    if {signshop::item::%arg-2%} is set:
                        clear {signshop::item::%arg-2%}
                        delete yaml value "Items.%arg-2%" from file "plugins/SignShop/Items.yml"
                        message " %{signshop::prefix}% &7You have removed &a%arg-2% &7into the items list."
                        stop 
                    else:
                        message " %{signshop::prefix}% &c%arg-2% &7isn't in the items list."
                        stop
                else:
                    message " %{signshop::prefix}% &cYou need to write the name of the item."
                    stop
        if argument-1 is "set":
            if player has permission "signshop.set" or "signshop.admin":
                if argument-2 is "sprice", "sell", "sellprice" or "sp":
                    if argument-3 is set:
                        if argument-4 is set:
                            if {signshop::item::%arg-3%} is set:
                                set {signshop::item::%arg-3%::sellprice} to arg-4
                                set yaml value "Items.%arg-3%.sellprice" from file "plugins/SignShop/Items.yml" to "%arg-4%"
                                message " %{signshop::prefix}% &7You have setted &a%arg-3%&a's sell price &7to &b%arg-4%&7."
                                stop 
                            else:
                                message " %{signshop::prefix}% &c%arg-3% &7isn't in the items list."
                                stop
                        else:
                            message " %{signshop::prefix}% &cYou need to write the sell price of the item."
                            stop
                    else:
                        message " %{signshop::prefix}% &cYou need to write the name of the item."
                        stop
                if argument-2 is "bprice", "buy", "buyprice" or "bp":
                    if argument-3 is set:
                        if argument-4 is set:
                            if {signshop::item::%arg-3%} is set:
                                set {signshop::item::%arg-3%::buyprice} to arg-4
                                set yaml value "Items.%arg-3%.buyprice" from file "plugins/SignShop/Items.yml" to "%arg-4%"
                                message " %{signshop::prefix}% &7You have setted &a%arg-3%&a's buy price &7to &b%arg-4%&7."
                                stop 
                            else:
                                message " %{signshop::prefix}% &c%arg-3% &7isn't in the items list."
                                stop
                        else:
                            message " %{signshop::prefix}% &cYou need to write the buy price of the item."
                            stop
                    else:
                        message " %{signshop::prefix}% &cYou need to write the name of the item."
                        stop
                else:
                    message " %{signshop::prefix}% &cWrong Sintax."
                    stop
        if argument-1 is "list":
            if player has permission "signshop.list" or "signshop.admin":
                wait 4 ticks
                set {_size} to size of {signshop::item::*}
                if {_size} is less than 10:
                    open chest with 1 rows named "%{signshop::prefix}%" to the player
                if {_size} is less than 19:
                    if {_size} is more than 9:
                        open chest with 2 rows named "%{signshop::prefix}%" to the player
                if {_size} is less than 28:
                    if {_size} is more than 18:
                        open chest with 3 rows named "%{signshop::prefix}%" to the player
                if {_size} is less than 37:
                    if {_size} is more than 27:
                        open chest with 4 rows named "%{signshop::prefix}%" to the player
                if {_size} is less than 46:
                    if {_size} is more than 36:
                        open chest with 5 rows named "%{signshop::prefix}%" to the player
                if {_size} is less than 55:
                    if {_size} is more than 45:
                        open chest with 6 rows named "%{signshop::prefix}%" to the player
                set {_x} to 0
                loop {signshop::item::*}:
                    set {_item} to "%loop-value%" parsed as item
                    format slot {_x} of player with {_item} named "&8[&9%loop-value%&8]" with lore "|| &9✎ &3Informations&8:|||| &9▪ &bBuy Price&8: &c%{signshop::item::%loop-value%::buyprice}%|| &9▪ &bSell Price&8: &c%{signshop::item::%loop-value%::sellprice}%||&2" to be unstealable
                    add 1 to {_x}
					
#=====================================|
#
# SIGNS EVENTS
#
#=====================================|

command /ssg [<item>] [<player>]:
    executable by: console
    trigger:
        add arg-1 to arg-2's inventory
		
command /ssitemcheck [<item>] [<player>]:
    executable by: console
    trigger:
        if arg-2 has arg-1:
            set {sstempvariablecheck.%arg-2%} to "OK"
            remove arg-1 from arg-2's inventory

on sign change:
    set {_line-1} to yaml value "Line.1" from file "plugins/SignShop/Sign.yml"
    if line 1 is "SS SELL", "SS BUY" or "SS FREE":
        if line 2 is set:
            if player has permission "signshop.create" or "signshop.admin":
                set {_item} to "%{signshop::item::%uncolored line 2 of event-block%}%"
                if {signshop::item::%uncolored line 2 of event-block%} is set:
                    if line 1 of event-block contains "SELL":
                        set {_type} to "Sell"
                        set {_price} to {signshop::item::%uncolored line 2 of event-block%::sellprice}
                    if line 1 of event-block contains "BUY":
                        set {_type} to "Buy"
                        set {_price} to {signshop::item::%uncolored line 2 of event-block%::buyprice}
                    if line 1 of event-block contains "FREE":
                        set {_type} to "Free"
                        set {_price} to "-"
                    wait 1 tick
                    set line 1 of event-block to "%{_line-1}%"
                    set line 2 of event-block to "&3%{_item}%"
                    set line 3 of event-block to "&c%{_price}%"
                    set line 4 of event-block to "&b%{_type}%"
                    message "&9New Sign Informations&8:"
                    message ""
                    message " &9▪ &7Item&8: &3%{_item}%"
                    message " &9▪ &7Price&8: &c%{_price}%"
                    message " &9▪ &7Type&8: &b%{_type}%"
                    message ""
                    stop
					
on rightclick on sign:
    set {_line-1} to yaml value "Line.1" from file "plugins/SignShop/Sign.yml"
    if line 1 of event-block is "%{_line-1}%":
        if player has permission "signshop.use" or "signshop.admin":
            if line 4 of event-block contains "Buy":
                set line 3 of event-block to "&c%{signshop::item::%uncolored line 2 of event-block%::buyprice}%"
                if player's balance is more than {signshop::item::%uncolored line 2 of event-block%::buyprice}-1:
                    set {_item} to "%{signshop::item::%uncolored line 2 of event-block%}%"
                    set {_price} to "%{signshop::item::%uncolored line 2 of event-block%::buyprice}%" parsed as number
                    remove {_price} from player's balance
                    make console execute command "/ssg %{_item}% %player%"
                    set {_first-char} to first character of {_item}
                    if {_first-char} is "a", "e", "i", "o" or "u":
                        message " %{signshop::prefix}% &7You have bought an &a%{_item}% &7for &c%{_price}%&7."
                    else:
                        message " %{signshop::prefix}% &7You have bought a &a%{_item}% &7for &c%{_price}%&7."
                    stop
                else:
                    message " %{signshop::prefix}% &cYou don't have enought money."
                    stop
            if line 4 of event-block contains "Sell":
                set line 3 of event-block to "&c%{signshop::item::%uncolored line 2 of event-block%::sellprice}%"
                set {_item} to "%{signshop::item::%uncolored line 2 of event-block%}%"
                make console execute command "/ssitemcheck %{_item}% %player%"
                if {sstempvariablecheck.%player%} is "OK":
                    delete {sstempvariablecheck.%player%}
                    set {_price} to "%{signshop::item::%uncolored line 2 of event-block%::sellprice}%" parsed as number
                    add {_price} to player's balance
                    set {_first-char} to first character of {_item}
                    if {_first-char} is "a", "e", "i", "o" or "u":
                        message " %{signshop::prefix}% &7You have sold an &a%{_item}% &7for &c%{_price}%&7."
                    else:
                        message " %{signshop::prefix}% &7You have sold a &a%{_item}% &7for &c%{_price}%&7."
                    stop
                else:
                    message " %{signshop::prefix}% &cYou don't have this item to sell."
                    stop
            if line 4 of event-block contains "Free":
                set line 3 of event-block to "&c-"
                set {_item} to "%{signshop::item::%uncolored line 2 of event-block%}%"
                set {_price} to "free"
                make console execute command "/ssg %{_item}% %player%"
                set {_first-char} to first character of {_item}
                if {_first-char} is "a", "e", "i", "o" or "u":
                    message " %{signshop::prefix}% &7You have bought an &a%{_item}% &7for &c%{_price}%&7."
                else:
                    message " %{signshop::prefix}% &7You have bought a &a%{_item}% &7for &c%{_price}%&7."
                stop