Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- options:
- prefix: &7&lCoinflip &8//&7
- GUIName: &8Coinflips
- MinimumBet: 50
- # These options are for when the coinflip is rolled, Title Display messages and their colours can be editted here!
- RollingTitleDisplay: &a&lWINNER &8(&7Rolling&8)
- RollingPlayerNameColour: &6
- WinnerTitleDisplay: &a&lWINNER &8(&7CHOSEN&8)
- WinnerColour: &6&l
- Permission: false # true / false
- PermissionNode: Coinflips.Use
- # DO NOT REMOVE THE DOUBLE %% It is skript's way of indentifying a percentage sign instead of a variable
- Taxes: 5%%
- function a(b: text) :: text:
- if length of {_b} > 3:
- return "%a(first length of {_b} - 3 characters of {_b})%,%last 3 characters of {_b}%"
- return {_b}
- function openCF(p: player):
- open virtual chest inventory with size 4 named "{@GUIName}" to {_p}
- set {_slot} to 0
- loop 36 times:
- make a gui slot {_slot} of {_p} with black stained glass pane named "" to do nothing
- set {_slot} to {_slot} + 1
- set {_slot} to 9
- loop {KoinFlip::Active::*}:
- set {_slot} to {_slot} + 1
- if {_slot} is 17 or 26 or 35 or 44:
- set {_slot} to {_slot} + 2
- set {_num} to a("%{CfAmt.%loop-value%}%")
- 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%"
- 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"
- set {_WL::*} to {Coinflip.%{_p}%} split at "|"
- 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]"
- #
- # Simply just do not touch dis, it'll break the coinflip system
- #
- function removePlayerArray(p: text):
- loop {KoinFlip::Active::*}:
- if loop-value is "%{_p}%":
- delete {KoinFlip::Active::%loop-index%}
- loop {KoinFlip::Active::*}:
- set {_num} to loop-index
- if loop-value is "<none>":
- set {_plus1} to {_num} + 1
- set {KoinFlip::Active::%loop-index%} to {KoinFlip::Active::%{_plus1}%}
- delete {KoinFlip::Active::%{_plus1}%}
- #
- # 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.
- #
- on disconnect:
- loop {KoinFlip::Active::*}:
- if loop-value is "%player%":
- removePlayerArray("%player%")
- add {CfAmt.%player%} to player's balance
- delete {CfAmt.%player%}
- #
- # This is the rolling coinflip code. First part is to chose the winner, remove player from the list of coinflips etc
- # Second part is the rolling of coinflip after winner is chosen, where the titles sent will slow down progressively until a winner is chosen
- # [EDITABLE MESSAGE] The third part [Broadcast ""] is the message sent to everyone on the server when a coinflip has its winner
- # Last part is to update Wins/Losses
- #
- function cfRoll(p1: player, p2: offline player, amt: integer):
- set {_dice} to a random number between 0.01 and 99.99
- if round({_dice}) is less than 50:
- set {_winner} to {_p1}
- if round({_dice}) is more than 50:
- set {_winner} to {_p2}
- if round({_dice}) is 50:
- set {_left} to a random integer between 1 and 2
- set {_winner} to {_p%{_left}%}
- set {_loser} to {_p2}
- if {_winner} is {_p2}:
- set {_loser} to {_p1}
- removePlayerArray("%{_p2}%")
- set {_x} to {CfAmt.%{_p2}%}
- delete {CfAmt.%{_p2}%}
- set {_1st} to {_loser}
- set {_2nd} to {_winner}
- chance of 50%:
- set {_1st} to {_winner}
- set {_2nd} to {_loser}
- set {_number} to a random integer between 10 and 20
- set {_base} to {_number} / 2
- loop {_number} times:
- set {_base} to {_base} - 0.4
- set {_time} to round(1 / {_base} * 10 * 1.1 * 1.2) / 10
- play sound "random.pop" with volume 2 at {_1st}
- play sound "gui.button.press" with volume 1 at {_1st}
- play sound "random.pop" with volume 2 at {_2nd}
- play sound "gui.button.press" with volume 1 at {_2nd}
- send title "{@RollingTitleDisplay}" with subtitle "{@RollingPlayerNameColour}%{_1st}%" to {_1st} for ("%{_time}% seconds" parsed as timespan)
- send title "{@RollingTitleDisplay}" with subtitle "{@RollingPlayerNameColour}%{_1st}%" to {_2nd} for ("%{_time}% seconds" parsed as timespan)
- wait "%{_time}% seconds" parsed as a timespan
- play sound "random.pop" with volume 2 at {_1st}
- play sound "gui.button.press" with volume 1 at {_1st}
- play sound "random.pop" with volume 2 at {_2nd}
- play sound "gui.button.press" with volume 1 at {_2nd}
- send title "{@RollingTitleDisplay}" with subtitle "{@RollingPlayerNameColour}%{_2nd}%" to {_1st} for 0.1 seconds
- send title "{@RollingTitleDisplay}" with subtitle "{@RollingPlayerNameColour}%{_2nd}%" to {_2nd} for 0.1 seconds
- wait "%{_time}% seconds" parsed as a timespan
- send title "{@WinnerTitleDisplay}" with subtitle "{@WinnerColour}%{_winner}%" to {_1st}for 3 seconds
- send title "{@WinnerTitleDisplay}" with subtitle "{@WinnerColour}%{_winner}%" to {_2nd} for 3 seconds
- play sound "mob.villager.haggle" with volume 2 at {_2nd}
- loop 4 times:
- play sound "random.levelup" with volume 2 at {_1st}
- wait 15 ticks
- set {_displaye} to a("%{_x}%")
- broadcast "{@prefix} &a%{_winner}% &7(%{Coinflip.%{_winner}%}%) has defeated &c%{_loser}% &7(%{Coinflip.%{_loser}%}%) in a &7&n$%{_displaye}%&7 /coinflip!"
- set {_tax} to "{@Taxes}"
- replace "%%" in {_tax} with ""
- set {_tax} to (100 - {_tax}) / 100
- set {_amt} to ({_x} * {_tax}) * 2
- add {_amt} to {_winner}'s balance
- set {_WL::*} to {Coinflip.%{_p1}%} split at "|"
- if {_winner} is {_p1}:
- set {_WL::1} to {_Wl::1} parsed as an integer + 1
- if {_loser} is {_p1}:
- set {_WL::2} to {_WL::2} parsed as an integer + 1
- set {Coinflip.%{_p1}%} to "%{_WL::1}%|%{_WL::2}%"
- set {_WL::*} to {Coinflip.%{_p2}%} split at "|"
- if {_winner} is {_p2}:
- set {_WL::1} to {_Wl::1} parsed as an integer + 1
- if {_loser} is {_p2}:
- set {_WL::2} to {_WL::2} parsed as an integer + 1
- set {Coinflip.%{_p2}%} to "%{_WL::1}%|%{_WL::2}%"
- # This is the coinflip command, nothing much to edit here
- command /coinflip [<string>] [<string>]:
- aliases: cf
- cooldown: 2 seconds
- cooldown message: &cYou can only use this command every 2 seconds
- trigger:
- if {@Permission} is true:
- if player does not have permission "{@PermissionNode}":
- message "{@prefix} Insufficient perms."
- stop
- if arg-1 is not set:
- openCF(player)
- if {Coinflip.%player%} is not set:
- set {Coinflip.%player%} to "0|0"
- if arg-1 is set:
- if arg-1 is "create":
- if arg-2 is set:
- if arg-2 parsed as an integer is greater than or equal to {@MinimumBet}:
- set {_amt} to arg-2 parsed as an integer
- if {KoinFlip::Active::*} contains "%player%":
- message "{@prefix} You already have an active coinflip going!"
- stop
- if {_amt} is less than or equal to player's balance:
- subtract {_amt} from player's balance
- message "{@prefix} You've created a coinflip using &d$%{_amt}% dollars"
- add "%player%" to {KoinFlip::Active::*}
- set {CfAmt.%player%} to {_amt}
- openCF(player)
- else:
- message "{@prefix} Insufficient cash"
- else:
- set {_displaynum} to a({@MinimumBet})
- message "{@prefix} You cannot create coinflips lower than $%{_displaynum}%!"
- if arg-1 is "update":
- openCF(player)
- if arg-1 is "join":
- if arg-2 is player:
- message "{@prefix} You cannot join your own coinflips!"
- stop
- if {KoinFlip::Active::*} does not contain arg-2:
- message "{@prefix} Coinflip is no longer valid."
- stop
- if player's balance is greater than or equal to {CfAmt.%arg-2%}:
- if arg-2 parsed as a player is online:
- subtract {CfAmt.%arg-2%} from player's balance
- message "{@prefix} &a$%{CfAmt.%arg-2%}%&7 has been removed from your account"
- cfRoll(player, arg-2 parsed as a offline player, {CfAmt.%arg-2%})
- else:
- message "&cError, this should not have happened. Please contact the administrators for assitance"
- if arg-1 is "leave":
- loop {KoinFlip::Active::*}:
- if loop-value is "%player%":
- removePlayerArray("%player%")
- add {CfAmt.%player%} to player's balance
- delete {CfAmt.%player%}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement