Solved Permission not given to op by default

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

    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!

xWires

Member
Aug 15, 2023
41
4
8
How can I make a permission that is not given to players with op by default? I have made a level up script, but because all skript permissions are given to ops by default, it doesnt work for people who have op.

Code:
options:
    b_cost: 100
    c_cost: 200
    d_cost: 400
    e_cost: 800
    f_cost: 1600
    g_cost: 3200
    h_cost: 6400
    i_cost: 12800
    j_cost: 25600
    k_cost: 51200
    l_cost: 102400
    m_cost: 204800
    n_cost: 409600
    o_cost: 819200
    p_cost: 1638400
    q_cost: 3276800
    r_cost: 6553600
    s_cost: 13107200
    t_cost: 26214400
    u_cost: 52428800
    v_cost: 104857600
    w_cost: 209715200
    x_cost: 419430400
    y_cost: 838860800
    z_cost: 1677721600

command /levelup:
    permission: wirednetwork.levelup
    permission message: &cYou don't have permission to use this command
    trigger:
        if player has permission "wirednetwork.level.a":
            if player's balance >= {@b_cost}:
                remove {@b_cost} from player's balance
                execute console command "lp user %player% promote levels"
            else:
                send "&cYou need ${@b_cost}" to player
        else if player has permission "wirednetwork.level.b":
            if player's balance >= {@c_cost}:
                remove {@c_cost} from player's balance
                execute console command "lp user %player% promote levels"
            else:
                send "&cYou need ${@c_cost}" to player
        else if player has permission "wirednetwork.level.c":
            if player's balance >= {@d_cost}:
                remove {@d_cost} from player's balance
                execute console command "lp user %player% promote levels"
            else:
                send "&cYou need ${@d_cost}" to player
        else if player has permission "wirednetwork.level.d":
            if player's balance >= {@e_cost}:
                remove {@e_cost} from player's balance
                execute console command "lp user %player% promote levels"
            else:
                send "&cYou need ${@e_cost}" to player
        else if player has permission "wirednetwork.level.e":
            if player's balance >= {@f_cost}:
                remove {@f_cost} from player's balance
                execute console command "lp user %player% promote levels"
            else:
                send "&cYou need ${@f_cost}" to player
        else if player has permission "wirednetwork.level.f":
            if player's balance >= {@g_cost}:
                remove {@g_cost} from player's balance
                execute console command "lp user %player% promote levels"
            else:
                send "&cYou need ${@g_cost}" to player
        else if player has permission "wirednetwork.level.g":
            if player's balance >= {@h_cost}:
                remove {@h_cost} from player's balance
                execute console command "lp user %player% promote levels"
            else:
                send "&cYou need ${@h_cost}" to player
        else if player has permission "wirednetwork.level.h":
            if player's balance >= {@i_cost}:
                remove {@i_cost} from player's balance
                execute console command "lp user %player% promote levels"
            else:
                send "&cYou need ${@i_cost}" to player
        else if player has permission "wirednetwork.level.i":
            if player's balance >= {@j_cost}:
                remove {@j_cost} from player's balance
                execute console command "lp user %player% promote levels"
            else:
                send "&cYou need ${@j_cost}" to player
        else if player has permission "wirednetwork.level.j":
            if player's balance >= {@k_cost}:
                remove {@k_cost} from player's balance
                execute console command "lp user %player% promote levels"
            else:
                send "&cYou need ${@k_cost}" to player
 
youd have to make the permission level for that perm higher then op has for normal idk how to set that tho
 
I figured out I can just use
Code:
if groups of player contains "level_a":
instead of giving each group a permission
 
How can I make a permission that is not given to players with op by default? I have made a level up script, but because all skript permissions are given to ops by default, it doesnt work for people who have op.

Code:
options:
    b_cost: 100
    c_cost: 200
    d_cost: 400
    e_cost: 800
    f_cost: 1600
    g_cost: 3200
    h_cost: 6400
    i_cost: 12800
    j_cost: 25600
    k_cost: 51200
    l_cost: 102400
    m_cost: 204800
    n_cost: 409600
    o_cost: 819200
    p_cost: 1638400
    q_cost: 3276800
    r_cost: 6553600
    s_cost: 13107200
    t_cost: 26214400
    u_cost: 52428800
    v_cost: 104857600
    w_cost: 209715200
    x_cost: 419430400
    y_cost: 838860800
    z_cost: 1677721600

