nfell2009

ShopSearch V1.2

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