NEED SCRIPT, IMMA PAY RUST ACC.

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

zyzaliukas

Member
Dec 7, 2024
1
0
1
23
i need skript for 1.20.1 mc version.
i need script for the use of checking ur own and other players pvp stats.
commands should be /stats - to check ur own stats, and /stats (player), to check other player stats.
and some admin commands with perms for wiping the all stats for all players (/stats wipeall), and to target a single player for that same purpose(/stats wipe (player).

all information i want to be in chat, and the stats and format i want is this:

(playername) statistics:

kills: ()
deaths: ()
killstreak: ()
best killstreak: ()
kdr: ()
placement: #()
last killed: (playername)

i want the placement would be based on most kills, i mean its like a scoreboard thing, to show what placecement the player is based on of all players that are in server, like placement: #1, if the player is with the top kills in server.i would love it if this is possible without any skripts addons, but its not then its fits as well.

i can pay only with RUST ACCOUNT, i had it for 2 years and almost never used it, cuz i play on my main acc. i thought its gonna be better to give it someone who wants to work for it a little! it has no vac bans or nothing, almost fresh acc haha

feel free to contact me in discord : zyzaliukas

theres a similar skript: https://forums.skunity.com/resources/kill-leaderboard.872/

but its old and cant get it to work, well just in case i added this. still i want it to show everything the way i sorted it.
 
Last edited:
this should work. have not tested in a server enviorment but it passed the parser.

Code:
# Function to calculate K/D ratio
function calculate_kdr(p: player) :: number:
    if {stats::%{p}%::deaths} > 0:
        return {stats::%{p}%::kills} / {stats::%{p}%::deaths}
    else:
        return {stats::%{p}%::kills} # No deaths, return just kills

# Function to calculate placement based on kills
function calculate_placement(p: player) :: number:
    set {_rank} to 1 # Initialize rank as 1
    loop all players:
        # Skip comparing the player to themselves
        if loop-player is not {p}:
            # If another player has more kills than the target player, increase the rank
            if {stats::%loop-player%::kills} > {stats::%{p}%::kills}:
                add 1 to {_rank}
    return {_rank}

# When a player dies, update their stats
on death of player:
    # Get the attacker and victim (the player who is killed and the one who kills)
    set {_attacker} to attacker
    set {_victim} to victim

    # Increment the attacker’s kills and victim’s deaths
    set {stats::%{_attacker}%::kills} to {stats::%{_attacker}%::kills} + 1
    set {stats::%{_victim}%::deaths} to {stats::%{_victim}%::deaths} + 1

    # Increase the attacker’s killstreak and reset the victim’s killstreak
    set {stats::%{_attacker}%::killstreak} to {stats::%{_attacker}%::killstreak} + 1
    set {stats::%{_victim}%::killstreak} to 0

    # Update best killstreak for the attacker
    if {stats::%{_attacker}%::killstreak} > {stats::%{_attacker}%::bestkillstreak}:
        set {stats::%{_attacker}%::bestkillstreak} to {stats::%{_attacker}%::killstreak}

    # Track last killed player for the attacker
    set {stats::%{_attacker}%::lastkilled} to name of {_victim}

# Reset killstreak on respawn
on death of player:
    set {stats::%player%::killstreak} to 0

# /stats command to check player's own stats
command /stats:
    trigger:
        set {_placement} to calculate_placement(player) # Get placement
        set {_kdr} to calculate_kdr(player) # Get K/D ratio
        send "&e(Your Stats) &7Statistics:" to player
        send "&7Kills: %{stats::%player%::kills}%" to player
        send "&7Deaths: %{stats::%player%::deaths}%" to player
        send "&7Killstreak: %{stats::%player%::killstreak}%" to player
        send "&7Best Killstreak: %{stats::%player%::bestkillstreak}%" to player
        send "&7K/D Ratio: %{_kdr}%" to player
        send "&7Placement: %{_placement}%" to player
        send "&7Last Killed: %{stats::%player%::lastkilled}%" to player

# /stats (player) command to check another player's stats
command /stats <player>:
    trigger:
        set {_placement} to calculate_placement(argument 1) # Get placement of the target player
        set {_kdr} to calculate_kdr(argument 1) # Get K/D ratio of the target player
        send "&e%argument 1%'s Statistics:" to player
        send "&7Kills: %{stats::%argument 1%::kills}%" to player
        send "&7Deaths: %{stats::%argument 1%::deaths}%" to player
        send "&7Killstreak: %{stats::%argument 1%::killstreak}%" to player
        send "&7Best Killstreak: %{stats::%argument 1%::bestkillstreak}%" to player
        send "&7K/D Ratio: %{_kdr}%" to player
        send "&7Placement: %{_placement}%" to player
        send "&7Last Killed: %{stats::%argument 1%::lastkilled}%" to player

# Admin Commands for wiping stats
# /stats wipeall to wipe all stats for all players
command /stats wipeall:
    permission: admin.stats
    trigger:
        loop all players:
            delete {stats::%loop-player%::*}
        send "&cAll player stats have been wiped." to player

# /stats wipe (player) to wipe a specific player's stats
command /stats wipe <player>:
    permission: admin.stats
    trigger:
        delete {stats::%argument 1%::*}
        send "&c%argument 1%'s stats have been wiped." to player
        send "&cYour stats have been wiped." to argument 1