command /levelup:
    permission: wirednetwork.levelup
    permission message: &cYou don't have permission to use this command
    trigger:
        if player has permission "wirednetwork.level.a":
            if player's balance >= {@b_cost}:
                remove {@b_cost} from player's balance
                execute console command "lp user %player% promote levels"
            else:
                send "&cYou need ${@b_cost}" to player
        else if player has permission "wirednetwork.level.b":
            if player's balance >= {@c_cost}:
                remove {@c_cost} from player's balance
                execute console command "lp user %player% promote levels"
            else:
                send "&cYou need ${@c_cost}" to player
        else if player has permission "wirednetwork.level.c":
            if player's balance >= {@d_cost}:
                remove {@d_cost} from player's balance
                execute console command "lp user %player% promote levels"
            else:
                send "&cYou need ${@d_cost}" to player
        else if player has permission "wirednetwork.level.d":
            if player's balance >= {@e_cost}:
                remove {@e_cost} from player's balance
                execute console command "lp user %player% promote levels"
            else:
                send "&cYou need ${@e_cost}" to player
        else if player has permission "wirednetwork.level.e":
            if player's balance >= {@f_cost}:
                remove {@f_cost} from player's balance
                execute console command "lp user %player% promote levels"
            else:
                send "&cYou need ${@f_cost}" to player
        else if player has permission "wirednetwork.level.f":
            if player's balance >= {@g_cost}:
                remove {@g_cost} from player's balance
                execute console command "lp user %player% promote levels"
            else:
                send "&cYou need ${@g_cost}" to player
        else if player has permission "wirednetwork.level.g":
            if player's balance >= {@h_cost}:
                remove {@h_cost} from player's balance
                execute console command "lp user %player% promote levels"
            else:
                send "&cYou need ${@h_cost}" to player
        else if player has permission "wirednetwork.level.h":
            if player's balance >= {@i_cost}:
                remove {@i_cost} from player's balance
                execute console command "lp user %player% promote levels"
            else:
                send "&cYou need ${@i_cost}" to player
        else if player has permission "wirednetwork.level.i":
            if player's balance >= {@j_cost}:
                remove {@j_cost} from player's balance
                execute console command "lp user %player% promote levels"
            else:
                send "&cYou need ${@j_cost}" to player
        else if player has permission "wirednetwork.level.j":
            if player's balance >= {@k_cost}:
                remove {@k_cost} from player's balance
                execute console command "lp user %player% promote levels"
            else:
                send "&cYou need ${@k_cost}" to player
You can simplify this code greatly with functions.
 
You can simplify this code greatly with functions.
I'm sure I could, I just don't know how, and this works so for now I'm happy with it, I'll probably change it in the future when I know more about skript.
 
That would be great, thanks
Sorry, just got back from school.

Functions are great for repeating code, which you did here.

First things first, instead of using options, use variables. Variables can be used in a lot of scenarios. Options are only good for text, like for example if you named your plugin and you wanted to make the name shown in each cmd, you would use an option so you wouldn't have to repeat it.

Variables are good for numbers. Very, very good for numbers Oh yeah, and booleans, but booleans aren't important. The main point is to use variables instead.

Now here is a good way to simplify your code with a function:

Code:
function balance(p: player, n: number, s: object):
          set {_bal} to player's balance
          if {_p} has permission "wirednetwork.level.%{_s}%":
            if {_bal} >= {_n}:
                remove {_n} from {_bal}
                execute console command "lp user %player% promote levels"
            else:
                send "&cYou need $%({_n} - {_bal})%" to player

And to use it, you would do this:

Code:
 balance(player, {[variable name]}, [whatever letter])

So for example:

Code:
balance(player, {cost.b}, b)

If you still need help or want a more detailed explanation, let me know.
 
Last edited:
  • Like
Reactions: xWires
Sorry, just got back from school.

Functions are great for repeating code, which you did here.

First things first, instead of using options, use variables. Variables can be used in a lot of scenarios. Options are only good for text, like for example if you named your plugin and you wanted to make the name shown in each cmd, you would use an option so you wouldn't have to repeat it.

Variables are good for numbers. Very, very good for numbers Oh yeah, and booleans, but booleans aren't important. The main point is to use variables instead.

Now here is a good way to simplify your code with a function:

Code:
function balance(p: player, n: number, s: string):
          set {_bal} to player's balance
          if {_p} has permission "wirednetwork.level.%{_s}%":
            if {_bal} >= {_n}:
                remove {_n} from {_bal}
                execute console command "lp user %player% promote levels"
            else:
                send "&cYou need $%({_n} - {_bal})%" to player

And to use it, you would do this:

Code:
 balance(player, {[variable name]}, [whatever letter])

So for example:

Code:
balance(player, {cost.b}, b)

If you still need help or want a more detailed explanation, let me know.
Thank you!