Advertisement
rePeteGG

RideYourHook v1.0 - Chat

Mar 1st, 2015
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.10 KB | None | 0 0
  1. # #######################################
  2. # #### RideYourHook v1.0 by rePeteGG ####
  3. # #######################################
  4.  
  5.  
  6.  
  7. # #### Variables
  8. On Script Load:
  9. set {rideyourhook.style} to "&6&o" # This is how the item name will be displayed. Standard is orange & italic.
  10. set {rideyourhook.name} to "Rider's Fishing Rod" # How the Fishing Rod will be named. Obviously.
  11.  
  12. # #### Debug settings
  13. set {skript.logging} to true # Logs actions from this skript to a log file.
  14. set {skript.logging.msg} to true # Logs actions from this skript live to console.
  15.  
  16. function func_logging(prefix: text, message: text, file: text):
  17. if {skript.logging} is true:
  18. log "[%{_prefix}%] %{_message}%" to "%{_file}%"
  19. if {skript.logging.msg} is true:
  20. message "[%{_prefix}%] %{_message}%" to console
  21.  
  22.  
  23.  
  24. # #### Command to spawn the special Fishing Rod.
  25. command /rideyourhook:
  26. aliases: /ryh
  27. executable by: players
  28. trigger:
  29. player has permission "skript.rideyourhook":
  30. give player fishing rod named "%{rideyourhook.style}%%{rideyourhook.name}%"
  31. func_logging("%{rideyourhook.name}%", "Successfully gave %{rideyourhook.name}% to %player%.", "RideYourHook.log")
  32.  
  33.  
  34.  
  35. # #### Functionality
  36. On Shoot:
  37. shooter is holding fishing rod
  38. display name of shooter's tool is "%{rideyourhook.style}%%{rideyourhook.name}%":
  39. set {_difference} to difference between {rideyourhook.cooldown.%shooter%} and now # Checks wether the cooldown is done or not.
  40. if {_difference} < 8 seconds: # Stops the code if the cooldown is not done. Set this to any value you like. 1 minute, 20 seconds, whatever. Just be advised that the cooldown is not saved between server restarts.
  41. func_logging("%{rideyourhook.name}%", "%shooter% tried to ride his hook but his cooldown was not ready.", "RideYourHook.log")
  42. stop trigger
  43. else:
  44. set {rideyourhook.proj.%projectile%} to projectile # saves the just launched hook projectile in a variable to be called later for the ride.
  45. if {rideyourhook.riding.%shooter%} is not set: # This variable is only true if the player is already riding a hook projectile. If that is the case, code will not attempt to ride another projectile.
  46. wait 1 ticks
  47. loop entities in radius 16 around shooter:
  48. loop-entity is {rideyourhook.proj.%projectile%}:
  49. make shooter ride loop-entity
  50. damage shooter's tool by 2 # Fishing rod has a durability of 64. By damaging the tool by 2 on every successful use you can use the rod 32 times.
  51. wait 1 tick
  52. if shooter is not riding loop-entity:
  53. func_logging("%{rideyourhook.name}%", "Something went wrong. %shooter% couldn't be placed on his hook. Maybe he/she was moving too fast when firing the hook or it lagged.", "RideYourHook.log")
  54. stop trigger
  55. else:
  56. set {rideyourhook.riding.%shooter%} to true # Flags the player as "riding a hook." This is needed for the "On Damage:" Event below.
  57. set {rideyourhook.cooldown.%shooter%} to now # Resets the cooldown.
  58. set {_counter} to 8 + 1 # Whatever you set for the cooldown a few lines above, set the same amount of time in seconds here. (Don't mind the + 1, its there to make the messages look better.)
  59. func_logging("%{rideyourhook.name}%", "%shooter% was successfully put on his hook, riding flag was set, cooldown started.", "RideYourHook.log")
  60.  
  61. while {_counter} > 1: # Sends the cooldown every second to the player as a fancy "action-bar".
  62. subtract 1 from {_counter}
  63. message "%{rideyourhook.style}%Cooldown: %{_counter}%" to shooter
  64. wait 1 second
  65. if {_counter} = 1:
  66. delete {rideyourhook.cooldown.%shooter%} # Cleans up the variables file a bit.
  67. func_logging("%{rideyourhook.name}%", "The cooldown of %shooter% expired.", "RideYourHook.log")
  68.  
  69. On Fishing: # AFAIK this event is called if player right clicks with a fishing rod and "reels in" the hook. This code kills the "riding a hook" flag of the player when he right clicks while riding the hook.
  70. player is holding fishing rod
  71. display name of tool is "%{rideyourhook.style}%%{rideyourhook.name}%":
  72. if {rideyourhook.riding.%player%} is true:
  73. delete {rideyourhook.riding.%player%}
  74. func_logging("%{rideyourhook.name}%", "The riding flag of %player% was successfully deleted due to right click while riding. (Variable: rideyourhook.riding.%player%)", "RideYourHook.log")
  75.  
  76. On tool change: # Since it is possible to despawn the hook+string by changing a tool this part makes sure that if you change your tool during a ride it removes your "riding a hook" flag.
  77. if tool is fishing rod: # to prevent this code to be fired EVERY time someone changes his tool this part checks wether the player switched TO the special fishing rod before firing the code that deletes the variables.
  78. display name of tool is "%{rideyourhook.style}%%{rideyourhook.name}%"
  79. set {rideyourhook.changetool.%player%} to true
  80. func_logging("%{rideyourhook.name}%", "%player% changed tool to %{rideyourhook.name}%.", "rideyourhook.log")
  81. stop
  82. if tool is not fishing rod named "%{rideyourhook.style}%%{rideyourhook.name}%":
  83. {rideyourhook.changetool.%player%} is true
  84. delete {rideyourhook.riding.%player%}
  85. delete {rideyourhook.changetool.%player%}
  86. func_logging("%{rideyourhook.name}%", "%player% changed away from %{rideyourhook.name}%. The riding flag of %player% was successfully deleted. (Variable: rideyourhook.riding.%player%)", "RideYourHook.log")
  87.  
  88. On Damage: # Prevents a bug where when you mount your hook in survival mode, you get damage and the hook starts pushing you up in the air infintely.
  89. victim is holding fishing rod
  90. display name of victim's tool is "%{rideyourhook.style}%%{rideyourhook.name}%"
  91. {rideyourhook.riding.%victim%} is set
  92. damage cause is not contact, attack, projectile, suffocation, fire, burning, melting, lava, drowning, block explosion, entity explosion, void, lightning, suicide, starvation, poison, potion, wither, falling block, thorns or unknown: # Since the damage the hook doing is seemingly not in the damage cause list that skript supports, this is needed. It excludes all damage causes that ARE supported and prevents damage from the fishing hook. As a bonus i took out fall damage, so as long as you ride a hook, you don't take fall damage.
  93. cancel event
  94. func_logging("%{rideyourhook.name}%", "Hook damage to %victim% was successfully prevented. (This message will appear multiple times per use.)", "RideYourHook.log")
  95.  
  96. On Projectile Hit: # Dismounts the player from the hook when it hits a block. Also minimizes how often you dismount halfway into the block below you.
  97. shooter is holding fishing rod
  98. display name of shooter's tool is "%{rideyourhook.style}%%{rideyourhook.name}%"
  99. if projectile is {rideyourhook.proj.%projectile%}:
  100. set {_block} to the block at location 0.5 beneath the projectile
  101. if {_block} is not air:
  102. eject passenger from {rideyourhook.proj.%projectile%}
  103. wait 1 tick
  104. delete {rideyourhook.proj.%projectile%}
  105. delete {rideyourhook.riding.%shooter%}
  106. func_logging("%{rideyourhook.name}%", "%shooter% was dismounted due to hook hitting a block. The riding flag of %shooter% was successfully deleted. (Variable: shamanrod.riding.%shooter%)", "RideYourHook.log")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement