Description: This script also can set server owned shops but allows for player owned shops as well.
This is a variation of the server owned item frame shop script, once again i cannot take full credit for this work as aufdemrand had a major part in laying the foundation for the server owned version. and many others helped make this work like mcmonkey talimar1 fullwall morphan1 and others.
Please give this script a like if you like it or use it so others can find it when they look for a shop script. thanks
Note: If you currently have the server owned version of the item frame shop on your server you will need to remove it for this script to work. this script has the option of making a store a server owned shop. for more details on this please visit https://www.youtube.com/watch?v=6uv_JhZpnYY for a short script setup tutorial. however if you do not plan to have player owned shops then i highly reccomend using the server version of the item frame shop script.
once again this works with the prices yaml you can find that here: http://scripts.citizensnpcs.co/view/f58jln place this script in the denizen folder not in the scripts folder.
thanks for looking at this script hope you enjoy it feel free to comment on any additional features you would like to see added. enjoy
StorekeeperPlayerOwned:
type: assignment
debug: true
default constants:
server_price_requirment: true
store open hour: 5
store close hour: 18
store greetings: [email protected] to my store!
|Feel free to look around!
|Just give me a click if you need something!
actions:
# Just some setup of the triggers
on remove:
- flag server playerstore:<-:<npc.flag[playerstore]>
on assignment:
- trigger name:proximity toggle:true radius:30
- trigger name:click toggle:true
- trigger name:chat toggle:true
- trigger name:damage toggle:true
- flag npc cashregister:5
on enter proximity:
- foreach <npc.flag[playerstore].as_cuboid.list_entities> {
- if !<def[value].has_framed_item> {
- adjust %value% framed:<npc.flag[storeitems].get[<npc.flag[storeitemlocations].find[<def[value].location>]>]>}}
on move proximity:
- if !<<player.flag[storekeepernpc]>.flag[playerstore].as_cuboid.is_within[<player.location>]> && '<player.inventory.contains[[email protected] bag]>' {
- inventory add o:[email protected]<player.name>_shopping_bag d:<<player.flag[storekeepernpc]>.inventory>
- take "[email protected] bag"
- narrate "<dark_red>No stealing items from my store!!"}
- if <player> == <npc.owner> && <npc.can_see[<player>]> && !<player.flag[greeted]> {
- narrate "<dark_purple>Hello <player.name> just ask for <green>'help' <dark_purple>if you need a command refresher for your shop"
- flag player greeted duration:5m
} else if !<player.flag[greeted]> && <npc.can_see[<player>]> {
- if !<npc.flag[greeting]> == null {
- narrate "<aqua><npc.flag[greeting].random>"}
else {
- narrate "<aqua><[email protected][<npc.constant[store greetings]>].as_list.random>"}
- flag player greeted duration:30s
}
on damage:
- flag player storekeepernpc:[email protected]<npc>
- if <player> == <npc.owner> {
- narrate "<dark_purple> The balance is <green><npc.flag[cashregister].as_int>"
- narrate "<dark_purple>would you like to <green>'give' <dark_purple>money to your store or <green>'take' <dark_purple>money from your store?"} else if '!<player.inventory.contains[[email protected] bag]>' && '!<player.inventory.contains[[email protected] bag]>' {
- note '[email protected] bag' as:<player.name>_shopping_bag
- animate <npc> arm_swing
- flag player storekeepernpc:<npc>
- narrate '<aqua>Here, have a complimentary shopping bag!'
- give <player> '[email protected] bag'
} else if <player.item_in_hand> == '[email protected] bag' && <npc.owner> == server {
- define total_price 0
- foreach <[email protected]<player.name>_shopping_bag.list_contents> {
- adjust %value% quantity:1 save:item2
- if <server.flag[<<entry[item2].result>.full.escaped>]> == null {
- flag server <<entry[item2].result>.full.escaped>:1.00}
- adjust %value% quantity:1 save:item
- define price <yaml[prices].read[prices.<<entry[item].result>.full.escaped>].mul[2].mul[<server.flag[<entry[item].result.full.escaped>]>].mul[<%value%.qty>]>
- define total_price <[email protected][%total_price%].add[%price%]> }
- narrate "<aqua>Ready to check out? Just click me with your bag!"
- narrate "<aqua>your total price is <green>%total_price%"} else if <player.item_in_hand> == '[email protected] bag' {
- define total_price 0
- foreach <[email protected]<player.name>_shopping_bag.list_contents> {
- if !<npc.flag[sell_<%value%.full.escaped>].mul[<%value%.qty>]> == null {
- define price <npc.flag[sell_<%value%.full.escaped>].mul[<%value%.qty>]>}
else {
- define price <[email protected][<npc.flag[sell_<%value%.full.escaped>]>].mul[<%value%.qty>]>
- define total_price <[email protected][%total_price%].add[%price%]> }}
- narrate "<aqua>Ready to check out? Just click me with your bag!"
- narrate "<aqua>your total price is <green>%total_price%"} else if <player.item_in_hand> == '[email protected] bag' && <npc.owner> == server {
- define total_price 0
- foreach <[email protected]<player.name>_shopping_bag.list_contents> {
- adjust %value% quantity:1 save:item
- define price <yaml[prices].read[prices.<<entry[item].result>.escaped>].mul[<%value%.qty>]>
- define total_price <[email protected][%total_price%].add[%price%]> }
- narrate "<aqua>Ready to sell items? Just right click me with your bag!"
- narrate "<aqua>your total price is <green>%total_price%"} else if <player.item_in_hand> == '[email protected] bag' {
- define total_price 0
- foreach <[email protected]<player.name>_selling_bag.list_contents> {
- define price <npc.flag[buy_%value%].as_int>
- define total_price <[email protected][%total_price%].add[%price%]> }
- narrate "<aqua>Ready to sell items? Just right click me with your bag!"
- narrate "<aqua>your total price is <green>%total_price%"}
else {
- flag player storekeepernpc:[email protected]<npc>
}
on chat:
- if <context.message> == greeting && <player> == <npc.owner> {
- narrate "<dark_purple>Would you like to <green>add <dark_purple>or <green>remove<dark_purple> a greeting?"
- flag player greeting
- determine cancelled
}
- if <player.flag[greeting]> == true && <player> == <npc.owner> {
- if <context.message> == add {
- if <npc.flag[greeting].as_list.size> > 4{
- narrate "You cannot exceed five greetings!"
- flag player greeting:!
- determine cancelled
- queue clear
}
else {
- narrate "<dark_purple>Please say the greeting you would like to add to your store"
- flag player greeting:!
- flag player addgreeting
- determine cancelled
}}
else if <context.message> == remove && <npc.owner> == <player> {
- flag player greeting:!
- flag player removegreeting
- narrate "What line number would you like to remove?"
- foreach <npc.flag[greeting].as_list> {
- narrate "%loop_index%=%value%"}
- determine cancelled
}}
- if <player.flag[removegreeting]> == true && <player> == <npc.owner> {
- narrate "<npc.flag[greeting].get[<context.message>]>"
- narrate "Has been removed"
- flag npc greeting[<context.message>]:<-
- flag player removegreeting:!
- determine cancelled
}
- if <player.flag[addgreeting]> == true && <player> == <npc.owner> {
- flag npc greeting:->:<context.message>
- flag player addgreeting:!
- narrate "<dark_purple>You added a new greeting to your list. Your new greeting is"
- narrate "<green><context.message>"
- determine cancelled
}
- if <context.message> == expand && <player> == <npc.owner> {
- execute as_op "npc select <npc.id> as:<player>"
- flag server playerstore:<-:<npc.flag[playerstore]>
- give [email protected]
- narrate "<dark_purple>please reselect the bottom and top corners of your cuboid then drop the selector"
- determine cancelled
}
- if <context.message> == help && <player> == <npc.owner> {
- narrate "<dark_purple>your shop commands are <green> Greeting, items, give, take, set, unset, expand."
- narrate "<dark_purple>Click the npc with an item to set a price for it"
- narrate "<dark_purple>Right click the npc without an item to view inventory for the store"
- determine cancelled
}
- if <context.message> == items && <player> == <npc.owner> {
- if <npc.flag[buyback]> == null {
- narrate "<aqua>No items have been sold to your shop"}
else {
- give <npc.flag[buyback]>
- flag npc buyback:!
- determine cancelled
}}
- if <player.flag[givingtocashregister]> == true && <player> == <npc.owner> {
- flag npc cashregister:+:<context.message>
- take money qty:<context.message>
- narrate "<dark_purple>You give <green><context.message> <dark_purple>to the cash register. The balance is now <green><npc.flag[cashregister].as_int>"
- flag player givingtocashregister:!
- determine cancelled
}
- if <context.message> == give && <player> == <npc.owner> {
- flag player givingtocashregister
- narrate "<dark_purple>How much would you like to give to the store?"
- determine cancelled
}
- if <context.message> == take && <player> == <npc.owner> {
- flag player takingfromcashregister
- narrate "<dark_purple>How much would you like to take from the store?"
- determine cancelled
}
- if <player.flag[takingfromcashregister]> == true && <player> == <npc.owner> {
- if <npc.flag[cashregister]> > <context.message> {
- flag npc cashregister:-:<context.message>
- give money qty:<context.message>
- narrate "<dark_purple>You take <green><context.message> <dark_purple>from the cash register. The balance is now <green><npc.flag[cashregister].as_int>"
- flag player takingfromcashregister:!
- determine cancelled
}
else if <npc.flag[cashregister]> < <context.message> {
- narrate "<dark_red>You havnt got that much money in your cashregister!"}}
- if <context.message> == unset && <player> == <npc.owner> {
- flag server playerstore:<-:<npc.flag[playerstore]>
- narrate "<dark_red>your store is now unprotected! tell the npc to 'set' the store back up when you are done editing"
- determine cancelled
}
- if <context.message> == sell {
- if <npc.owner> == server {
- note '[email protected] bag' as:<player.name>_selling_bag
- animate <npc> arm_swing
- narrate '<aqua>Here is your item selling bag!'
}
else {
- note '[email protected] bag' as:<player.name>_selling_bag
- animate <npc> arm_swing
- narrate '<aqua>Here is your item selling bag!'
- narrate "<aqua>We buy the following items that you have"
- foreach <player.inventory.list_contents.simple> {
- if !<npc.flag[buy_<%value%.full.escaped>]> == null {
- if <%value%.display> == null {
- narrate "<aqua>We buy <green><%value%.material.name> <aqua>for <green><npc.flag[buy_<%value%.escaped>]> coins a piece"}
else {
- narrate "<aqua>We buy <green><%value%.display> <aqua>for <green><npc.flag[buy_<%value%.full.escaped>]> coins a piece"}}}}
- drop '[email protected] bag' <npc.location.add[<npc.location.direction.vector.mul[2]>].add[0,1,0]>
- determine cancelled
}
- if <context.message> == set && <player> == <npc.owner> && !<server.flag[playerstore].as_list> contains <npc.flag[playerstore]> {
- narrate "<&b>your store is now open for business!"
- flag server playerstore:->:<npc.flag[playerstore]>
- flag npc storeitems:!
- foreach <npc.flag[playerstore].as_cuboid.list_entities> {
- if <def[value].entity_type> == item_frame {
- flag npc storeitems:->:<def[value].framed_item>
- flag npc storeitemlocations:->:<def[value].location>
}}
- determine cancelled
}
- if <context.message> == buying && <player> == <npc.owner> {
- if <npc.constant[server_price_requirment]> == true {
- narrate "<dark_purple>please set a price below <green><yaml[prices].read[prices.<npc.flag[currentitem]>]> <dark_purple>for that item."
- flag player settype:buy
- determine cancelled
}
else {
- flag player settype:buy
- narrate "<dark_purple>please set a price for that item"
- determine cancelled
}}
- if <context.message> == selling && <player> == <npc.owner> {
- if <npc.constant[server_price_requirment]> == true {
- narrate "<dark_purple>please set a price above <green><yaml[prices].read[prices.<npc.flag[currentitem]>]> <dark_purple>for that item."
- flag player settype:sell
- determine cancelled
}
else {
- flag player settype:sell
- narrate "<dark_purple>please set a price for that item"
- determine cancelled
}}
- if !<npc.flag[currentitem]> == null && <player> == <npc.owner> {
- if <player.flag[settype]> == buy && <npc.constant[server_price_requirment]> == true {
- if <context.message> > <yaml[prices].read[prices.<npc.flag[currentitem]>]> && <context.message.is[matches].to[integer]> {
- narrate "<dark_red>your price needs to be below the base price. this price will not be set for this item."
- flag npc currentitem:!
- flag player settype:!
- determine cancelled
}
else if <context.message> < <yaml[prices].read[prices.<npc.flag[currentitem]>]> && <context.message.is[matches].to[integer]> {
- flag npc <player.flag[settype]>_<npc.flag[currentitem]>:<context.message>
- if <<npc.flag[currentitem].unescaped>.display> == null {
- narrate "<dark_purple><<npc.flag[currentitem].unescaped>.material.name> <player.flag[settype]> price is now set to <green><context.message>"}
else {
- narrate "<dark_purple><<npc.flag[currentitem].unescaped>.display> <player.flag[settype]> price is now set to <green><context.message>"}
- flag npc currentitem:!
- flag player settype:!
- determine cancelled
}
else {
- narrate "<dark_red>That doesn not match a valid number! please set a proper number for a price"
- determine cancelled
}}}
- if !<npc.flag[currentitem]> == null && <player> == <npc.owner> {
- if <player.flag[settype]> == sell && <npc.constant[server_price_requirment]> == true {
- if <context.message> < <yaml[prices].read[prices.<npc.flag[currentitem]>]> && <context.message.is[matches].to[integer]> {
- narrate "<dark_red>your price needs to be above the base price. this price will not be set for this item."
- flag npc currentitem:!
- flag player settype:!
- determine cancelled
}
else if <context.message> > <yaml[prices].read[prices.<npc.flag[currentitem]>]> && <context.message.is[matches].to[integer]> {
- flag npc <player.flag[settype]>_<npc.flag[currentitem]>:<context.message>
- if <<npc.flag[currentitem].unescaped>.display> == null {
- narrate "<dark_purple><<npc.flag[currentitem].unescaped>.material.name> <player.flag[settype]> price is now set to <green><context.message>"}
else {
- narrate "<dark_purple><<npc.flag[currentitem].unescaped>.display> <player.flag[settype]> price is now set to <green><context.message>"}
- flag npc currentitem:!
- flag player settype:!
- determine cancelled
}
else {
- narrate "<dark_red>That doesn not match a valid number! please set a proper number for a price"
- determine cancelled
}}}
- if !<npc.flag[currentitem]> == null && <player> == <npc.owner> {
- if !<npc.constant[server_price_requirment]> == true {
- if <context.message.is[matches].to[integer]> {
- flag npc <player.flag[settype]>_<npc.flag[currentitem]>:<context.message>
- if <<npc.flag[currentitem].unescaped>.display> == null {
- narrate "<dark_purple><<npc.flag[currentitem].unescaped>.material.name> <player.flag[settype]> price is now set to <green><context.message>"}
else {
- narrate "<dark_purple><<npc.flag[currentitem].unescaped>.display> <player.flag[settype]> price is now set to <green><context.message>"}
- flag npc currentitem:!
- flag player settype:!
- determine cancelled
}
else {
- narrate "<dark_red>That is not a valid number. please select a valid number for the price"
- determine cancelled
}}
on click:
- if <player> == <npc.owner> && !<player.item_in_hand> == [email protected]{
- adjust <player.item_in_hand> quantity:1 save:item8
- flag npc currentitem:<entry[item8].result.full.escaped>
- narrate "<dark_purple>will you be <green>'selling' <dark_purple>or <green>'buying' <dark_purple>for this item?"
- queue clear
- determine cancelled
}
else if <player> == <npc.owner> && <player.item_in_hand> == [email protected]{
- inventory open d:<npc.inventory>
}
- if <player.item_in_hand> == "[email protected] bag"{
- if <[email protected]<player.name>_shopping_bag.qty> == 0{
- narrate "<aqua>your shopping bag is empty!"} else if <npc.owner> == server {
- flag player delay duration:3s
- chat "ok let's total these items up for you then!"
- define total_price 0
- foreach <[email protected]<player.name>_shopping_bag.list_contents> {
- adjust %value% quantity:1 save:item2
- if <server.flag[<<entry[item2].result>.full.escaped>]> == null {
- flag server <<entry[item2].result>.full.escaped>:1.00}
- adjust %value% quantity:1 save:item
- define price <yaml[prices].read[prices.<<entry[item].result>.full.escaped>].mul[2].mul[<server.flag[<entry[item].result.full.escaped>]>].mul[<%value%.qty>]>
- define total_price <[email protected][%total_price%].add[%price%]> }
- if <player.money> < %total_price% {
- narrate "<dark_red>YOU NEED MONEYS D="
- queue clear
}
- flag player bagnumber:+:1
- note "[email protected] bag""as:<player.name> <player.flag[bagnumber].as_int>_item_bag"
- take money qty:%total_price%
- run "itemgiverPlayer Owned" delay:1s
- take '[email protected] bag'
- narrate "<aqua>The shopkeeper takes <green>%total_price% coins"
- narrate "<gold>You are all checked out. have a great day!"
- narrate "<red>Do not open your item bag until you are ready to take all the items out"
- foreach <[email protected]<player.name>_shopping_bag.list_contents.full.escaped> {
- adjust %value% quantity:1 save:item9
- flag server <entry[item9].result>adjust:+:<def[value].qty>
- run script:price_adjuster def:<entry[item9].result>
}}
else {
- flag player delay duration:3s
- chat "ok let's total these items up for you then!"
- define total_price 0
- foreach <[email protected]<player.name>_shopping_bag.list_contents> {
- adjust %value% quantity:1 save:item2
- if <server.flag[<<entry[item2].result>.full.escaped>]> == null {
- flag server <<entry[item2].result>.full.escaped>:1.00}
- define price <[email protected][<npc.flag[sell_<entry[item2].result.full.escaped>]>].mul[<%value%.qty>]>
- define total_price <[email protected][%total_price%].add[%price%]> }
- if <player.money> < %total_price% {
- narrate "<dark_red>YOU NEED MONEYS D="
- queue clear
}
- if <npc.inventory.list_contents.simple> contains <[email protected]<player.name>_shopping_bag.list_contents.simple> {
- narrate "<aqua>I am sorry but we just ran out of some of those items!"
- queue clear
}
- flag player bagnumber:+:1
- note "[email protected] bag""as:<player.name> <player.flag[bagnumber].as_int>_item_bag"
- take money qty:%total_price%
- flag npc cashregister:+:%total_price%
- run "itemgiverPlayer Owned" delay:1s
- take '[email protected] bag'
- narrate "<aqua>The shopkeeper takes <green>%total_price% coins"
- narrate "<gold>You are all checked out. have a great day!"
- narrate "<red>Do not open your item bag until you are ready to take all the items out"
- foreach <[email protected]<player.name>_shopping_bag.list_contents.full.escaped> {
- adjust %value% quantity:1 save:item9
- flag server <entry[item9].result>adjust:+:<def[value].qty>
- run script:price_adjuster def:<entry[item9].result>
}}} else if <player.item_in_hand> == "[email protected] bag"{
- flag player delay duration:3s
- if <[email protected]<player.name>_selling_bag.qty> == 0{
- narrate "<dark_red>your selling bag is empty!"} else if <[email protected]<player.name>_selling_bag.contains['[email protected] bag']> {
- chat "i am sorry but i do not buy back my shopping bags."} else if <npc.owner> == server {
- chat "ok let's total these items up for you then!"
- define total_price 0
- foreach <[email protected]<player.name>_selling_bag.list_contents> {
- adjust %value% quantity:1 save:item
- define price <yaml[prices].read[prices.<<entry[item].result>.full.escaped>].mul[<%value%.qty>]>
- define total_price <[email protected][%total_price%].add[%price%]> }
- note '[email protected] bag' as:<player.name>_selling_bag
- give money qty:%total_price%
- take '[email protected] bag'
- narrate "<aqua>The shopkeeper gives you <green>%total_price% coins"
- foreach <[email protected]<player.name>_shopping_bag.list_contents.full.escaped> {
- adjust %value% quantity:1 save:item9
- flag server <<entry[item9].result>adjust:-:<def[value].qty>
- run script:price_adjuster def:<entry[item9].result>
}
- queue clear
}
else {
- chat "ok let's total these items up for you then!"
- define total_price 0
- foreach <[email protected]<player.name>_selling_bag.list_contents> {
- adjust %value% quantity:! save:item
- define price <[email protected][<npc.flag[buy_<%item%.full.escaped>]>].mul[<%value%.qty>]>
- define total_price <[email protected][%total_price%].add[%price%]> }
- if %total_price% < <npc.flag[wallet].as_int> {
- flag npc buyback:->:<[email protected]<player.name>_selling_bag.list_contents>
- note '[email protected] bag' as:<player.name>_selling_bag
- give money qty:%total_price%
- flag npc cashregister:-:%total_price%
- take '[email protected] bag'
- narrate "<aqua>The shopkeeper gives you <green>%total_price% coins"
- foreach <[email protected]<player.name>_shopping_bag.list_contents.full.escaped> {
- adjust %value% quantity:1 save:item9
- flag server <entry[item9].result>adjust:-:<def[value].qty>
- run script:price_adjuster def:<entry[item9].result>
}
- queue clear
}
else {
- narrate "<aqua>I am sorry I don't have the funds to buy all of that back!"}}} else {
- if [email protected]<player.inventory> contains '[email protected] bag' || [email protected]<player.inventory> contains '[email protected] bag' {} else if <player> == <npc.owner> {
- queue clear
}
else {
- chat "Please visit http://youtu.be/2f3Dk4cPCXs for a short tutorial of how to use our stores."}
itemgiverPlayer Owned:
type: task
debug: true
script:
- inventory add o:[email protected]<player.name>_shopping_bag 'd:[email protected]<player.name> <player.flag[bagnumber].as_int>_item_bag'
- ^adjust '[email protected]_bag' "lore:<player.name> <player.flag[bagnumber].as_int>" save:playersbag
- give <entry[playersbag].result.full>
Item Frame Shop Player Owned:
type: world
debug: true
events:
on server start:
- yaml load:prices.yml id:prices
on price command:
- if <player.is_op> {
- adjust <player.item_in_hand.full> quantity:1 save:item3
- if !<yaml[prices].contains[prices.<entry[item3].result.full.escaped>]> {
- flag player setpriceserver:<entry[item3].result.full.escaped>
- narrate "<dark_purple>what is the base price you want for that item?"
- determine cancelled
}
else {
- narrate "<dark_purple>That item already has a current price of <green><yaml[prices].read[prices.<entry[item3].result.full.escaped>]>"
- narrate "<dark_purple>To adjust that items price use the /adjust_price command"
- determine cancelled
}}
on adjust_price command:
- adjust <player.item_in_hand.full> quantity:1 save:item3
- yaml id:prices set prices.<entry[item3].result.full.escaped>:!
- flag player setpriceserver:<entry[item3].result.full.escaped>
- narrate "<dark_purple>what is the base price you want for that item?"
- determine fulfilled
on player chats:
- if <player.is_op> && !<player.flag[setpriceserver]> == null {
- if <context.message.is[matches].to[integer]> {
- yaml id:prices set prices.<player.flag[setpriceserver]>:<context.message>
- yaml savefile:prices.yml id:prices
- narrate "<dark_purple><<player.flag[setpriceserver].unescaped>.display> price is now set to <green><yaml[prices].read[prices.<player.flag[setpriceserver]>]>"
- flag setpriceserver:!
- determine cancelled
}
else {
- narrate "<dark_red>That is not a valid number"
- narrate "<dark_purple>what is the base price you want for that item?"
- determine cancelled
}}
on stop command:
- foreach <server.flag[storenpcs].as_list> {
- flag %value% playerstoreinventory:<def[value].inventory.list_contents>}
on entity teleports:
- if '<player.inventory.contains[[email protected] bag]>' {
- queue clear
}
else if '<player.inventory.contains[[email protected] bag]>' {
- inventory add o:[email protected]<player.name>_shopping_bag d:<<player.flag[storekeepernpc]>.inventory>
- take "[email protected] bag"
- narrate "<dark_red>No stealing items from my store!!"}
on player quits:
- if '<player.inventory.contains[[email protected] bag]>' {
- inventory add o:[email protected]<player.name>_shopping_bag d:<<player.flag[storekeepernpc]>.inventory>
- take "[email protected] bag"
- narrate "<dark_red>No stealing items from my store!!"}
on store_setup command:
- give <player> [email protected]
- determine fulfilled
on player clicks with [email protected]:
- if <global.flag[playerstore].escape_contents> == null {
- run "storelocationstick3" as:<player> delay:1t
- create player storekeeper <player.location.cursor_on.add[0.5,1,0.5]>
- execute as_op "npc select"
- narrate "<dark_purple>please select the bottom and top corners of your cuboid then drop the selector"
- take [email protected]
- lookclose <player.selected_npc> state:true
- queue clear
}
- foreach <global.flag[playerstore].escape_contents> {
- if <def[value].unescaped.as_cuboid.is_within[<context.location>]> {
- narrate "you cannot place your store inside of someone another store"
- determine cancelled
}}
- foreach <global.flag[playerstore].escape_contents> {
- if !<def[value].unescaped.as_cuboid.is_within[<context.location>]> {
- run "storelocationstick3" as:<player> delay:1t
- create player storekeeper <player.location.cursor_on.add[0.5,1,0.5]>
- execute as_op "npc select"
- narrate "<dark_purple>please select the bottom and top corners of your cuboid then drop the selector"
- take [email protected]
- lookclose <player.selected_npc> state:true
- queue clear
}}
on item_frame damaged by entity_explosion:
- foreach <global.flag[playerstore].escape_contents> {
- if <def[value].unescaped.as_cuboid.is_within[<context.entity.location>]> {
- determine cancelled
}}
on item_frame damaged by block_explosion:
- foreach <global.flag[playerstore].escape_contents> {
- if <def[value].unescaped.as_cuboid.is_within[<context.entity.location>]> {
- determine cancelled
}}
on player right clicks with [email protected]:
- if <global.flag[playerstore].escape_contents> == null {
- run "storelocationstick2" def:<context.location> as:<player> delay:1t
- flag player location1:<context.location>
- narrate "<dark_purple>Cuboid location 1 selected"
- determine cancelled
}
- foreach <global.flag[playerstore].escape_contents> {
- if <def[value].unescaped.as_cuboid.is_within[<context.location>]> {
- determine cancelled
}
else {
- run "storelocationstick2" def:<context.location> as:<player> delay:1t
- flag player location1:<context.location>
- narrate "<dark_purple>Cuboid location 1 selected"
- determine cancelled
}}
on player left clicks with [email protected]:
- if <global.flag[playerstore].escape_contents> == null {
- run "storelocationstick2" def:<context.location> as:<player> delay:1t
- flag player location2:<context.location>
- narrate "<dark_purple>Cuboid location 2 selected"
- determine cancelled
}
- foreach <global.flag[playerstore].escape_contents> {
- if <def[value].unescaped.as_cuboid.is_within[<context.location>]> {
- determine cancelled
}
else {
- flag player location2:<context.location>
- run "storelocationstick2" def:<context.location> as:<player> delay:1t
- narrate "<dark_purple>Cuboid location 2 selected"
- determine cancelled
}}
on player drops [email protected]:
- execute as_op "npc owner <player.name> --id <player.selected_npc.id>"
- assignment set npc:<player.selected_npc> script:StorekeeperPlayerOwned
- flag <player.selected_npc> playerstore:[email protected]<player.flag[location1]>|<player.flag[location2]>
- flag player location1:!
- flag player location2:!
- flag server storenpcs:->:<npc>
- run "storeselectorremover2" delay:1t
- narrate "<dark_purple>tell the npc <green>'SET' <dark_purple>to set the items in the frame"
- determine cancelled
on player right clicks [email protected]_frame:
- foreach <global.flag[playerstore].escape_contents> {
- if <def[value].unescaped.as_cuboid.is_within[<context.location>]> {
- if <player.item_in_hand.scriptname> == 'shopping bag' {
- if <[email protected]<player.name>_shopping_bag.stacks> >= 18{
- narrate "<aqua>Your shopping bag is full!"}
else if <<player.flag[storekeepernpc]>.owner> == server {
- inventory add o:<c.entity.framed_item> d:[email protected]<player.name>_shopping_bag
- if <c.entity.framed_item.display> != null
narrate "<aqua>You add a <green><c.entity.framed_item.display> <aqua>to your shopping bag."
else
narrate "<aqua>You add <green><c.entity.framed_item.material.name.replace[_].with[ ]> <aqua>to your shopping bag."
- playsound <player> sound:DIG_GRASS
}
else if <<player.flag[storekeepernpc]>.inventory.list_contents.simple> contains <context.entity.framed_item> {
- inventory add o:<c.entity.framed_item> d:[email protected]<player.name>_shopping_bag
- take <c.entity.framed_item> from:<<player.flag[storekeepernpc]>.inventory>
- if <c.entity.framed_item.display> != null
narrate "<aqua>You add a <green><c.entity.framed_item.display> <aqua>to your shopping bag."
else
narrate "<aqua>You add <green><c.entity.framed_item.material.name.replace[_].with[ ]> <aqua>to your shopping bag."
- playsound <player> sound:DIG_GRASS
}
else {
- narrate "<dark_red>That item is out of stock!"}}
- determine cancelled
}}}
on player places block:
- foreach <global.flag[playerstore].escape_contents> {
- if <def[value].unescaped.as_cuboid.is_within[<context.location>]> {
- if <player.is_sneaking> && <player.is_op> {
- queue clear
} else {
- determine cancelled
}}}
on player breaks [email protected]_frame:
- foreach <global.flag[playerstore].escape_contents> {
- if <def[value].unescaped.as_cuboid.is_within[<context.location>]> {
- if <player.is_sneaking> && <player.is_op> {
- queue clear
}
else {
- if <c.hanging.framed_item.display> != null
narrate "It's a <c.hanging.framed_item.display>."
else
narrate "It's <c.hanging.framed_item.material.formatted>."
- narrate "Right click it with your shopping bag to add it to your transaction."
- determine cancelled
}}}
on player breaks block:
- foreach <global.flag[playerstore].escape_contents> {
- if <def[value].unescaped.as_cuboid.is_within[<context.location>]> {
- if <player.is_sneaking> && <player.is_op> {
- queue clear
} else {
- determine cancelled
}
- if <player.flag[storekeeper_warned]> == null {
- narrate '<aqua>[storekeeper] -> You<&co> <dark_red>Hey! <aqua>You break it, you buy it! <dark_red>Be careful!'
- flag <player> storekeeper_warned duration:5s
}}}
on entity damages [email protected]_frame:
- foreach <global.flag[playerstore].escape_contents> {
- if <def[value].unescaped.as_cuboid.is_within[<context.entity.location>]> {
- if <player.is_sneaking> && <player.is_op> {
- queue clear
}
else {
- foreach <global.flag[playerstore].escape_contents> {
- if <def[value].unescaped.as_cuboid.is_within[<context.entity.location>]> {
- if <server.flag[<context.entity.framed_item.full.escaped>]> == null {
- flag server <context.entity.framed_item.full.escaped>:1.00
- determine cancelled
}
else if <<player.flag[storekeepernpc]>.owner> == server {
- define price <yaml[prices].read[prices.<context.entity.framed_item.full.escaped>].mul[2].mul[<server.flag[<context.entity.framed_item.full.escaped>]>].as_int>
- narrate "<green>%price%"
- determine cancelled
}
else {
- define price <<player.flag[storekeepernpc]>.flag[sell_<context.entity.framed_item.full.escaped>]>
- narrate "<green>%price%"
- determine cancelled
}}}}}}
on player right clicks entity with [email protected] bag:
- if <context.entity.as_npc> == <npc> {
- flag player shopkeeper:<npc>
}
on player places item_frame:
- foreach <global.flag[playerstore].escape_contents> {
- if <def[value].unescaped.as_cuboid.is_within[<context.location>]> {
- if <player.is_sneaking> && <player.is_op> {
- queue clear
} else {
- determine cancelled
}}}
on player right clicks with [email protected] bag:
- define is_shopping false
- foreach <global.flag[playerstore].escape_contents> {
- if <player.location.is_within[<def[value].unescaped>]> {
- define is_shopping true
- foreach stop
}}
- if !<player.inventory.qty[[email protected] bag]> >= 2{
- take '[email protected] bag' qty:36
- note '[email protected] bag' as:<player.name>_shopping_bag
}
- if !%is_shopping% {
- inventory clear d:[email protected]<player.name>_shopping_bag
- take '[email protected] bag'
- narrate '<dark_red>You are not shopping right now!'
}
else if <[email protected]<player.name>_shopping_bag||null> == null && %is_shopping% {
- note '[email protected] bag' as:<player.name>_shopping_bag
}
else if %is_shopping% {
- if !<context.location.find.entities[item].within[1].exclude[<player>].get[1]||null> == null {
- inventory add o:<<player.location.cursor_on.find.entities[item].within[1].exclude[<player>].get[1]>.item> d:[email protected]<player.name>_shopping_bag
- narrate "<aqua>You add <green><<context.location.find.entities[item].within[1].exclude[<player>].get[1]>.item.material.name.replace[_].with[ ]> <aqua>to your shopping bag."}
else if !<player.location.cursor_on.find.entities[item].within[1].exclude[<player>].get[1]||null> == null {
- inventory add o:<<player.location.cursor_on.find.entities[item].within[1].exclude[<player>].get[1]>.item> d:[email protected]<player.name>_shopping_bag
- narrate "<aqua>You add <green><<player.location.cursor_on.find.entities[item].within[1].exclude[<player>].get[1]>.item.material.name.replace[_].with[ ]> <aqua>to your shopping bag."}
else {
- narrate '<aqua>You take a look in your shopping bag...'
- inventory open d:[email protected]<player.name>_shopping_bag
}}
- determine cancelled
on player right clicks with [email protected] bag:
- define is_shopping false
- foreach <global.flag[playerstore].escape_contents> {
- if <player.location.is_within[<def[value].unescaped>]> {
- define is_shopping true
- foreach stop
}}
- if !%is_shopping% {
- inventory clear d:[email protected]<player.name>_selling_bag
- narrate '<dark_red>You are not in a shop right now!'
- take '[email protected] bag'
- determine cancelled
}
else if <[email protected]<player.name>_shopping_bag||null> == null && %is_shopping% {
- note '[email protected] bag' as:<player.name>_selling_bag
- inventory open d:[email protected]<player.name>_selling_bag
- determine cancelled
}
else if %is_shopping% {
- inventory open d:[email protected]<player.name>_selling_bag
- determine cancelled
}
- determine cancelled
on player right clicks with [email protected]_bag:
- foreach <global.flag[playerstore].escape_contents> {
- if <def[value].unescaped.as_cuboid.is_within[<context.location>]> && <player.location.facing[<player.flag[shopkeeper]>]> {} else {
- narrate '<aqua>You take a look in your shopping bag...'
- inventory open "d:[email protected]<context.item.lore.as_string.strip_color>_item_bag"}
- determine cancelled
}
on player drops [email protected] bag:
- narrate '<aqua>You ditch your shopping bag.'
- if !<<player.flag[storekeepernpc]>.owner> == server {
- inventory add o:[email protected]<player.name>_shopping_bag 'd:<<player.flag[storekeepernpc]>.inventory>'
}
- run "bagremovertaskPlayer Owned" delay:1t
- determine cancelled
on player drops [email protected] bag:
- narrate '<aqua>You ditch your selling bag.'
- run "bagremovertask1Player Owned" delay:1t
- determine cancelled
on player clicks in inventory:
- if <c.inventory> == '[email protected]<player.name>_shopping_bag' && <player.item_in_hand> == '[email protected] bag' {
- determine passively cancelled
- inventory update d:<player.inventory>
}
- if <c.inventory> == '[email protected]<player.name>_shopping_bag' && <player.item_in_hand> == '[email protected] bag' {
- if <context.is_shift_click> {
- determine passively cancelled
- inventory update d:<player.inventory>
}}
- if <c.inventory> == '[email protected]<player.name>_selling_bag' {
- if "[email protected]@shopping bag|[email protected] bag|[email protected]_bag" contains <context.item> {
- inventory update
- determine cancelled
}}
on player picks up [email protected] bag:
- if '<player.inventory.contains[[email protected] bag]>' {
- determine cancelled
} else {
- note '[email protected] bag' as:<player.name>_shopping_bag
- narrate "<aqua>You pick up a brand new shopping bag. It's empty!"}
on player closes inventory:
- if <player.item_in_hand> == '[email protected]_bag' {
- if <context.inventory> == <player.inventory> {} else {
- foreach <[email protected]<player.item_in_hand.lore.as_string.strip_color>_item_bag.list_contents> {
- drop %value% <player.location>}
- narrate "<dark_red>your shopping bag ripped"
- take iteminhand
}
on player picks up [email protected]:
- narrate "<aqua>To learn how to set up the frame shop please visit <green>https://www.youtube.com/watch?v=FlYEog5-KxU"
on player clicks [email protected] in inventory:
- narrate "<aqua>To learn how to set up the frame shop please visit <green>https://www.youtube.com/watch?v=FlYEog5-KxU"
'player bag':
type: inventory
size: 18# It's empty!
'selling bag':
type: inventory
size: 18
'shopping bag':
type: item
material: boat
display name: shopping bag
lore:
- Give this to a shopkeeper to check out.
- Right click to see the contents.
'item_bag':
type: item
material: boat
display name: item bag
lore:
- <red>this bag contains the items you bought
'selling bag':
type: item
material: boat
display name: selling bag
lore:
- <green>Right click the shopkeeper with this bag to sell the items in it.
- <green>Left click the shopkeeper with this bag to see what the
- <green>total price of your items will be.
storelocationstick4:
type: item
material: [email protected]_hoe
display name: store_selector_tool
storeselectorremover2:
type: task
debug: false
script:
- take [email protected]
bagremovertaskPlayer Owned:
type: task
debug: false
script:
- take '[email protected] bag'
bagremovertask1Player Owned:
type: task
debug: false
script:
- take '[email protected] bag'
playerstorekeeperegg:
type: item
material: [email protected]_egg
display name: shop_keeper
storelocationstick3:
type: task
debug: false
script:
- give <player> "[email protected]"
storelocationstick2:
type: task
script:
- showfake [email protected]_wool %1% to:<player> d:30s