Advertisement
therasmusgamer

Untitled

Jul 30th, 2019
467
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.58 KB | None | 0 0
  1. options:
  2. prefix: &7&lCoinflip &8//&7
  3. GUIName: &8Coinflips
  4.  
  5. MinimumBet: 50
  6.  
  7. # These options are for when the coinflip is rolled, Title Display messages and their colours can be editted here!
  8.  
  9. RollingTitleDisplay: &a&lWINNER &8(&7Rolling&8)
  10. RollingPlayerNameColour: &6
  11. WinnerTitleDisplay: &a&lWINNER &8(&7CHOSEN&8)
  12. WinnerColour: &6&l
  13.  
  14.  
  15. Permission: false # true / false
  16. PermissionNode: Coinflips.Use
  17.  
  18. # DO NOT REMOVE THE DOUBLE %% It is skript's way of indentifying a percentage sign instead of a variable
  19. Taxes: 5%%
  20.  
  21. function a(b: text) :: text:
  22. if length of {_b} > 3:
  23. return "%a(first length of {_b} - 3 characters of {_b})%,%last 3 characters of {_b}%"
  24. return {_b}
  25.  
  26. function openCF(p: player):
  27. open virtual chest inventory with size 4 named "{@GUIName}" to {_p}
  28. set {_slot} to 0
  29. loop 36 times:
  30. make a gui slot {_slot} of {_p} with black stained glass pane named "" to do nothing
  31. set {_slot} to {_slot} + 1
  32. set {_slot} to 9
  33. loop {KoinFlip::Active::*}:
  34. set {_slot} to {_slot} + 1
  35. if {_slot} is 17 or 26 or 35 or 44:
  36. set {_slot} to {_slot} + 2
  37. set {_num} to a("%{CfAmt.%loop-value%}%")
  38. make a gui slot {_slot} of {_p} with skull of (loop-value parsed as an offline player) named "&7%loop-value%" with lore "" and "&7&l> &a&lAmount" and "&7 &7 $%{_num}% Bet" and "" and "&7&l> &a&lWin-Loss Rate" and "&7 &7 W-%{Coinflip.%loop-value%}%-L" and "" and "&7&oLeft-Click to join Coin Flip" to run {_p} command "/coinflip join %loop-value%"
  39.  
  40. make a gui slot 35 of {_p} with emerald block named "&a&lRefresh" with lore "&7Click to refresh available coinflips" to run {_p} command "/coinflip update"
  41. set {_WL::*} to {Coinflip.%{_p}%} split at "|"
  42. make a gui slot 27 of {_p} with orange dye named "&6&lHelp" with lore "&e/coinflip <> /cf" and "&7> &7&oOpens the coinflip GUI" and "&e/cf create <amt>" and "&7> &7&oCreates a coinflip using in game money" and "&e/cf join <player>" and "&7> &7&oJoin a player's coinflip" and "&e/cf leave" and "&7> &7&oRemove your coinflip for free" and "" and "&7&lStatistic" and "&a&lWINS &8[&7%{_WL::1}%&8]" and "&c&lLOSES &8[&7%{_WL::2}%&8]"
  43.  
  44.  
  45.  
  46. #
  47. # Simply just do not touch dis, it'll break the coinflip system
  48. #
  49. function removePlayerArray(p: text):
  50. loop {KoinFlip::Active::*}:
  51. if loop-value is "%{_p}%":
  52. delete {KoinFlip::Active::%loop-index%}
  53. loop {KoinFlip::Active::*}:
  54. set {_num} to loop-index
  55. if loop-value is "<none>":
  56. set {_plus1} to {_num} + 1
  57. set {KoinFlip::Active::%loop-index%} to {KoinFlip::Active::%{_plus1}%}
  58. delete {KoinFlip::Active::%{_plus1}%}
  59.  
  60.  
  61. #
  62. # Due to the fact skript cannot manipulate much things where the coinflip creator is offline, on leave, it'll essentially run /cf leave on the player.
  63. #
  64. on disconnect:
  65. loop {KoinFlip::Active::*}:
  66. if loop-value is "%player%":
  67. removePlayerArray("%player%")
  68. add {CfAmt.%player%} to player's balance
  69. delete {CfAmt.%player%}
  70.  
  71.  
  72.  
  73. #
  74. # This is the rolling coinflip code. First part is to chose the winner, remove player from the list of coinflips etc
  75. # Second part is the rolling of coinflip after winner is chosen, where the titles sent will slow down progressively until a winner is chosen
  76. # [EDITABLE MESSAGE] The third part [Broadcast ""] is the message sent to everyone on the server when a coinflip has its winner
  77. # Last part is to update Wins/Losses
  78. #
  79. function cfRoll(p1: player, p2: offline player, amt: integer):
  80. set {_dice} to a random number between 0.01 and 99.99
  81. if round({_dice}) is less than 50:
  82. set {_winner} to {_p1}
  83. if round({_dice}) is more than 50:
  84. set {_winner} to {_p2}
  85. if round({_dice}) is 50:
  86. set {_left} to a random integer between 1 and 2
  87. set {_winner} to {_p%{_left}%}
  88. set {_loser} to {_p2}
  89. if {_winner} is {_p2}:
  90. set {_loser} to {_p1}
  91. removePlayerArray("%{_p2}%")
  92. set {_x} to {CfAmt.%{_p2}%}
  93. delete {CfAmt.%{_p2}%}
  94.  
  95. set {_1st} to {_loser}
  96. set {_2nd} to {_winner}
  97. chance of 50%:
  98. set {_1st} to {_winner}
  99. set {_2nd} to {_loser}
  100. set {_number} to a random integer between 10 and 20
  101. set {_base} to {_number} / 2
  102. loop {_number} times:
  103. set {_base} to {_base} - 0.4
  104. set {_time} to round(1 / {_base} * 10 * 1.1 * 1.2) / 10
  105. play sound "random.pop" with volume 2 at {_1st}
  106. play sound "gui.button.press" with volume 1 at {_1st}
  107. play sound "random.pop" with volume 2 at {_2nd}
  108. play sound "gui.button.press" with volume 1 at {_2nd}
  109. send title "{@RollingTitleDisplay}" with subtitle "{@RollingPlayerNameColour}%{_1st}%" to {_1st} for ("%{_time}% seconds" parsed as timespan)
  110. send title "{@RollingTitleDisplay}" with subtitle "{@RollingPlayerNameColour}%{_1st}%" to {_2nd} for ("%{_time}% seconds" parsed as timespan)
  111. wait "%{_time}% seconds" parsed as a timespan
  112. play sound "random.pop" with volume 2 at {_1st}
  113. play sound "gui.button.press" with volume 1 at {_1st}
  114. play sound "random.pop" with volume 2 at {_2nd}
  115. play sound "gui.button.press" with volume 1 at {_2nd}
  116. send title "{@RollingTitleDisplay}" with subtitle "{@RollingPlayerNameColour}%{_2nd}%" to {_1st} for 0.1 seconds
  117. send title "{@RollingTitleDisplay}" with subtitle "{@RollingPlayerNameColour}%{_2nd}%" to {_2nd} for 0.1 seconds
  118. wait "%{_time}% seconds" parsed as a timespan
  119. send title "{@WinnerTitleDisplay}" with subtitle "{@WinnerColour}%{_winner}%" to {_1st}for 3 seconds
  120. send title "{@WinnerTitleDisplay}" with subtitle "{@WinnerColour}%{_winner}%" to {_2nd} for 3 seconds
  121. play sound "mob.villager.haggle" with volume 2 at {_2nd}
  122. loop 4 times:
  123. play sound "random.levelup" with volume 2 at {_1st}
  124. wait 15 ticks
  125.  
  126. set {_displaye} to a("%{_x}%")
  127. broadcast "{@prefix} &a%{_winner}% &7(%{Coinflip.%{_winner}%}%) has defeated &c%{_loser}% &7(%{Coinflip.%{_loser}%}%) in a &7&n$%{_displaye}%&7 /coinflip!"
  128. set {_tax} to "{@Taxes}"
  129. replace "%%" in {_tax} with ""
  130. set {_tax} to (100 - {_tax}) / 100
  131. set {_amt} to ({_x} * {_tax}) * 2
  132. add {_amt} to {_winner}'s balance
  133. set {_WL::*} to {Coinflip.%{_p1}%} split at "|"
  134. if {_winner} is {_p1}:
  135. set {_WL::1} to {_Wl::1} parsed as an integer + 1
  136. if {_loser} is {_p1}:
  137. set {_WL::2} to {_WL::2} parsed as an integer + 1
  138. set {Coinflip.%{_p1}%} to "%{_WL::1}%|%{_WL::2}%"
  139. set {_WL::*} to {Coinflip.%{_p2}%} split at "|"
  140. if {_winner} is {_p2}:
  141. set {_WL::1} to {_Wl::1} parsed as an integer + 1
  142. if {_loser} is {_p2}:
  143. set {_WL::2} to {_WL::2} parsed as an integer + 1
  144. set {Coinflip.%{_p2}%} to "%{_WL::1}%|%{_WL::2}%"
  145.  
  146.  
  147.  
  148.  
  149. # This is the coinflip command, nothing much to edit here
  150.  
  151. command /coinflip [<string>] [<string>]:
  152. aliases: cf
  153. cooldown: 2 seconds
  154. cooldown message: &cYou can only use this command every 2 seconds
  155. trigger:
  156. if {@Permission} is true:
  157. if player does not have permission "{@PermissionNode}":
  158. message "{@prefix} Insufficient perms."
  159. stop
  160. if arg-1 is not set:
  161. openCF(player)
  162. if {Coinflip.%player%} is not set:
  163. set {Coinflip.%player%} to "0|0"
  164. if arg-1 is set:
  165. if arg-1 is "create":
  166. if arg-2 is set:
  167. if arg-2 parsed as an integer is greater than or equal to {@MinimumBet}:
  168. set {_amt} to arg-2 parsed as an integer
  169. if {KoinFlip::Active::*} contains "%player%":
  170. message "{@prefix} You already have an active coinflip going!"
  171. stop
  172. if {_amt} is less than or equal to player's balance:
  173. subtract {_amt} from player's balance
  174. message "{@prefix} You've created a coinflip using &d$%{_amt}% dollars"
  175. add "%player%" to {KoinFlip::Active::*}
  176. set {CfAmt.%player%} to {_amt}
  177.  
  178. openCF(player)
  179. else:
  180. message "{@prefix} Insufficient cash"
  181. else:
  182. set {_displaynum} to a({@MinimumBet})
  183. message "{@prefix} You cannot create coinflips lower than $%{_displaynum}%!"
  184.  
  185. if arg-1 is "update":
  186. openCF(player)
  187.  
  188. if arg-1 is "join":
  189. if arg-2 is player:
  190. message "{@prefix} You cannot join your own coinflips!"
  191. stop
  192. if {KoinFlip::Active::*} does not contain arg-2:
  193. message "{@prefix} Coinflip is no longer valid."
  194. stop
  195. if player's balance is greater than or equal to {CfAmt.%arg-2%}:
  196. if arg-2 parsed as a player is online:
  197. subtract {CfAmt.%arg-2%} from player's balance
  198. message "{@prefix} &a$%{CfAmt.%arg-2%}%&7 has been removed from your account"
  199. cfRoll(player, arg-2 parsed as a offline player, {CfAmt.%arg-2%})
  200. else:
  201. message "&cError, this should not have happened. Please contact the administrators for assitance"
  202.  
  203. if arg-1 is "leave":
  204. loop {KoinFlip::Active::*}:
  205. if loop-value is "%player%":
  206. removePlayerArray("%player%")
  207. add {CfAmt.%player%} to player's balance
  208. delete {CfAmt.%player%}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement