nfell2009

ShopSearch - V1.0 by HoneyBuzzard and nfell2009!

Apr 16th, 2014
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 8.41 KB | None | 0 0
  1. options:
  2.     P: &8[&aSS&8]&a
  3.     MyC: &6[&eMyC&6]&e
  4.     uMyC: [MyC]
  5.    
  6. on join:
  7.     if {ss.%player%.exists} is not set:
  8.         set {ss.%player%.exists} to true
  9.         set {ss.%player%.buying} to false
  10.    
  11. command /searchshop <text> [<integer>] [<item>]:
  12.     description: Main SearchShop command
  13.     permission: searchshop.usage
  14.     aliases: /ss, /searchs, /sshop,
  15.     trigger:
  16.         if arg 1 is not set:
  17.             message "{@P} You must give a subcommand!"
  18.         else if arg 1 is "add":
  19.             message "{@P} Right click to add a chest!"
  20.             set {ss.%player%.add} to true
  21.         else if arg 1 is "remove":
  22.             message "{@P} Right click to remove a chest!"
  23.             set {ss.%player%.remove} to true
  24.         else if arg 1 is "buy":
  25.             if {ss.%player%.buying} is false:
  26.                 message "{@P} You haven't selected anything to buy!"
  27.             else if {ss.%player%.buying} is true:
  28.                 message "{@P} Your selected purchase is as follows:"
  29.                 message "{@P} Item: %{ss.%player%.buying.item}%"
  30.                 message "{@P} Amount: %{ss.%player%.buying.amount}%"
  31.                 if {myc.enabled} is true:
  32.                     if {_price} is greater than 1:
  33.                         message "{@P} Price: %{ss.%player%.buying.price}%%{myc.currency.plural}%"
  34.                     else:
  35.                         message "{@P} Price: %{ss.%player%.buying.price}%%{myc.currency}%"
  36.                 else:
  37.                     message "{@P} Price: %{ss.%player%.buying.price}%"
  38.                 message "{@P} From Player: %{ss.%player%.buying.playerto}%"
  39.             else:
  40.                 message "{@P} Something went wrong..."
  41.         else if arg 1 is "confirm":
  42.             if {ss.%player%.buying} is true:
  43.                 if block at {ss.%player%.buying.chestloc} contains {ss.%player%.buying.amount} of {ss.%player%.buying.item}:
  44.                     if {myc.enabled} is true:
  45.                         if {myc.%player%.money} is greater than or equal to {ss.%player%.buying.price}:
  46.                             remove {ss.%player%.buying.amount} of {ss.%player%.buying.item} from block at {ss.%player%.buying.chestloc}
  47.                             give {ss.%player%.buying.amount} of {ss.%player%.buying.item} to player
  48.                             subtract {ss.%player%.buying.price} from {myc.%player%.money}
  49.                             set {myc.%player%.lastpayto} to {ss.%player%.buying.playerto}
  50.                             set {myc.%player%.lastpayout} to {ss.%player%.buying.price}
  51.                             add {ss.%player%.buying.price} to {myc.%{ss.%player%.buying.playerto}%.money}
  52.                             set {myc.%{ss.%player%.buying.playerto}%.lastpayin} to {ss.%player%.buying.price}
  53.                             set {myc.%{ss.%player%.buying.playerto}%.lastpayfrom} to player
  54.                             if {_price} is greater than 1:
  55.                                 message "{@P} You just bought %{ss.%player%.buying.amount}% %{ss.%player%.buying.item}% from %{ss.%player%.buying.playerto}% for %{ss.%player%.buying.price}%%{myc.currency.plural}%"
  56.                                 log "{@uMyC} %player% bought %{ss.%player%.buying.amount}% %{ss.%player%.buying.item}% from %{ss.%player%.buying.playerto}% for %{ss.%player%.buying.price}%%{myc.currency.plural}%" to "myc/%player%"
  57.                                 log "{@uMyC} %player% bought bought %{ss.%player%.buying.amount}% %{ss.%player%.buying.item}% from %{ss.%player%.buying.playerto}% for %{ss.%player%.buying.price}%%{myc.currency.plural}%" to "myc/%{ss.%player%.buying.playerto}%"
  58.                             else:
  59.                                 message "{@P} You just bought %{ss.%player%.buying.amount}% %{ss.%player%.buying.item}% from %{ss.%player%.buying.playerto}% for %{ss.%player%.buying.price}%%{myc.currency}%"
  60.                                 log "{@uMyC} %player% bought %{ss.%player%.buying.amount}% %{ss.%player%.buying.item}% from %{ss.%player%.buying.playerto}% for %{ss.%player%.buying.price}%%{myc.currency}%" to "myc/%player%"
  61.                                 log "{@uMyC} %player% bought %{ss.%player%.buying.amount}% %{ss.%player%.buying.item}% from %{ss.%player%.buying.playerto}% for %{ss.%player%.buying.price}%%{myc.currency}%" to "myc/%{ss.%player%.buying.playerto}%"
  62.                             set {ss.%player%.buying} to false
  63.                             delete {ss.%player%.buying.chestloc}
  64.                             delete {ss.%player%.buying.itemname}
  65.                             delete {ss.%player%.buying.amount}
  66.                             delete {ss.%player%.buying.price}
  67.                             delete {ss.%player%.buying.playerto}
  68.                         else:
  69.                             message "{@MyC} Your funds don't support that purchase!"
  70.                     else:
  71.                         if player's balance is greater than or equal to {_price}:
  72.                             remove arg-2 of arg-3 from block at loop-value
  73.                             give arg-2 of arg-3 to player
  74.                             subtract {_price} from player's balance
  75.                             add {_price} to {_playerto}'s balance
  76.                             message "{@P} You just bought %arg-2% %arg-3% from %{_playerto}% for %{_price}%"
  77.                 else:
  78.                     message "{@P} There was an error trying to see if the chest contains the items! Try again or contact the shop owner."
  79.             else:
  80.                 message "{@P} There is nothing for you too buy!"
  81.         else if {ss.%arg 1%.exists} is true:
  82.             if arg 2 is not set:
  83.                 message "{@P} You must enter an item amount you want!"
  84.                 stop trigger
  85.             else if arg 3 is not set:
  86.                 message "{@P} You must enter the item you want!"
  87.                 stop trigger
  88.             else if arg 2 is not number:
  89.                 message "{@P} You must enter the amount as a number!"
  90.             else:
  91.                 set {_counter} to 0
  92.                 loop {ss.%arg 1%.chests::*}:
  93.                     add 1 to {_counter}
  94.                     if block at loop-value is chest:
  95.                         if block at loop-value contains arg-2 of arg-3:
  96.                             set {_x} to x coordinate of loop-value
  97.                             set {_y} to y coordinate of loop-value
  98.                             set {_z} to z coordinate of loop-value
  99.                             add 1 to {_y}
  100.                             set {_cloc} to location at {_x}, {_y}, {_z}
  101.                             if block at {_cloc} is sign:
  102.                                 if line 1 of block at {_cloc} is set:
  103.                                     if line 2 of block at {_cloc} is set:
  104.                                         if line 3 of block at {_cloc} is set:
  105.                                             if line 4 of block at {_cloc} is set:
  106.                                                 set {_wamount} to arg-2
  107.                                                 set {_witem} to arg-3
  108.                                                 set {_playerto} to line 1 of block at {_cloc} parsed as player
  109.                                                 set {_amount} to line 2 of block at {_cloc} parsed as number
  110.                                                 set {_price} to line 3 of block at {_cloc} parsed as number
  111.                                                 set {_itemname} to line 4 of block at {_cloc} parsed as text
  112.                                                 if {_wamount} is equal to {_amount}:
  113.                                                     if "%{_witem}%" is equal to "%{_itemname}%":
  114.                                                         set {ss.%player%.buying.amount} to line 2 of block at {_cloc} parsed as number
  115.                                                         set {ss.%player%.buying} to true
  116.                                                         subtract 1 from {_y}
  117.                                                         set {ss.%player%.buying.chestloc} to location at {_x}, {_y}, {_z}
  118.                                                         set {ss.%player%.buying.item} to {_itemname} parsed as item
  119.                                                         set {ss.%player%.buying.price} to {_price}
  120.                                                         set {ss.%player%.buying.playerto} to {_playerto}
  121.                                                         message "{@P} You have now selected the following for purchase:"
  122.                                                         message "{@P} Item: %{ss.%player%.buying.item}%"
  123.                                                         message "{@P} Amount: %{ss.%player%.buying.amount}%"
  124.                                                         if {myc.enabled} is true:
  125.                                                             if {_price} is greater than 1:
  126.                                                                 message "{@P} Price: %{ss.%player%.buying.price}%%{myc.currency.plural}%"
  127.                                                             else:
  128.                                                                 message "{@P} Price: %{ss.%player%.buying.price}%%{myc.currency}%"
  129.                                                         else:
  130.                                                             message "{@P} Price: %{ss.%player%.buying.price}%"
  131.                                                         message "{@P} From Player: %{ss.%player%.buying.playerto}%"
  132.                                                         message "{@P} Do: /ss confirm - to buy this. You can review this purchase at any time by doing: /ss buy"
  133.                                                         stop loop
  134.         else:
  135.             message "{@P} Unknown command!"
  136. on rightclick on chest:
  137.     if {ss.%player%.add} is true:
  138.         loop blocks 1 above block:
  139.             if loop-block is sign:
  140.                 line 1 of loop-block is "%player%":
  141.                     set {_x} to x coordinate of block
  142.                     set {_y} to y coordinate of block
  143.                     set {_z} to z coordinate of block
  144.                     set {_ss.x} to floor({_x})
  145.                     set {_ss.y} to floor({_y})
  146.                     set {_ss.z} to floor({_z})
  147.                     set {_ss.cloc} to location at {_ss.x}, {_ss.y}, {_ss.z}
  148.                     add {_ss.cloc} to {ss.%player%.chests::*}
  149.                     message "{@P} Added: %{_ss.cloc}%"
  150.                     cancel event
  151.                     set {ss.%player%.add} to false
  152.                 else:
  153.                     message "{@P} It needs to be your shop!"
  154.                     cancel event
  155.     else if {ss.%player%.remove} is true:
  156.         loop blocks 1 above block:
  157.             if loop-block is sign:
  158.                 line 1 of loop-block is "%player%":
  159.                     set {_x} to x coordinate of block
  160.                     set {_y} to y coordinate of block
  161.                     set {_z} to z coordinate of block
  162.                     set {_ss.x} to floor({_x})
  163.                     set {_ss.y} to floor({_y})
  164.                     set {_ss.z} to floor({_z})
  165.                     set {_ss.cloc} to location at {_ss.x}, {_ss.y}, {_ss.z}
  166.                     remove {_ss.cloc} from {ss.%player%.chests::*}
  167.                     message "{@P} Removed: %{_ss.cloc}%"
  168.                     cancel event
  169.                     set {ss.%player%.remove} to false
  170.                 else:
  171.                     message "{@P} It needs to be your shop!"
  172.                     cancel event
Advertisement
Add Comment
Please, Sign In to add comment