Discord Thread Skript class gui

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

This thread came from the skUnity Discord. You can't reply to it here but if you join the skUnity Discord, you'll be able to post a reply there. The thread link is part of the thread's message.
Status
Not open for further replies.

skUnity Discord

Site Manager
Aug 5, 2023
12,755
1
0
The skUnity Discord
discord.gg
code_language.skript:
options:
    prefix: &eArtix&cRPG &8|

on join:
    if {joined::%player's uuid%} is not set:
        set {class::%player's uuid%} to "&b&lUNRANKED"
        set {joined::%player's uuid%} to true

on join:
    if {class::%player's uuid%} is not set:
        set {class::%player's uuid%} to "&b&lUNRANKED"

on join:
    if {class::%player's uuid%} is not set:
        set {_class} to {class::%player's uuid%}

command /deldata:
    permission: console
    trigger:
        delete {class::*}


function classGUI(p: player):
    create a gui with virtual chest inventory with size 3 named "Choose Class" with shape "---------" and "-1-2-3-4-" and "---------":
        make gui slot "-" with black stained glass pane
        make gui slot "1" with SHIELD named "&eWarrior (Tank)":
            chooseClass({_p}, "Warrior")
        make gui slot "2" with diamond ore named "&eArcher":
            chooseClass({_p}, "Knight")
        make gui slot "3" with wheat named "&eArcher":
            chooseClass({_p}, "Archer")
        make gui slot "4" with raw cod named "&eMage":
            chooseClass({_p}, "Mage")
    open last gui to {_p}

command /class:
    trigger:
        classGUI(player)
    
function chooseClass(p: player, t: text):

    {_t} is "Warrior":
        set {_class} to {_t}
        send "{@prefix} &eYou have choosed class &b%{_t}%&e." to {_p}
        stop
    {_t} is "Knight":
        set {_class} to {_t}
        send "{@prefix} &eYou have choosed class &b%{_t}%&e." to {_p}
        stop
    {_t} is "Archer":
        set {_class} to {_t}
        send "{@prefix} &eYou have choosed class &b%{_t}%&e." to {_p}
        stop
    {_t} is "Mage":
        set {_class} to {_t}
        send "{@prefix} &eYou have choosed class &b%{_t}%&e." to {_p}
        stop

When I choose any class it doesn't show in sidebar and my stats my class, just UNRANKED it doesn't change.

Can anyone help me?

Posted by: .h4xr from the skUnity Discord. View the thread on skUnity Discord here
 
in the chooseClass() function, you are setting {_class} to the name of the class, but nothing else. {_class} is a LOCAL variable, meaning it will only work in the code that is being used (in this case, ONLY inside the function, nothing else). I'm assuming the scoreboard is displaying "%{_class}%" ? If so, it is trying to show a local variable that was already deleted
so, just replace the {_class} in your function with {class::%uuid of {_p}%} and you're good

Posted by: tobyminceraft from the skUnity Discord.
 
code_language.skript:
options:
    prefix: &eArtix&cRPG &8|
on join:
    if {joined::%player's uuid%} is not set:
        set {class::%player's uuid%} to "&b&lUNRANKED"
        set {joined::%player's uuid%} to true
on join:
    if {class::%player's uuid%} is not set:
        set {class::%player's uuid%} to "&b&lUNRANKED"
on join:
    if {class::%player's uuid%} is not set:
        set {_class} to {class::%player's uuid%}
command /deldata:
    permission: console
    trigger:
        delete {class::*}


function classGUI(p: player):
    set {_} to chest inventory with 3 rows named "Choose Class"
    set slot (integers between 0 and 27) of {_} to black stained glass pane
    set slot 10 of {_} to shield named "&eWarrior (Tank)"
    set slot 12 of {_} to diamond ore named "&eArcher"
    set slot 14 of {_} to wheat named "&eArcher"
    set slot 16 of {_} to stick named "&eMage"
    open {_} to {_p}

command /class:
    trigger:
        classGUI(player)
on inventory click:
    event-inventory is not player's inventory
    click type is left mouse button
    if name of event-inventory is "Choose Class":
        cancel event
        if clicked slot is 10 or 12 or 14 or 16:
            set {_t} to uncolored name of clicked slot
            replace " (Tank)" with "" in {_t}
            set {class::%player's uuid%} to {_t}
            send "{@prefix} &eYou have choosed class &b%{_t}%&e." to player
i did it in the correct way and in normal gui

Posted by: _grifin_ from the skUnity Discord.
 
Status
Not open for further replies.