Files
server_jackpot.sk
Code
1 884
server_jackpot.sk
# ============================================================
# Server Jackpot Ticket
# Vanilla Skript terbaru - tanpa addon GUI
#
# Instalasi:
# 1. Simpan file ini di plugins/Skript/scripts/server_jackpot.sk
# 2. Pastikan economy provider tersedia untuk Skript
# (umumnya Vault + EssentialsX Economy / CMI Economy).
# 3. Jalankan: /sk reload server_jackpot
# ============================================================
options:
player-gui: &8💎 Server Jackpot
admin-gui: &8⚙ Admin Jackpot
history-gui: &8📜 Riwayat Jackpot
admin-history-gui: &8📜 Admin Riwayat Jackpot
prefix: &8[&6Jackpot&8] &r
function jackpotMoney(value: number) :: text:
return "$%{_value}%"
function jackpotTicketTotal() :: number:
return size of {jackpot::tickets::*}
function jackpotChance(owned: number, total: number) :: number:
if {_total} is less than or equal to 0:
return 0
set {_chance} to ({_owned} / {_total}) * 100
return {_chance}
function jackpotProgressBar(owned: number, total: number) :: text:
if {_total} is less than or equal to 0:
return "&8□□□□□□□□□□"
set {_chance} to jackpotChance({_owned}, {_total})
set {_bar} to ""
loop 10 times:
if loop-number * 10 is less than or equal to {_chance}:
set {_bar} to "%{_bar}%&a■"
else:
set {_bar} to "%{_bar}%&8□"
return {_bar}
function jackpotTimeText() :: text:
if {jackpot::remainingminutes} is not set:
return "&cBelum dijadwalkan"
if {jackpot::remainingminutes} is less than or equal to 0:
return "&cSedang menunggu undian"
return "&f%{jackpot::remainingminutes}% menit"
function jackpotStartNewRound():
delete {jackpot::tickets::*}
delete {jackpot::playertickets::*}
delete {jackpot::processing::*}
set {jackpot::pool} to {jackpotconfig::jackpotawal}
set {_hours} to {jackpotconfig::periodejam}
set {jackpot::remainingminutes} to {_hours} * 60
function jackpotResetTotal():
jackpotStartNewRound()
delete {jackpot::forceconfirm::*}
delete {jackpot::resetconfirm::*}
function jackpotStoreHistory(winnerId: text, winnerName: text, amount: number):
loop 4 times:
set {_from} to 5 - loop-number
set {_to} to {_from} + 1
set {jackpot::history::%{_to}%::uuid} to {jackpot::history::%{_from}%::uuid}
set {jackpot::history::%{_to}%::winner} to {jackpot::history::%{_from}%::winner}
set {jackpot::history::%{_to}%::amount} to {jackpot::history::%{_from}%::amount}
set {jackpot::history::%{_to}%::time} to {jackpot::history::%{_from}%::time}
set {jackpot::history::1::uuid} to {_winnerId}
set {jackpot::history::1::winner} to {_winnerName}
set {jackpot::history::1::amount} to {_amount}
set {jackpot::history::1::time} to now
function jackpotOpenHistory(p: player, adminView: boolean):
if {_adminView} is true:
set {_gui} to chest inventory with 3 rows named "{@admin-history-gui}"
set {jackpot::historyadminview::%uuid of {_p}%} to true
else:
set {_gui} to chest inventory with 3 rows named "{@history-gui}"
delete {jackpot::historyadminview::%uuid of {_p}%}
loop 5 times:
set {_number} to loop-number
set {_slot} to 9 + {_number}
if {jackpot::history::%{_number}%::uuid} is set:
set {_winner} to {jackpot::history::%{_number}%::winner}
set {_amount} to {jackpot::history::%{_number}%::amount}
set {_date} to {jackpot::history::%{_number}%::time}
set {_item} to golden apple
set name of {_item} to "&6&l#%{_number}% &e%{_winner}%"
add "&7Hadiah: &a%jackpotMoney({_amount})%" to {_lore::*}
add "&7Waktu: &f%{_date}%" to {_lore::*}
if {_adminView} is true:
add "" to {_lore::*}
add "&cKlik untuk hapus history ini." to {_lore::*}
set lore of {_item} to {_lore::*}
set slot {_slot} of {_gui} to {_item}
delete {_lore::*}
else:
set {_empty} to gray stained glass pane
set name of {_empty} to "&7Belum ada pemenang"
set slot {_slot} of {_gui} to {_empty}
set {_close} to barrier
set name of {_close} to "&c&lTutup"
set slot 22 of {_gui} to {_close}
open {_gui} to {_p}
function jackpotPurchaseItem(p: player, amount: number) :: item:
set {_id} to uuid of {_p}
set {_owned} to {jackpot::playertickets::%{_id}%}
set {_total} to jackpotTicketTotal()
set {_cost} to {jackpotconfig::ticketprice} * {_amount}
set {_afterOwned} to {_owned} + {_amount}
set {_afterTotal} to {_total} + {_amount}
set {_chance} to jackpotChance({_afterOwned}, {_afterTotal})
set {_enabled} to true
set {_reason} to ""
if {jackpotconfig::enabled} is not true:
set {_enabled} to false
set {_reason} to "&cJackpot sedang nonaktif."
if {jackpot::drawing} is true:
set {_enabled} to false
set {_reason} to "&cUndian sedang diproses."
if {_amount} is greater than {jackpotconfig::maxpertransaksi}:
set {_enabled} to false
set {_reason} to "&cMelebihi batas transaksi."
if {jackpotconfig::cappertickets} is greater than 0:
if {_afterOwned} is greater than {jackpotconfig::cappertickets}:
set {_enabled} to false
set {_reason} to "&cBatas Ticket ronde ini tercapai!"
if balance of {_p} is less than {_cost}:
set {_enabled} to false
set {_reason} to "&cSaldo tidak cukup!"
if {_enabled} is true:
if {_amount} is 1:
set {_item} to emerald
else if {_amount} is 5:
set {_item} to emerald
set amount of {_item} to 5
else:
set {_item} to emerald block
set name of {_item} to "&a&l+%{_amount}% Ticket"
if {_amount} is {jackpotconfig::maxpertransaksi}:
set name of {_item} to "&a&l+%{_amount}% Ticket &7(Maks per transaksi)"
add "&7Harga: &c%jackpotMoney({_cost})%" to {_lore::*}
add "&7Peluang kamu jadi: &e%{_afterOwned}%/%{_afterTotal}% &7(%{_chance}% persen)" to {_lore::*}
add "" to {_lore::*}
add "&e▶ Klik untuk beli «" to {_lore::*}
set lore of {_item} to {_lore::*}
return {_item}
set {_item} to redstone block
set name of {_item} to "&c&l+%{_amount}% Ticket"
add "&7Harga: &c%jackpotMoney({_cost})%" to {_lore::*}
add "" to {_lore::*}
add "%{_reason}%" to {_lore::*}
set lore of {_item} to {_lore::*}
return {_item}
function jackpotOpenMain(p: player):
set {_id} to uuid of {_p}
set {_total} to jackpotTicketTotal()
set {_owned} to {jackpot::playertickets::%{_id}%}
set {_pool} to jackpotMoney({jackpot::pool})
set {_chance} to jackpotChance({_owned}, {_total})
set {_bar} to jackpotProgressBar({_owned}, {_total})
set {_time} to jackpotTimeText()
set {_gui} to chest inventory with 3 rows named "{@player-gui}"
set {_jackpot} to nether star
set name of {_jackpot} to "&6&l💎 SERVER JACKPOT"
add "&7Prize Pool: &a%{_pool}%" to {_lore::*}
add "&7Total Ticket Beredar: &e%{_total}%" to {_lore::*}
add "&7Kontribusi tiap ticket: &6%{jackpotconfig::persenjackpot}% persen" to {_lore::*}
add "" to {_lore::*}