+StorekeeperPlayerOwned:
+ type: assignment
+ debug: false
+
+ default constants:
+ transaction_data: true
+ transaction_log: true
+ server_price_requirment: true
+ open_limit: false
+ online_only: true
+ store greetings: li@Welcome 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 store:<-:<npc.flag[store]>
+ on assignment:
+ - trigger name:proximity toggle:true radius:30 cooldown:3s
+ - trigger name:click toggle:true
+ - trigger name:chat toggle:true
+ - trigger name:damage toggle:true
+ - flag npc cashregister:5
+ on enter proximity:
+ - if <npc.has_flag[storeitems]||false>:
+ - foreach <npc.flag[store].as_cuboid.list_entities[item_frame]||li@>:
+ - if !<def[value].has_framed_item>:
+ - adjust %value% framed:<npc.flag[storeitems].get[<npc.flag[storeitemlocations].find[<def[value].location>]>]>
+
+
+
+ on exit proximity:
+ - define name <player.name>
+ - if <npc.has_flag[closed]> && <npc.has_flag[customer]||true> == false:
+ - if !'<server.flag[storeclosed].as_list.escaped>' contains '<npc.flag[store].as_cuboid.escaped||false>':
+ - flag server storeclosed:->:<npc.flag[store].as_cuboid>
+ - announce "store closed"
+ - foreach <npc.flag[store].as_cuboid.get_blocks.filter[material.name.contains[door]]||li@>:
+ - switch %value% state:off
+
+ - despawn
+
+ on move proximity:
+ - if <npc.has_flag[store]> && <player.location.is_within[<npc.flag[store].as_cuboid>]||false>:
+ - flag player storekeepernpc:<npc>
+ - if !<npc.flag[customer]||true> contains <player.name> && <player> != <npc.owner>:
+ - flag npc customer:->:<player.name>
+
+
+ - if <npc.has_flag[store]> && !<player.location.is_within[<npc.flag[store].as_cuboid>]> && '<player.inventory.contains[i@shopping_bag]>':
+ - inventory add o:in@def[name]_shopping_bag d:<def[keeper].inventory||null>
+ - take "i@shopping_bag"
+ - narrate "<dark_red>No stealing items from my store!!"
+ - else if <npc.flag[customer]||false> contains <player.name> && !<player.location.is_within[<npc.flag[store].as_cuboid>]||false>:
+ - flag npc customer:<-:<player.name>
+
+ - if <player> == <npc.owner> && <npc.can_see[<player>]||null> && !<player.flag[greeted]||false>:
+ - 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]||false> && <npc.can_see[<player>]||null>:
+ - if !<npc.flag[greeting]||null> == null:
+ - narrate "<aqua><npc.flag[greeting].random>"
+
+ - else:
+ - narrate "<aqua><el@val[<npc.constant[store greetings]>].as_list.random>"
+
+ - flag player greeted duration:30s
+
+ on damage:
+ - define name <player.name>
+ - if <player.uuid> == <npc.owner.uuid||npc.owner>:
+ - narrate "<dark_purple> The balance is <green><npc.flag[cashregister].as_int||null>"
+ - 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[i@shopping_bag]>' && '!<player.inventory.contains[i@selling_bag]||>':
+ - note 'in@player bag' as:<player.name>_shopping_bag
+ - animate <npc> arm_swing
+ - flag player storekeepernpc:<npc>
+ - narrate '<aqua>Here, have a complimentary shopping_bag!'
+ - give 'i@shopping_bag'
+ - else if <player.item_in_hand.simple> == 'i@shopping_bag' && <npc.owner> == server:
+ - define total_price 0
+ - foreach <in@%name%_shopping_bag.list_contents>:
+ - adjust %value% quantity:1 save:item2
+ - if <server.flag[<entry[item2].result.escaped>]||null> == null:
+ - flag server <entry[item2].result.escaped>:1.00
+
+ - adjust %value% quantity:1 save:item
+ - define price <yaml[prices].read[prices.<entry[item].result.escaped>].mul[2].mul[<server.flag[<entry[item].result.escaped>]>].mul[<def[value].qty>]||null>
+ - define total_price <el@val[%total_price%].add[%price%]||null>
+
+ - 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.simple> == 'i@shopping_bag':
+ - define total_price 0
+ - define name <player.name>
+ - foreach <in@%name%_shopping_bag.list_contents>:
+ - if !<npc.flag[sell_<def[value].escaped>].mul[<%value%.qty>]||null> == null:
+ - define price <npc.flag[sell_<def[value].escaped>].mul[<def[value].qty>]||null>
+
+ - else:
+ - define price <el@val[<npc.flag[sell_<def[value].escaped>]>].mul[<def[value].qty>]||null>
+ - define total_price <el@val[%total_price%].add[%price%]||null>
+
+
+ - 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.simple> == 'i@selling_bag' && <npc.owner> == server:
+ - define total_price 0
+ - foreach <in@%name%_selling_bag.list_contents.exclude[i@air]>:
+ - adjust %value% quantity:1 save:item
+ - define price <yaml[prices].read[prices.<entry[item].result.escaped>].mul[<def[value].qty>]>
+ - define total_price <el@val[%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.simple> == 'i@selling_bag':
+ - define total_price 0
+ - foreach <in@%name%_selling_bag.list_contents.exclude[i@air]>:
+ - define newvalue <def[value].escaped>
+ - define price <npc.flag[buy_%newvalue%]||null>
+ - define total_price <el@val[%total_price%].add[%price%]||null>
+
+ - 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:n@<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 d:15s
+ - narrate "<dark_purple>Your current greetings are<&co>"
+ - foreach <npc.flag[greeting].as_list||li@>:
+ - narrate "%loop_index%=%value%"
+
+ - determine cancelled
+
+ - if <player.has_flag[greeting]> == true && <player> == <npc.owner>:
+ - if <context.message> == add:
+ - if <npc.flag[greeting].as_list.size||0> > 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||li@>:
+ - narrate "%loop_index%=%value%"
+
+ - determine cancelled
+
+
+ - if <player.has_flag[removegreeting]||false> == 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.has_flag[addgreeting]||false> == 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"
+ - flag server store:<-:<npc.flag[store]>
+ - give "storelocationstick"
+ - 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, open, close."
+ - 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]||false> == false:
+ - narrate "<aqua>No items have been sold to your shop"
+
+ - else:
+ - give <npc.flag[buyback]>
+ - flag npc buyback:!
+ - determine cancelled
+
+
+ - if <player.has_flag[givingtocashregister]||null> == 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||null>"
+ - 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.has_flag[takingfromcashregister]||null> == 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||null>"
+ - flag player takingfromcashregister:!
+ - determine cancelled
+
+ - else if <npc.flag[cashregister]||false> < <context.message>:
+ - narrate "<dark_red>You havnt got that much money in your cashregister!"
+
+
+ - if <context.message> == unset && <player> == <npc.owner>:
+ - flag global store:<-:<npc.flag[store]>
+ - 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 'in@selling bag' as:<player.name>_selling_bag
+ - animate <npc> arm_swing
+ - narrate '<aqua>Here is your item selling bag!'
+
+ - else:
+ - note 'in@player 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>:
+ - if <npc.flag[buy_<def[value].escaped>]||null> != null:
+ - if <def[value].display||null> == null:
+ - narrate "<aqua>We buy <green><def[value].material.name||null> <aqua>for <green><npc.flag[buy_<def[value].escaped||null>]||null> coins a piece"
+
+ - else:
+ - narrate "<aqua>We buy <green><def[value].display||null> <aqua>for <green><npc.flag[buy_<%value%.escaped||null>]||null> coins a piece"
+
+
+
+
+ - give i@selling_bag
+ - determine cancelled
+
+ - if <context.message> == set && <player> == <npc.owner> && <server.flag[store].as_list.escaped> !contains <npc.flag[store].escaped>:
+ - determine passively cancelled
+ - narrate "<&b>your store is now open for business!"
+ - flag npc stock:!
+ - flag server store:->:<npc.flag[store]||null>
+ - flag npc storeitems:!
+ - foreach <npc.flag[store].as_cuboid.list_entities||<player>>:
+ - if <def[value].entity_type> == item_frame:
+ - flag npc storeitems:->:<def[value].framed_item||null>
+ - flag npc storeitemlocations:->:<def[value].location||null>
+
+
+ - wait 1t
+ - foreach <npc.flag[store].as_cuboid.get_blocks[m@chest,5|m@chest,4|m@chest,3|m@chest,2|m@trapped_chest,5|m@trapped_chest,4|m@trapped_chest,3|m@trapped_chest,2]||li@>:
+ - flag npc stock:->:<def[value].inventory||null>
+
+
+ - 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]||null>]||null> <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]||false> == true:
+ - narrate "<dark_purple>please set a price above <green><yaml[prices].read[prices.<npc.flag[currentitem]||null>]||null> <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.has_flag[currentitem]> == true && <player> == <npc.owner>:
+ - if <player.flag[settype]||null> == buy && <npc.constant[server_price_requirment]||false> == true:
+ - if <context.message> > <yaml[prices].read[prices.<npc.flag[currentitem]||null>]||null> && <context.message.is[matches].to[integer]||false>:
+ - 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]||false>]||null> && <context.message.is[matches].to[integer]||false>:
+ - flag npc <player.flag[settype]>_<npc.flag[currentitem]>:<context.message>
+ - if <npc.flag[currentitem].unescaped.display||null> == null:
+ - narrate "<dark_purple><npc.flag[currentitem].unescaped.as_item.material.name||null> <player.flag[settype]||null> price is now set to <green><context.message>"
+
+ - else:
+ - narrate "<dark_purple><npc.flag[currentitem].unescaped.display||null> <player.flag[settype]||null> price is now set to <green><context.message>"
+
+ - flag npc currentitem:!
+ - flag player settype:!
+ - determine cancelled
+
+ - else:
+ - narrate "<dark_red>That doesnt not match a valid number! please set a proper number for a price"
+ - determine cancelled
+
+
+
+ - if <npc.has_flag[currentitem]> == true && <player> == <npc.owner>:
+ - if <player.flag[settype]||false> == sell && <npc.constant[server_price_requirment]> == true:
+ - if <context.message> < <yaml[prices].read[prices.<npc.flag[currentitem]||null>]||null> && <context.message.is[matches].to[integer]||false>:
+ - 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]||null>_<npc.flag[currentitem]||null>:<context.message>
+ - if <npc.has_flag[currentitem].unescaped.display||null> == null:
+ - narrate "<dark_purple><npc.flag[currentitem].unescaped.as_item.material.name||null> <player.flag[settype]||null> price is now set to <green><context.message>"
+
+ - else:
+ - narrate "<dark_purple><npc.flag[currentitem].unescaped.display||null> <player.flag[settype]||null> 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.has_flag[currentitem]> && <player> == <npc.owner>:
+ - if !<npc.constant[server_price_requirment]||false> == true:
+ - if <context.message.is[matches].to[integer]||false>:
+ - flag npc <player.flag[settype]||null>_<npc.flag[currentitem]||null>:<context.message>
+ - if <npc.flag[currentitem].unescaped.display||null> == null:
+ - narrate "<dark_purple><npc.flag[currentitem].unescaped.material.name||null> <player.flag[settype]||null> price is now set to <green><context.message>"
+
+ - else:
+ - narrate "<dark_purple><npc.flag[currentitem].unescaped.display||null> <player.flag[settype]||null> 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
+
+
+ - if <context.message> == open && <player> == <npc.owner>:
+ - flag player openhour
+ - narrate "<dark_purple>Please select a opening hour between <green>0 <dark_purple>and <green>23 <dark_purple>If you no longer want an opening hour then just say none."
+ - determine cancelled
+
+ - if <context.message> == close && <player> == <npc.owner> && <npc.constant[open_limit]> == false:
+ - flag player closehour
+ - narrate "<dark_purple>Please select a closing hour between <green>0 <dark_purple>and <green>23"
+ - determine cancelled
+ - else if <npc.constant[open_limit]> != false:
+ - narrate "<red> This server has an open limit and doesn not allow for a store closing change. Please make your opening hour and then the store will close automaticly when the time limit is reached."
+ - if <player.has_flag[openhour]>:
+ - flag npc open:<c.message>
+ - flag player openhour:!
+ - narrate "<green><c.message> <dark_purple>Is now your opening hour!"
+ - determine cancelled
+
+ - if <player.has_flag[closehour]>:
+ - flag npc close:<c.message>
+ - flag player closehour:!
+ - narrate "<green><c.message> <dark_purple>Is now your closing hour!"
+ - determine cancelled
+
+ on click:
+ - define name <player.name>
+ - if <player> == <npc.owner> && <player.item_in_hand> != i@air:
+ - adjust <player.item_in_hand> quantity:1 save:item8
+ - flag npc currentitem:<entry[item8].result.escaped>
+ - narrate "<dark_purple>will you be <green>'selling' <dark_purple>or <green>'buying' <dark_purple>for this item?"
+ - queue clear
+ - determine cancelled
+
+ - if <player.item_in_hand.simple> == i@shopping_bag:
+ - define bag in@<def[name]>_shopping_bag
+ - if <def[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 <in@%name%_shopping_bag.list_contents>:
+ - adjust %value% quantity:1 save:item2
+ - if <server.flag[<entry[item2].result.escaped>]||null> == null:
+ - flag server <entry[item2].result.escaped>:1.00
+
+ - adjust %value% quantity:1 save:item
+ - define price <yaml[prices].read[prices.<entry[item].result.escaped||null>].mul[2].mul[<server.flag[<entry[item].result.escaped||null>]||null>].mul[<def[value].qty||null>]>
+ - define total_price <el@val[%total_price%].add[%price%]||null>
+ - if <npc.constant[transaction_data]||false> == true:
+ - yaml id:transaction_data set transaction.<player.name>.bought.from_<npc.owner>.<def[value].scriptname||<def[value].material.name>>:+:<def[value].qty>
+ - yaml savefile:transaction_data.yml id:transaction_data
+
+ - if <npc.constant[transaction_log]||false> == true:
+ - if <server.flag[loglimiter]> == 1000:
+ - flag server logname:+:1
+ - flag server loglimiter:!
+
+ - log "<player.name> bought <def[value].qty> <def[value].scriptname||<def[value].material.name>> from_<npc.owner> for %price%" file:transaction_log<server.flag[logname]||<&sp>>
+
+
+ - if <player.money> < %total_price%:
+ - narrate "<dark_red>YOU NEED MONEYS D="
+ - queue clear
+
+ - flag player bagnumber:+:1
+ - note "in@player bag" "as:<player.name> <player.flag[bagnumber].as_int>_item_bag"
+ - take money qty:%total_price%
+ - if <npc.constant[transaction_data]||false> == true:
+ - yaml id:transaction_data set transaction.<player.name>.money.spent:+:<def[total_price].as_int>
+ - yaml savefile:transaction_data.yml id:transaction_data
+
+ - run "itemgiverPlayer Owned" delay:1s
+ - take 'i@shopping_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 <in@%name%_shopping_bag.list_contents>:
+ - adjust %value% quantity:1 save:item9
+ - flag server <entry[item9].result.escaped>adjust:+:<def[value].qty>
+ - run script:price_adjuster def:<entry[item9].result.escaped>
+
+
+ - else:
+ - define playerbag in@<player.name>_shopping_bag
+ - flag player delay duration:3s
+ - chat "ok let's total these items up for you then!"
+ - define total_price 0
+ - foreach <in@%name%_shopping_bag.list_contents>:
+ - adjust %value% quantity:1 save:item2
+ - if <server.flag[<entry[item2].result.escaped>]> == null:
+ - flag server <entry[item2].result.escaped>:1.00
+
+ - define price <el@val[<npc.flag[sell_<entry[item2].result.escaped>]>].mul[<def[value].qty>]>
+ - define total_price <el@val[%total_price%].add[%price%]>
+ - if <npc.constant[transaction_data]||false>:
+ - yaml id:transaction_data set transaction.<player.name>.bought.from_<npc.owner>.<def[value].scriptname||<def[value].material.name>>:+:<def[value].qty>
+ - yaml savefile:transaction_data.yml id:transaction_data
+
+ - if <npc.constant[transaction_log]||false> == true:
+ - if <server.flag[loglimiter]> == 1000:
+ - flag server logname:+:1
+ - flag server loglimiter:!
+
+ - log "<player.name> bought <def[value].qty> <def[value].scriptname||<def[value].material.name>> from_<npc.owner> for %price%" file:transaction_log<server.flag[logname]||<&sp>>
+
+
+ - if <player.money> < %total_price%:
+ - narrate "<dark_red>YOU NEED MONEYS D="
+ - queue clear
+
+ - if <npc.inventory.list_contents.simple> contains <def[playerbag].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 "in@player bag" "as:<player.name> <player.flag[bagnumber].as_int>_item_bag"
+ - take money qty:%total_price%
+ - flag npc cashregister:+:%total_price%
+ - if <npc.constant[transaction_data]||false> == true:
+ - yaml id:transaction_data set transaction.<player.name>.money.spent:+:<def[total_price].as_int>
+ - yaml savefile:transaction_data.yml id:transaction_data
+
+ - run "itemgiverPlayer Owned" delay:1s
+ - take 'i@shopping_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 <def[bag].list_contents>:
+ - adjust <def[value]> quantity:1 save:item9
+ - flag server <entry[item9].result.escaped>adjust:+:<def[value].qty>
+ - run script:price_adjuster def:<entry[item9].result.escaped>
+
+
+ - else if <player.item_in_hand.simple> == i@selling_bag:
+ - define bag in@<player.name>_selling_bag
+ - flag player delay duration:3s
+ - if <def[bag].qty> == 0:
+ - narrate "<dark_red>your selling bag is empty!"
+
+ - else if <def[bag].contains[i@shopping_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 <def[bag].list_contents.exclude[i@air]>:
+ - adjust %value% quantity:1 save:item
+ - define price <yaml[prices].read[prices.<entry[item].result.escaped>].mul[<def[value].qty>]||null>
+ - define total_price <el@val[%total_price%].add[%price%]||null>
+ - if <npc.constant[transaction_data]||false>:
+ - yaml id:transaction_data set transaction.<player.name>.sold.to_<npc.owner>.<def[value].scriptname||<def[value].material.name>>:+:<def[value].qty>
+ - yaml savefile:transaction_data.yml id:transaction_data
+
+ - if <npc.constant[transaction_log]||false> == true:
+ - if <server.flag[loglimiter]> == 1000:
+ - flag server logname:+:1
+ - flag server loglimiter:!
+
+ - log "<player.name> sold <def[value].qty> <def[value].scriptname||def[value].material.name> from_<npc.owner> for %price%" file:transaction_log<server.flag[logname]||<&sp>>
+
+
+ - give money qty:%total_price%
+ - if <npc.constant[transaction_data]||false> == true:
+ - yaml id:transaction_data set transaction.<player.name>.money.recieved:+:<def[total_price].as_int>
+ - yaml savefile:transaction_data.yml id:transaction_data
+
+ - take 'i@selling_bag'
+ - narrate "<aqua>The shopkeeper gives you <green>%total_price% coins"
+ - foreach <def[bag].list_contents>:
+ - adjust <def[value]> quantity:1 save:item9
+ - flag server <entry[item9].result.escaped>adjust:-:<def[value].qty>
+ - run script:price_adjuster def:<entry[item9].result.escaped>
+ - note as:<player.name>_selling_bag remove
+
+ - queue clear
+
+ - else:
+ - chat "ok let's total these items up for you then!"
+ - define total_price 0
+ - foreach <in@%name%_selling_bag.list_contents.exclude[i@air]||li@>:
+ - adjust %value% quantity:1 save:item
+ - define price <el@val[<npc.flag[buy_<def[value].escaped>]>].mul[<def[value].qty>]>
+ - define total_price <el@val[%total_price%].add[%price%]||null>
+ - if <npc.constant[transaction_data]||false>:
+ - yaml id:transaction_data set transaction.<player.name>.sold.to_<npc.owner>.<def[value].scriptname||<def[value].material.name>>:+:<def[value].qty>
+ - yaml savefile:transaction_data.yml id:transaction_data
+
+ - if <npc.constant[transaction_log]||false> == true:
+ - if <server.flag[loglimiter]> == 1000:
+ - flag server logname:+:1
+ - flag server loglimiter:!
+
+ - flag server loglimiter:+:1
+ - log "<player.name> sold <def[value].qty> <def[value].scriptname||<def[value].material.name>> from_<npc.owner> for %price%" file:transaction_log<server.flag[logname]||<&sp>>
+
+
+ - if %total_price% < <npc.flag[cashregister].as_int||null>:
+ - flag npc buyback:->:<in@%name%_selling_bag.list_contents>
+ - note 'in@player bag' as:<player.name>_selling_bag
+ - give money qty:%total_price%
+ - flag npc cashregister:-:%total_price%
+ - if <npc.constant[transaction_data]||false> == true:
+ - yaml id:transaction_data set transaction.<player.name>.money.recieved:+:<def[total_price].as_int>
+ - yaml savefile:transaction_data.yml id:transaction_data
+
+ - take 'i@selling_bag'
+ - narrate "<aqua>The shopkeeper gives you <green>%total_price% coins"
+ - foreach <def[bag].list_contents>:
+ - adjust <def[value]> quantity:1 save:item9
+ - flag server <entry[item9].result.escaped>adjust:-:<def[value].qty>
+ - run script:price_adjuster def:<entry[item9].result.escaped>
+
+ - queue clear
+
+ - else:
+ - narrate "<aqua>I am sorry I don't have the funds to buy all of that back!"
+
+
+
+ - else if <player.inventory> contains 'i@shopping_bag' || <player.inventory> contains 'i@selling_bag':
+ - queue clear
+
+ - else if <player.uuid> == <npc.owner.uuid>:
+ - narrate "<green>Hey boss!"
+ - 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: false
+ script:
+ - define name <player.name>
+ - inventory add o:in@%name%_shopping_bag 'd:in@<player.name> <player.flag[bagnumber].as_int>_item_bag'
+ - ^adjust 'i@item_bag' "lore:<player.name> <player.flag[bagnumber].as_int>" save:playersbag
+ - give <entry[playersbag].result>
+Item Frame Shop Player Owned:
+ type: world
+ debug: false
+ constants:
+ permission_for_prices: true
+ events:
+ on player right clicks with polar_bear_spawn_egg:
+ - determine cancelled
+ on server start:
+ - yaml load:prices.yml id:prices
+ - if !<server.has_file[transaction_data]||false>:
+ - yaml create id:transaction_data
+ - wait 1t
+ - yaml id:transaction_data set transaction:data
+ - yaml savefile:transaction_data.yml id:transaction_data
+
+ - else:
+ - yaml load:transaction_data.yml id:transaction_data
+
+ on time changes:
+ - foreach <server.get_npcs_flagged[store]||li@>:
+ - define shopkeeper %value%
+ - if <def[shopkeeper].location.world> == <c.world>:
+ - if !<def[shopkeeper].constant[open_limit]> == false:
+ - flag <def[shopkeeper]> openhours:+:1
+ - if <def[shopkeeper].flag[openhours]> == <def[shopkeeper].constant[open_limit]>:
+ - flag <def[shopkeeper]> openhours:!
+ - if <def[shopkeeper].flag[customer]||false> == false:
+ - if !'<server.flag[storeclosed].as_list.escaped>' contains '<def[shopkeeper].flag[store].as_cuboid.escaped>':
+ - announce "shop closed"
+ - despawn <def[shopkeeper]>
+ - foreach <def[shopkeeper].flag[store].as_cuboid.get_blocks.filter[material.name.contains[door]]||li@>:
+ - switch %value% state:off
+
+ - flag server storeclosed:->:<def[shopkeeper].flag[store].as_cuboid>
+
+
+ - else:
+ - flag <def[shopkeeper]> closed
+
+
+
+ - else if <def[shopkeeper].flag[close]||false> == <c.time> && <def[shopkeeper].flag[customer]||false> == false:
+ - despawn <def[shopkeeper]>
+ - if !'<server.flag[storeclosed].as_list.escaped>' contains '<def[shopkeeper].flag[store].as_cuboid.escaped>':
+ - announce "shop closed"
+ - foreach <def[shopkeeper].flag[store].as_cuboid.get_blocks.filter[material.name.contains[door]]||li@>:
+ - switch %value% state:off
+
+ - flag server storeclosed:->:<def[shopkeeper].flag[store].as_cuboid>
+
+
+ - else if <def[shopkeeper].flag[close]||false> == <c.time>:
+ - flag <def[shopkeeper]> closed
+
+ - if <def[shopkeeper].constant[online_only]> == true:
+ - if <def[shopkeeper].owner.as_player.is_online||false> && <def[shopkeeper].flag[open]||false> == <c.time>:
+ - spawn <def[shopkeeper]> <def[shopkeeper].location>
+ - if '<server.flag[storeclosed].as_list.escaped>' contains '<def[shopkeeper].flag[store].as_cuboid.escaped>':
+ - announce "shop opened"
+ - flag server storeclosed:<-:<def[shopkeeper].flag[store].as_cuboid>
+ - flag <def[shopkeeper]> closed:!
+
+
+
+ - else if <def[shopkeeper].flag[open]||false> == <c.time>:
+ - spawn <def[shopkeeper]> <def[shopkeeper].location>
+ - if '<server.flag[storeclosed].as_list.escaped>' contains '<def[shopkeeper].flag[store].as_cuboid.escaped>':
+ - announce "shop opened"
+ - flag server storeclosed:<-:<def[shopkeeper].flag[store].as_cuboid>
+ - flag <def[shopkeeper]> closed:!
+
+
+
+
+ on player clicks wooden_door:
+ - foreach <server.get_npcs_flagged[store]||li@>:
+ - if <def[value].owner> == <player>:
+ - if <c.location.is_within[<def[value].flag[store].as_cuboid]>]||false>:
+ - queue clear
+
+
+ - else:
+ - foreach <global.flag[storeclosed].escape_contents||li@>:
+ - if <context.location.is_within[<def[value].unescaped.as_cuboid>]||false>:
+ - narrate "<red>This shop is closed and the door is locked!!!"
+ - determine cancelled
+
+
+
+
+ on price command:
+ - if <player.is_op>:
+ - adjust <player.item_in_hand> quantity:1 save:item3
+ - if !<yaml[prices].contains[prices.<entry[item3].result.escaped>]||false>:
+ - flag player setpriceserver:<entry[item3].result.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.escaped>]||null>"
+ - narrate "<dark_purple>To adjust that items price use the /adjust_price command"
+ - determine cancelled
+
+
+ on player right clicks chest:
+ - foreach <global.flag[store].escape_contents||li@>:
+ - if <context.location.is_within[<def[value].unescaped.as_cuboid>]||false>:
+ - if <player.flag[storekeepernpc].as_npc.owner.uuid> != <player.uuid>:
+ - narrate "<red>This chest is locked"
+ - determine cancelled
+
+
+
+ on player right clicks trapped_chest:
+ - foreach <global.flag[store].escape_contents||li@>:
+ - if <context.location.is_within[<def[value].unescaped.as_cuboid>]||false>:
+ - if <player.flag[storekeepernpc].as_npc.owner> != <player.uuid>:
+ - narrate "<red>This chest is locked"
+ - determine cancelled
+
+
+
+ on adjust_price command:
+ - adjust <player.item_in_hand> quantity:1 save:item3
+ - yaml id:prices set prices.<entry[item3].result.escaped>:!
+ - flag player setpriceserver:<entry[item3].result.escaped>
+ - narrate "<dark_purple>what is the base price you want for that item?"
+ - determine fulfilled
+ on player chats:
+ - if <player.is_op> && <player.has_flag[setpriceserver]||null>:
+ - if <context.message.is[matches].to[integer]||false>:
+ - yaml id:prices set prices.<player.flag[setpriceserver]>:<context.message>
+ - yaml savefile:prices.yml id:prices
+ - narrate "<dark_purple><player.flag[setpriceserver].unescaped.display||<player.flag[setpriceserver].unescaped.scriptname||<player.flag[setpriceserver].unescaped.as_item.material.name>>> price is now set to <green><yaml[prices].read[prices.<player.flag[setpriceserver]>]||null>"
+ - 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||li@>:
+ - flag %value% storeinventory:<def[value].inventory.list_contents>
+
+ on player teleports:
+ - if '!<player.inventory.contains[i@shopping_bag]||null>':
+ - queue clear
+
+ - else if '<player.inventory.contains[i@shopping_bag]>':
+ - define name <player.name>
+ - if !<player.flag[storekeepernpc].as_npc.owner> == server:
+ - foreach <in@%name%_shopping_bag.list_contents>:
+ - define item %value%
+ - foreach <player.flag[storekeepernpc].as_npc.flag[stock].as_list||li@>:
+ - if <def[value].list_contents.simple> contains <def[item].simple> && <def[value].stacks[%item%]> < 64 && !<def[value].stacks> == <def[value].size>:
+ - give %item% qty:<def[item].qty> to:%value%
+ - foreach stop
+
+ - else if %loop_index% == <player.flag[storekeepernpc].as_npc.flag[stock].as_list.size>:
+ - foreach <player.flag[storekeepernpc].as_npc.flag[stock].as_list||li@>:
+ - if !<def[value].stacks> == <def[value].size>:
+ - give %item% qty:<def[item].qty> to:%value%
+
+
+
+
+
+
+ - narrate "<dark_red>No stealing items from my store!!"
+
+ on player quits:
+ - if '<player.inventory.contains[i@shopping_bag]>':
+ - define name <player.name>
+ - if !<player.flag[storekeepernpc].as_npc.owner> == server:
+ - foreach <in@%name%_shopping_bag.list_contents>:
+ - define item %value%
+ - foreach <player.flag[storekeepernpc].as_npc.flag[stock].as_list||li@>:
+ - if <def[value].list_contents.simple> contains <def[item].simple> && <def[value].stacks[%item%]> < 64 && !<def[value].stacks> == <def[value].size>:
+ - give %item% qty:<def[item].qty> to:%value%
+ - foreach stop
+
+ - else if %loop_index% == <player.flag[storekeepernpc].as_npc.flag[stock].as_list.size>:
+ - foreach <player.flag[storekeepernpc].as_npc.flag[stock].as_list>:
+ - if !<def[value].stacks> == <def[value].size>:
+ - give %item% qty:<def[item].qty> to:%value%
+
+
+
+
+
+
+
+ - foreach <server.get_npcs_flagged[store]||li@>:
+ - if <def[value].constant[online_only]> == true:
+ - if <def[value].owner> == <player>:
+ - if <def[value].flag[customer]||false> == false:
+ - if !'<server.flag[storeclosed].as_list.escaped>' contains '<def[value].flag[store].as_cuboid.escaped>':
+ - announce "shop closed"
+ - despawn <def[value]>
+ - flag server storeclosed:->:<def[value].flag[store].as_cuboid>
+
+
+
+ - else:
+ - flag <def[value]> closed
+
+
+
+ on store_setup command:
+ - give i@storekeeperegg
+ - determine fulfilled
+ on player clicks with storekeeperegg:
+ - if <global.flag[store].escape_contents||true>:
+ - create player storekeeper <player.location.cursor_on.add[0.5,1,0.5]> "save:mystorekeeper"
+ - wait 2t
+ - flag player storenpc:<entry[mystorekeeper].created_npc>
+ - narrate "<dark_purple>please select the bottom and top corners of your cuboid then drop the selector"
+ - take i@storekeeperegg
+ - wait 1t
+ - lookclose <entry[mystorekeeper].created_npc> state:true
+ - assignment set npc:<entry[mystorekeeper].created_npc.id> script:StorekeeperPlayerOwned
+ - give i@storelocationstick
+ - queue clear
+
+ - foreach <global.flag[store].escape_contents||li@>:
+ - if <context.location.is_within[<def[value].unescaped.as_cuboid||false>]>:
+ - narrate "you cannot place your store inside of another store"
+ - determine cancelled
+
+
+ - foreach <global.flag[store].escape_contents||li@>:
+ - if !<context.location.is_within[<def[value].unescaped.as_cuboid||false>]>:
+ - create player storekeeper <player.location.cursor_on.add[0.5,1,0.5]> "save:mystorekeeper"
+ - execute as_op "npc select"
+ - execute as_op "npc owner <player>" <player.selected_npc>
+ - narrate "<dark_purple>please select the bottom and top corners of your cuboid then drop the selector"
+ - take i@storekeeperegg
+ - flag player storenpc:<entry[mystorekeeper].created_npc>
+ - lookclose <entry[mystorekeeper].created_npc> state:true
+ - wait 1t
+ - assignment set npc:<entry[mystorekeeper].created_npc> script:StorekeeperPlayerOwned
+ - give i@storelocationstick
+ - queue clear
+
+
on item_frame breaks:
+ - foreach <global.flag[store].escape_contents||li@>:
+ - if <context.location.is_within[<def[value].unescaped.as_cuboid>]||false>:
+ - determine cancelled
+
+ on entity explodes:
+ - foreach <context.blocks>:
+ - define blocks <def[value]>
+ - foreach <global.flag[store].escape_contents||li@>:
+ - if <def[blocks].is_within[<def[value].unescaped.as_cuboid>]||false>:
+ - determine cancelled
+
+ on item_frame damaged by block_explosion:
+ - foreach <global.flag[store].escape_contents||li@>:
+ - if <context.location.is_within[<def[value].unescaped.as_cuboid>]||false>:
+ - determine cancelled
+
+
+ on player right clicks with storelocationstick:
+ - if <global.flag[store].escape_contents||null> == null:
+ - flag player location1:<context.location>
+ - narrate "<dark_purple>Cuboid location 1 selected"
+ - determine passively cancelled
+ - wait 1t
+ - showfake m@red_wool <c.location> to:<player> d:10s
+
+ - else:
+ - foreach <global.flag[store].escape_contents||li@>:
+ - if <context.location.is_within[<def[value].unescaped.as_cuboid>]||false>:
+ - narrate "<red>You cannot have your store in another store location please select a different location"
+ - determine cancelled
+
+ - else:
+ - flag player location1:<context.location>
+ - narrate "<dark_purple>Cuboid location 1 selected"
+ - determine passively cancelled
+ - wait 1t
+ - showfake m@red_wool <c.location> to:<player> d:10s
+
+
+
+ on player left clicks with storelocationstick:
+ - if <global.flag[store].escape_contents||null> == null:
+ - flag player location2:<context.location>
+ - narrate "<dark_purple>Cuboid location 2 selected"
+ - determine passively cancelled
+ - wait 1t
+ - showfake m@red_wool <c.location> to:<player> d:10s
+
+ - else:
+ - foreach <global.flag[store].escape_contents||li@>:
+ - if <context.location.is_within[<def[value].unescaped.as_cuboid>]||false>:
+ - narrate "<red>You cannot have your store in another store location please select a different location"
+ - determine cancelled
+
+ - else:
+ - flag player location2:<context.location>
+ - narrate "<dark_purple>Cuboid location 2 selected"
+ - determine passively cancelled
+ - wait 1t
+ - showfake m@red_wool <c.location> to:<player> d:10s
+
+
+
+ on player drops storelocationstick:
+ - execute as_op "npc select" "<player.name> --id <player.flag[storenpc].id>"
+ - execute as_op "npc owner <player.name> --id <player.selected_npc.id>"
+ - flag <player.flag[storenpc]> store:cu@<player.flag[location1]>|<player.flag[location2]>
+ - flag player location1:!
+ - flag player location2:!
+ - flag server storenpcs:->:<player.flag[storenpc]>
+ - narrate "<dark_purple>tell the npc <green>'SET' <dark_purple>to set the items in the frame"
+ - determine passively cancelled
+ - wait 1t
+ - take storelocationstick
+ on player right clicks item_frame:
+ - define name <player.name>
+ - foreach <global.flag[store].escape_contents||li@>:
+ - if <context.location.is_within[<def[value].unescaped.as_cuboid>]||false>:
+ - if <player.is_op> && <player.is_sneaking>:
+ - queue clear
+
+ - determine passively cancelled
+ - if <player.item_in_hand.simple||false> == 'i@shopping_bag':
+ - if <in@%name%_shopping_bag.stacks> = 18:
+ - narrate "<aqua>Your shopping bag is full!"
+ - else if <player.flag[storekeepernpc].as_npc.owner> == server && <yaml[prices].read[prices.<context.entity.framed_item.escaped>]||null> == null:
+ - foreach <server.list_online_players>:
+ - if !'<def[value].has_permission[<script.constant[permission_for_prices]>]||null>' == null:
+ - narrate "<red>Warning<&co><dark_purple><c.entity.framed_item> has no price! please set a price for this item by holding it in your hand ant typing /price" target:%value%
+
+ - else if !<server.flag[pricemessage].contains[<c.entity.framed_item>]>:
+ - flag server pricemessage:->:<c.entity.framed_item>
+
+
+ - narrate "<dark_red>This item has no price. please contact the servers administrators to let them know"
+ - determine cancelled
+
+ - else if <player.flag[storekeepernpc].as_npc.owner> == server:
+ - inventory add o:<c.entity.framed_item> d:in@<player.name>_shopping_bag
+ - if <c.entity.framed_item.display||null> != 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].as_npc.flag[sell_<context.entity.framed_item.escaped>]||null> == null:
+ - if <player.flag[storekeepernpc].as_npc.owner.as_player.is_online> == true:
+ - narrate "<red>Warning<&co><dark_purple><context.entity.framed_item.display.name||<context.entity.framed_item.scriptname||<context.entity.framed_item.material.name>>> does not have a price set for it! Please set a price in your shop for this item" targets:<player.flag[storekeepernpc].as_npc.owner.as_player>
+
+ - else:
+ - if !<player.flag[storekeepernpc].as_npc.owner.as_player.flag[storepricemessage].as_list.contains[<context.entity.framed_item>]||false>:
+ - flag <player.flag[storekeepernpc].as_npc.owner.as_player> "storepricemessage:->:<context.entity.framed_item.display||<c.entity.framed_item.scriptname||<context.entity.framed_item.material.name>>>"
+
+
+ - narrate "<dark_red>This item has no price and cannot be sold till a price is set for it."
+ - determine cancelled
+
+ - else:
+ - foreach <player.flag[storekeepernpc].as_npc.flag[stock].as_list||li@>:
+ - if <def[value].contains[<context.entity.framed_item>]>:
+ - inventory add o:<c.entity.framed_item> d:in@<player.name>_shopping_bag
+ - take <c.entity.framed_item> from:<def[value]>
+ - narrate "<aqua>You add a <green><context.entity.framed_item.display.name||<context.entity.framed_item.scriptname||<context.entity.framed_item.material.name>>> <aqua>to your shopping bag."
+ - playsound <player> sound:DIG_GRASS
+ - define true true
+ - foreach stop
+
+ - if %loop_index% == <player.flag[storekeepernpc].as_npc.flag[stock].as_list.size> && <def[true]||false> == false:
+ - if <player.flag[storekeepernpc].as_npc.owner.as_player.is_online> == true:
+ - narrate "<red>Warning<&co><dark_purple><context.entity.framed_item.display.name||<context.entity.framed_item.scriptname||<context.entity.framed_item.material.name>>> is out of stock! Please restock this item." targets:<player.flag[storekeepernpc].as_npc.owner.as_player>
+
+ - else:
+ - if !<player.flag[storekeepernpc].as_npc.owner.as_player.flag[storestockmessage].as_list||false> contains <c.entity.framed_item||false>:
+ - flag <player.flag[storekeepernpc].as_npc.owner.as_player> "storestockmessage:->:<context.entity.framed_item.display||<c.entity.framed_item.scriptname||<context.entity.framed_item.material.name>>>"
+
+
+ - narrate "<dark_red>That item is out of stock! Please check back later"
+
+
+
+ - determine cancelled
+
+
+
+ on player places block:
+ - foreach <global.flag[store].escape_contents||li@>:
+ - if <context.location.is_within[<def[value].unescaped.as_cuboid>]||false>:
+ - if <player.is_sneaking> && <player.is_op>:
+ - queue clear
+
+ - else:
+ - determine cancelled
+
+
+
+ on player breaks item_frame:
- foreach <global.flag[store].escape_contents||li@>:
- if <context.location.is_within[<def[value].unescaped.as_cuboid>]||false>:
+ - if <player.is_sneaking> && <player.is_op>:
+ - queue clear
+
+ - else:
+ - if <c.hanging.framed_item.display||null> != 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[store].escape_contents||li@>:
+ - if <context.location.is_within[<def[value].unescaped.as_cuboid>]||false>:
+ - if <player.is_sneaking> && <player.is_op>:
+ - queue clear
+
+ - else:
+ - determine cancelled
+
+ - if <player.flag[storekeeper_warned]||null> == 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 item_frame:
+ - foreach <global.flag[store].escape_contents||li@>:
+ - if <context.entity.location.is_within[<def[value].unescaped.as_cuboid>]||false>:
+ - if <player.is_sneaking> && <player.is_op>:
+ - queue clear
+
+ - else:
+ - foreach <global.flag[store].escape_contents||li@>:
+ - if <context.entity.location.is_within[<def[value].unescaped.as_cuboid>]||false>:
+ - if <server.flag[<context.entity.framed_item.escaped>]||null> == null:
+ - flag server <context.entity.framed_item.escaped>:1.00
+ - determine cancelled
+ - else if <player.flag[storekeepernpc].as_npc.owner> == server && <yaml[prices].read[prices.<context.entity.framed_item.escaped>]||null> == null:
+ - foreach <server.list_online_players>:
+ - if '<def[value].has_permission[<script.constant[permission_for_prices]>]||null>' != null:
+ - narrate "<red>Warning<&co><dark_purple><c.entity.framed_item> has no price! please set a price for this item by holding it in your hand ant typing /price" target:%value%
+
+ - else if !<server.flag[pricemessage].contains[<c.entity.framed_item>]>:
+ - flag server pricemessage:->:<c.entity.framed_item>
+
+
+ - narrate "<dark_red>This item has no price. please contact the servers administrators to let them know"
+ - determine cancelled
+
+ - else if <player.flag[storekeepernpc].as_npc.owner> == server:
+ - define price <yaml[prices].read[prices.<context.entity.framed_item.escaped>].mul[2].mul[<server.flag[<context.entity.framed_item.escaped>]>].as_int||null>
+ - narrate "<green>%price%"
+ - determine cancelled
+
+ - else if <player.flag[storekeepernpc].as_npc.flag[sell_<context.entity.framed_item.escaped>]||null> == null:
+ - if <player.flag[storekeepernpc].as_npc.owner.as_player.is_online> == true:
+ - narrate "<red>Warning<&co><dark_purple><context.entity.framed_item.display.name||<context.entity.framed_item.scriptname||<context.entity.framed_item.material.name>>> does not have a price set for it! Please set a price in your shop for this item" targets:<player.flag[storekeepernpc].as_npc.owner.as_player>
+
+ - else:
+ - if <player.flag[storekeepernpc].as_npc.owner.as_player.flag[storepricemessage].contains[<context.entity.framed_item>]||true>:
+ - flag <player.flag[storekeepernpc].as_npc.owner.as_player> "storepricemessage:->:<context.entity.framed_item.display||<c.entity.framed_item.scriptname||<context.entity.framed_item.material.name>>>"
+
+
+ - narrate "<dark_red>This item has no price and cannot be sold till a price is set for it."
+ - determine cancelled
+
+ - else:
+ - define price <player.flag[storekeepernpc].as_npc.flag[sell_<context.entity.framed_item.escaped>]||null>
+ - narrate "<green>%price%"
+ - determine cancelled
+
+
+
+
+
+
+
+ on player joins:
+ - foreach <server.get_npcs_flagged[store]||li@>:
+ - if <def[value].owner> == <player> && <def[value].constant[open_limit]> == false:
+ - spawn <def[value]> <def[value].location>
+ - if '<server.flag[storeclosed].as_list.escaped>' contains '<def[value].flag[store].as_cuboid.escaped>':
+ - announce "shop opened"
+ - flag server storeclosed:<-:<def[value].flag[store].as_cuboid>
+ - flag <def[value]> closed:!
+
+
+
+ - if !<player.flag[storepricemessage]||null> == null:
+ - wait 5s
+ - foreach <player.flag[storepricemessage].as_list||li@>:
+ - wait 3t
+ - narrate "<red>Warning<&co><dark_purple>%value% does not have a price set for it! Please set a price in your shop for this item"
+ - flag player storepricemessage:<-:%value%
+
+
+ - if !<player.flag[storestockmessage]||null> == null:
+ - wait 8s
+ - foreach <player.flag[storestockmessage].as_list>:
+ - wait 3t
+ - narrate "<red>Warning<&co><dark_purple>%value% is out of stock! Please restock this item."
+ - flag player storestockmessage:<-:%value%
+
+
+ - if '<player.has_permission[<script.constant[permission_for_prices]||false>]||false>':
+ - wait 12s
+ - foreach <server.flag[pricemessage].as_list||li@>:
+ - narrate "<red>Warning<&co><dark_purple>%value% has no price! please set a price for this item by holding it in your hand and typing /price"
+ - flag server pricemessage:<-:%value%
+
+
+ on player right clicks entity with shopping_bag:
+ - if <context.entity.is_npc||null>:
+ - flag player shopkeeper:<npc>
+
+ on player places item_frame:
+ - foreach <global.flag[store].escape_contents||li@>:
+ - if <context.location.is_within[<def[value].unescaped.as_cuboid>]||false>:
+ - if <player.is_sneaking> && <player.is_op>:
+ - queue clear
+
+ - else:
+ - determine cancelled
+
+
+
+ on player right clicks with shopping_bag:
+ - define name <player.name>
+ - define is_shopping false
+ - foreach <global.flag[store].escape_contents||li@>:
+ - if <player.location.is_within[<def[value].unescaped>]>:
+ - define is_shopping true
+ - foreach stop
+ - if <player.inventory.qty[shopping_bag]> > 1:
+ - take 'i@shopping_bag' qty:36
+ - note 'in@player bag' as:<player.name>_shopping_bag
+ - if <def[is_shopping]> == false:
+ - inventory clear d:in@<player.name>_shopping_bag
+ - take 'i@shopping_bag'
+ - narrate '<dark_red>You are not shopping right now!'
+ - else if <inventory.definition[name]_shopping_bag||null> == in@null && <def[is_shopping]>:
+ - note 'in@player bag' as:<player.name>_shopping_bag
+ - else if <def[is_shopping]>:
+ - narrate '<aqua>You take a look in your shopping bag...'
+ - inventory open d:in@<player.name>_shopping_bag
+
+ - determine cancelled
+
+ on player right clicks with selling_bag:
+ - define name <player.name>
+ - define is_shopping false
+ - define bag in@<player.name>_shopping_bag
+ - foreach <global.flag[store].escape_contents||li@>:
+ - if <player.location.is_within[<def[value].unescaped>]>:
+ - define is_shopping true
+ - foreach stop
+
+
+ - if !<def[is_shopping]>:
+ - define name <player.name>
+ - foreach <in@%name%_selling_bag.list_contents>:
+ - drop %value% <player.location>
+
+ - inventory clear d:in@<player.name>_selling_bag
+ - narrate '<dark_red>You are not in a shop right now!'
+ - take 'i@selling_bag'
+ - determine cancelled
+
+ - else if <def[bag]||null> == null && <def[is_shopping]>:
+ - note 'in@player bag' as:<player.name>_selling_bag
+ - inventory open d:in@<player.name>_selling_bag
+ - determine cancelled
+
+ - else if <def[is_shopping]>:
+ - inventory open d:in@<player.name>_selling_bag
+ - determine cancelled
+
+ - determine cancelled
+
+ on player right clicks with item_bag:
+ - foreach <global.flag[store].escape_contents||li@>:
+ - if <context.location.is_within[<def[value].unescaped.as_cuboid>]||false> && <player.location.facing[<player.flag[shopkeeper]>]>:
+ - queue clear
+ - else:
+ - define item <player.item_in_hand.lore.as_string.strip_color>
+ - foreach <in@%item%_item_bag.list_contents>:
+ - drop %value% <player.location>
+ - narrate "<dark_red>your shopping bag ripped"
+
+ - take iteminhand
+
+ - determine cancelled
+
+ on player drops shopping_bag:
+ - define name <player.name>
+ - narrate '<aqua>You ditch your shopping bag.'
+ - if !<player.flag[storekeepernpc].as_npc.owner> == server:
+ - foreach <in@%name%_shopping_bag.list_contents>:
+ - define item %value%
+ - foreach <player.flag[storekeepernpc].as_npc.flag[stock].as_list||li@>:
+ - if <def[value].list_contents.simple> contains <def[item].simple> && <def[value].stacks[%item%]> < 64 && !<def[value].stacks> == <def[value].size>:
+ - give %item% qty:<def[item].qty> to:%value%
+ - foreach stop
+
+ - else if %loop_index% == <player.flag[storekeepernpc].as_npc.flag[stock].as_list.size>:
+ - foreach <player.flag[storekeepernpc].as_npc.flag[stock].as_list||li@>:
+ - if !<def[value].stacks> == <def[value].size>:
+ - give %item% qty:<def[item].qty> to:%value%
+ - determine passively cancelled
+ - wait 1t
+ - take 'i@shopping_bag'
+
+ on player drops selling_bag:
+ - define name <player.name>
+ - foreach <in@%name%_selling_bag.list_contents>:
+ - drop %value% <player.location>
+
+ - narrate '<aqua>You ditch your selling bag.'
+ - note in@<player.name>_selling_bag remove
+ - determine passively cancelled
+ - wait 1t
+ - take 'i@selling_bag'
+ on player clicks in inventory:
+ - define name <player.name>
+ - if <c.inventory> == 'in@<player.name>_shopping_bag' && <player.item_in_hand.simple> == 'i@shopping_bag':
+ - determine passively cancelled
+ - inventory update d:<player.inventory>
+
+ - if <c.inventory> == 'in@<player.name>_shopping_bag' && <player.item_in_hand.simple> == 'i@shopping_bag':
+ - if <context.is_shift_click>:
+ - determine passively cancelled
+ - inventory update d:<player.inventory>
+
+
+ - if <c.inventory> == 'in@<player.name>_selling_bag':
+ - if "li@i@shopping_bag|i@selling_bag|i@item_bag" contains <context.item>:
+ - inventory update
- determine cancelled
+
+
+ on player picks up shopping_bag:
+ - if '<player.inventory.contains[i@shopping_bag]>':
+ - determine cancelled
+
+ - else:
+ - note 'in@player bag' as:<player.name>_shopping_bag
+ - narrate "<aqua>You pick up a brand new shopping bag. It's empty!"
+
+ on player picks up storekeeperegg:
+ - 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 storekeeperegg 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
+ debug: false
+ title: <aqua>shopping bag
+ size: 18
+
+ # It's empty!
+'selling bag':
+ type: inventory
+ debug: false
+ title: <aqua>selling bag
+ size: 18
+
+shopping_bag:
+ type: item
+ debug: false
+ material: "player_head[skull_skin=02d014dd-6d1a-4056-ba55-977918442838|eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3R
+leHR1cmUvYmY0MGM3NzE2MjY3YjFmNDY5YWU3MzBkMDEzYjE0MDAyN2Q4NDE5YzEyZDcxZjA3MTk4MTdhYzBhMWY3ZjA5ZCJ9fX0=]"
+ display name: "shopping bag"
+ lore:
+ - Give this to a shopkeeper to check out
+ - by right clicking him with it.
+ - Right click to see the contents.
+ - Left click the shopkeeper to see the price.
+
+'item_bag':
+ type: item
+ debug: false
+ material: "player_head[skull_skin=02d014dd-6d1a-4056-ba55-977918442838|eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3R
+leHR1cmUvYmY0MGM3NzE2MjY3YjFmNDY5YWU3MzBkMDEzYjE0MDAyN2Q4NDE5YzEyZDcxZjA3MTk4MTdhYzBhMWY3ZjA5ZCJ9fX0=]"
+ display name: item bag
+ lore:
+ - <red>this bag contains the items you bought
+
+selling_bag:
+ type: item
+ debug: false
+ material: "player_head[skull_skin=02d014dd-6d1a-4056-ba55-977918442838|eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3R
+leHR1cmUvYmY0MGM3NzE2MjY3YjFmNDY5YWU3MzBkMDEzYjE0MDAyN2Q4NDE5YzEyZDcxZjA3MTk4MTdhYzBhMWY3ZjA5ZCJ9fX0=]"
+ 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.
+
+storelocationstick:
+ type: item
+ debug: false
+ material: iron_hoe
+ display name: store_selector_tool
+storekeeperegg:
+ type: item
+ debug: false
+ material: polar_bear_spawn_egg
+ display name: shop_keeper
+price_adjuster:
+ type: task
+ debug: false
+ script:
+ - if <server.flag[%1%adjust]> == 100 {
+ - flag server %1%:+:0.01
+ - flag server %1%adjust:1
+ }
+ - if <server.flag[%1%adjust]> == 0 {
+ - flag server %1%:-:0.01
+ - flag server %1%adjust:1
+ }