Prestige with an item

  • 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!

ItzAstrid

Member
May 6, 2024
4
0
1
24
Basically I want a skript that on right click of a book for example that it removes the book and gives the player +1 prestige, and I want it to also show up in chat before their rank and name, I use ChatControl for my chat manager
 
AppleScript:
options:
    # MAX ACHIEVABLE PRESTIGE
    # SET TO -1 FOR NO LIMIT
    max-prestige: 5

function retrievePrestige(p: player) :: number:
    metadata tag "prt" of {_p} is set:
        return metadata tag "prt" of {_p}
        stop
    byte tag "PRT" of nbt compound of {_p} is set:
        set metadata tag "prt" of {_p} to byte tag "PRT" of nbt compound of {_p}
        delete byte tag "PRT" of nbt compound of {_p}
    else:
        set metadata tag "prt" of {_p} to 0
    return metadata tag "prt" of {_p}

command /giveprestigeitem <player=%player%>:
    permission: *
    trigger:
        give arg-1 book named "&b+1 PRESTIGE"
       
command /prestige <player=%player%>:
    trigger:
        set {_n} to name of arg-1
        arg-1 is player:
            set {_n} to "Your"
        set {_p} to metadata tag "prt" of arg-1
        if metadata tag "prt" of arg-1 is not set:
            set {_p} to 0
        send "&f&l%{_n}% &r&bprestige is &7%{_p}%"

on leave:
    set byte tag "PRT" of nbt compound of player to metadata tag "prt" of player

on unload:
    loop all players:
        set byte tag "PRT" of nbt compound of loop-player to metadata tag "prt" of loop-player

on join:
    if byte tag "PRT" of nbt compound of player is not set:
        set byte tag "PRT" of nbt compound of player to 0
    set metadata tag "prt" of player to byte tag "PRT" of nbt compound of player
    delete byte tag "PRT" of nbt compound of player

on load:
    loop all players:
        if byte tag "PRT" of nbt compound of loop-player is not set:
            set byte tag "PRT" of nbt compound of loop-player to 0
        set metadata tag "prt" of loop-player to byte tag "PRT" of nbt compound of loop-player
        delete byte tag "PRT" of nbt compound of loop-player

on right click:
    name of 1 of player's tool contains "&b+1 PRESTIGE":
        set {_d} to metadata tag "prt" of player
        {@max-prestige} > {_d}:
            set metadata tag "prt" of player to 1+{_d}
            remove 1 of player's tool from player
            broadcast "&f&l%player's name% &r&breedemed +1 Prestige!"
        else:
            send "&bYou have hit the max Prestige!" to player
 
Last edited:
AppleScript:
options:
    # MAX ACHIEVABLE PRESTIGE
    # SET TO -1 FOR NO LIMIT
    max-prestige: 5

function retrievePrestige(p: player) :: number:
    metadata tag "prt" of {_p} is set:
        return metadata tag "prt" of {_p}
        stop
    byte tag "PRT" of nbt compound of {_p} is set:
        set metadata tag "prt" of {_p} to byte tag "PRT" of nbt compound of {_p}
        delete byte tag "PRT" of nbt compound of {_p}
    else:
        set metadata tag "prt" of {_p} to 0
    return metadata tag "prt" of {_p}

command /giveprestigeitem <player=%player%>:
    permission: *
    trigger:
        give arg-1 book named "&b+1 PRESTIGE"
      
command /prestige <player=%player%>:
    trigger:
        set {_n} to name of arg-1
        arg-1 is player:
            set {_n} to "Your"
        set {_p} to metadata tag "prt" of arg-1
        if metadata tag "prt" of arg-1 is not set:
            set {_p} to 0
        send "&f&l%{_n}% &r&bprestige is &7%{_p}%"

on leave:
    set byte tag "PRT" of nbt compound of player to metadata tag "prt" of player

on unload:
    loop all players:
        set byte tag "PRT" of nbt compound of loop-player to metadata tag "prt" of loop-player

on join:
    if byte tag "PRT" of nbt compound of player is not set:
        set byte tag "PRT" of nbt compound of player to 0
    set metadata tag "prt" of player to byte tag "PRT" of nbt compound of player
    delete byte tag "PRT" of nbt compound of player

on load:
    loop all players:
        if byte tag "PRT" of nbt compound of loop-player is not set:
            set byte tag "PRT" of nbt compound of loop-player to 0
        set metadata tag "prt" of loop-player to byte tag "PRT" of nbt compound of loop-player
        delete byte tag "PRT" of nbt compound of loop-player

on right click:
    name of 1 of player's tool contains "&b+1 PRESTIGE":
        set {_d} to metadata tag "prt" of player
        {@max-prestige} > {_d}:
            set metadata tag "prt" of player to 1+{_d}
            remove 1 of player's tool from player
            broadcast "&f&l%player's name% &r&breedemed +1 Prestige!"
        else:
            send "&bYou have hit the max Prestige!" to player
is there any skript addons I need for this?
 
Question: how would I put this to show in chat? Just so people can flex their prestiges so it doesn't feel like a lost function with no use (even tho there is a way to check the prestiges)
 
Question: how would I put this to show in chat? Just so people can flex their prestiges so it doesn't feel like a lost function with no use (even tho there is a way to check the prestiges)
add &f&l[&b&l%metadata tag "prt" of player%&r&f&l] to the start of the chatFormat options
 
Another thing you can use is do your chat format settings with this:
Code:
set chat format to "%player's prefix%%player's displayname%&f: %message%"
(if you're using prefixes and stuff). That way, you can just do this:
Code:
set player's displayname to "%player's displayname% &7{&6%metadata tag "prt" of player%&7}"

You can also use Skript-placeholders if you use plugins like TAB or EssentialsChat for your tab and chat settings