Need some help with Skript

Discussion in 'Spigot Plugin Help' started by Thomas_, May 23, 2015.

  1. So basically i'm creating a command that is /fixpower and all it does is give the player a faction powerboost ( Yes we have staff who can do it but they're not on 24/7 )

    Anyways here's what i've gotten so far :p ( I only started to learn Skript yesterday so i'm sorry if the code is really really bad lol)

    Code (Text):

    command /fixpower:
        permission: skript.fixpower
        trigger:
            if arg 1 is not set:
                if player has permission "fixpower.God":
                        execute console command "/f powerboost p %player% 50"
                        message "&eYou have been given your faction powerboost!"
            else if player has permission "fixpower.SuperGod":
                        execute console command "/f powerboost p %player% 150"
                        message "&eYou have been given your faction powerboost!"
     
     
  2. You're asking for an argument ("if arg 1 is not set:"), but you aren't specifying an argument in the command.

    modify the command line so it has an argument:
    Code (Text):
    command /fixpower <text/player/offlineplayer/number/whatever type the argument should be>
    OR remove "if arg 1 is not set:" and set the indentation correctly for the "fixpower.God" permission check.

    Also, you don't need to define the "permission: skript.fixpower" portion of the skript if you're going to check permissions in the skript anyway, unless you want the player to have both permissions to be able to run it.
     
    • Like Like x 1
  3. Ok i'm editting that now and will update you ina second if it works
     
  4. Done everythign but what do you mean by set the indentation correctly? that's the only way i know how to check for the permission
     
  5. There's nothing wrong with how you were checking permissions, those two ways are fine, but generally you don't have to use BOTH methods to check permissions, only one or the other.

    Indentation is the spacing before a line. If were to remove the "if arg 1..." line, you'd have to remove some spacing before the first "if player has permission..." line, so that the script would load correctly, thats all.
     
    • Like Like x 1
  6. When i do the command no message shows up and it's not giving me the powerboost :/

    Here's what i've done
    Code (Text):

    command /fixpower:
        trigger:
         if player has permission "fixpower.God":
                        execute console command "/f powerboost p %player% 50"
                        message "&eYou have been given your faction powerboost!"
            else if player has permission "fixpower.SuperGod":
                        execute console command "/f powerboost p %player% 150"
                        message "&eYou have been given your faction powerboost!"
     
     
    #6 Thomas_, May 23, 2015
    Last edited: May 23, 2015
  7. Spacing/indentation is just off:
    Code (Text):

    command /fixpower:
            trigger:
                    if player has permission "fixpower.God":
                            execute console command "/f powerboost p %player% 50"
                            message "&eYou have been given your faction powerboost!"
                    else if player has permission "fixpower.SuperGod":
                            execute console command "/f powerboost p %player% 150"
                            message "&eYou have been given your faction powerboost!"
     
     
    • Like Like x 1
  8. I'm often confused with skripts.
    ;(
     
  9. So read the docs! Though you call yourself a developer, so just develop in Java ;) Skript is pretty easy to grasp once you realize the code sections are just determined by spacing instead of curly brackets.
     
    • Like Like x 1

  10. Nah... the basic concept is easy as poo. Its almost plain English. If you can follow the logic, you can probably write it in Skript. It has it's limitations for sure, but I used to do some pretty crazy stuff with it.
     
    • Agree Agree x 1
  11. Plain English??? Hell! I code CSS better than that and I have no idea what is CSS-related and what's HTML :eek:
     
  12. Forgot to update, i got it working thanks Absentee :D
     
  13. Then whats the problem, why are you even replying to this thread? If you're just going to act like you're too good for it with some ridiculous comparison to css & html (a stylesheet & a markup language, not programming languages, nor a scripting languages. So basically completely unrelated other than all of it being "code"), then go develop in Java, after all you are a self-proclaimed "Java Developer".

    It's as close to plain english as code can ever get lol. It can be plain German if you want, too (or whatever else there are language files for)!
     
    #13 Absentee23, May 23, 2015
    Last edited: May 23, 2015
  14. the basic stuff is SUPER easy...

    on break of block:
    give player an apple

    that stuff is easy.

    BUT... it CAN get complicated.

    Code (Text):
    command /flags [<text>] [<text>] [<text>]:
        permission: obam.free
        trigger:
       
            argument 1 is not set:
               
                set {_who} to "Everyone"
                set {_grab} to "header"
                set {_menu.run} to true
               
            argument 1 is not "menu" or "set":
                argument 1 is not "menu" or "set"
                set {_who} to argument 1
                set {_grab} to "header"
                set {_menu.run} to true
                argument 2 is set:
                    send "&cThat is not quite right..."
                    stop
                   
            argument 1 is "menu":
                set {_who} to argument 3
                {_who} is not set:
                    send "&cThat is not quite right..."
                    stop
                set {_grab} to argument 2
                set {_menu.run} to true
               
            argument 1 is "set":
                {chunk.live.%chunk at location of player%} is not set:
                    send "&cThis is not a claimed chunk!"
                    stop
                {chunk.live.%chunk at location of player%} is not uuid of player:
                    {flags.%chunk at location of player%::admin::Everyone} is not set:
                        set {flags.%chunk at location of player%::admin::Everyone} to false
                    {flags.%chunk at location of player%::admin::Everyone} is false:
                        {flags.%chunk at location of player%::admin::%uuid of player%} is not set:
                            set {flags.%chunk at location of player%::admin::%uuid of player%} to false
                           
                    {flags.%chunk at location of player%::admin::Everyone} is false:
                        {flags.%chunk at location of player%::admin::%uuid of player%} is false:
                            send "&cYou do not have permission to do this!"
                            stop
               
                argument 3 is not "Everyone":
                    set {_playerLookUp} to argument 3
                    access "playerLookUp" from {_playerLookUp}
                    {_playerLookUp} is argument 3:
                        send "&c%argument 3% is not a valid player! Please check spelling and try again!"
                        stop
                    set {_who} to {_playerLookUp}
                else:
                    argument 3 is set
                    set {_who} to "Everyone"
               
                argument 2 is "all":
                    $ thread
                    set {_list::*} to objects in column "FlagName" from result of query "SELECT * FROM Flags"
                    set {_found} to false
                    loop {_list::*}:
                        {flags.%chunk at location of player%::%loop-value%::%{_who}%} is true:
                            set {_found} to true
                    {_found} is true:
                        loop {_list::*}:
                            set {flags.%chunk at location of player%::%loop-value%::%{_who}%} to false
                        send "&cCleared all flags for &e%argument 3%&c!"
                        stop
                    {_found} is false:
                        loop {_list::*}:
                            set {flags.%chunk at location of player%::%loop-value%::%{_who}%} to true
                        send "&aSet all flags to &etrue &afor &e%argument 3%&a!"
                        stop
                argument 2 is "front" or "frontflow" or "frontfirespread" or "fronttnt":
                    {flags.%chunk at location of player%::%argument 2%} is true:
                        set {flags.%chunk at location of player%::%argument 2%} to false
                        send "&cYou have disabled the &e%argument 2%&c flag on this &eFront"
                        stop
                    {flags.%chunk at location of player%::%argument 2%} is false:
                        set {flags.%chunk at location of player%::%argument 2%} to true
                        send "&aYou have enabled the &e%argument 2%&a flag on this &eFront"
                        stop
                {flags.%chunk at location of player%::%argument 2%::%{_who}%} is false:
                    set {flags.%chunk at location of player%::%argument 2%::%{_who}%} to true
                    send "&aEnabled &e%argument 2%&a flag for &e%argument 3%"
                    stop
                {flags.%chunk at location of player%::%argument 2%::%{_who}%} is true:
                    set {flags.%chunk at location of player%::%argument 2%::%{_who}%} to false
                    send "&cDisabled &e%argument 2%&c flag for &e%argument 3%"
                    stop
                       

                   
                   
               
               
            {_who} is not "Everyone":
                set {_playerLookUp} to {_who}
                access "playerLookUp" from {_playerLookUp}
                {_playerLookUp} is {_who}:
                    send "%{_who}% is not a valid player! Please check spelling and try again!"
                    stop
                   
                set {_who.name} to {_who}
                set {_who} to {_playerLookUp}
               
            else:
                set {_who.name} to "Everyone"
               
            {_menu.run} is set
            send "&aOpening Menu..."
            wait 3 ticks
               
            set {_query} to result of query "SELECT * FROM Flags WHERE Layer = '%{_grab}%'"
            set {_cur.menu::*} to objects in column "FlagName" from {_query}
            {_cur.menu::*} is not set:
                send "&cThat is not quite right..."
                stop
            set {_size} to size of {_cur.menu::*}
            set {_chest} to 2
            {_size} is less than or equal to 9:
                set {_chest} to 2
            {_size} is greater than 9:
                set {_chest} to 4
            {_size} is greater than 18:
                set {_chest} to 6
            {_size} is greater than 27:
                set {_chest} to 8
            show chest with {_chest} rows named "&1OBAM Flags %{_grab}% Menu" to player
            wait 1 tick
            loop {_cur.menu::*}:
                set {_query} to result of query "SELECT * FROM Flags WHERE FlagName = '%loop-value%'"
                set {_flagname} to "%loop-value%"
                set {_cur.item::*} to objects in column "Item" from {_query}
                set {_item} to {_cur.item::1} parsed as item
                set {_cur.name::*} to objects in column "Name" from {_query}
                set {_name} to {_cur.name::1}
                set {_cur.lore::*} to objects in column "Lore" from {_query}
                set {_lore} to {_cur.lore::1}
                set {_cur.slot::*} to objects in column "Slot" from {_query}
                set {_slot} to {_cur.slot::1}
                {_slot} is greater than 18:
                    add 18 to {_slot}
                {_slot} is greater than 9:
                    {_slot} is less than or equal to 18
                    add 9 to {_slot}
                set {_slot} to {_slot} - 1
                set {_slot1} to {_slot} + 9
                set {_cur.com::*} to objects in column "Command" from {_query}
                set {_command} to {_cur.com::1}
                replace "PLAYER" in {_command} with "%player%"
                replace "WHO" in {_command} with "%{_who.name}%"
                set {_what} to {_item} named {_name} with lore {_lore}
                format slot {_slot} of player with {_what} to be unstealable
                {_command} is set:
                    format slot {_slot} of player with {_what} to close then run {_command}
                {_flagname} is "all":
                    set {_found} to false
                    set {_list::*} to objects in column "FlagName" from result of query "SELECT * FROM Flags"
                    loop {_list::*}:
                        {flags.%chunk at location of player%::%loop-value-2%::%{_who}%} is not set:
                            set {flags.%chunk at location of player%::%loop-value-2%::%{_who}%} to false
                       
                        {flags.%chunk at location of player%::%loop-value-2%::%{_who}%} is true:
                            set {_found} to true
                       
                {_found} is true:
                    set {_item2} to light green wool
                    set {_lore2} to "&6Click to &cDisable &6all flags for &e%{_who.name}%."
                    set {_name2} to "&aEnabled"
                    set {_command2} to "sudo %player% flags set all %{_who.name}%"
                {_found} is false:
                    set {_item2} to red wool
                    set {_name2} to "&cDisabled"
                    set {_lore2} to "&6Click to &aEnable &6all flags for &e%{_who.name}%."
                    set {_command2} to "sudo %player% flags set all %{_who.name}%"
                {_flagname} is "frontflow" or "frontfirespread" or "fronttnt":
                    {flags.%chunk at location of player%::%{_flagname}%} is not set:
                        set {flags.%chunk at location of player%::%{_flagname}%} to false
                    {flags.%chunk at location of player%::%{_flagname}%} is true:
                        set {_item2} to light green wool
                        set {_name2} to "&aEnabled"
                        set {_lore2} to "&6Click to &cDisable &6the &e%{_flagname}% &6flag for this front."
                        set {_command2} to "sudo %player% flags set %{_flagname}%"
                    {flags.%chunk at location of player%::%{_flagname}%} is false:
                        set {_item2} to red wool
                        set {_name2} to "&cDisabled"
                        set {_lore2} to "&6Click to &aEnable &6the &e%{_flagname}% &6flag for this front."
                        set {_command2} to "sudo %player% flags set %{_flagname}% %{_who.name}%"
                {_flagname} is not "front" or "frontflow" or "frontfirespread" or "fronttnt" or "all":
                    {flags.%chunk at location of player%::%{_flagname}%::%{_who}%} is not set:
                        set {flags.%chunk at location of player%::%{_flagname}%::%{_who}%} to false
                    {flags.%chunk at location of player%::%{_flagname}%::%{_who}%} is true:
                        set {_item2} to light green wool
                        set {_name2} to "&aEnabled"
                        set {_lore2} to "&6Click to &cDisable &6the &e%{_flagname}% &6flag for &e%{_who.name}%."
                        set {_command2} to "sudo %player% flags set %{_flagname}% %{_who.name}%"
                    {flags.%chunk at location of player%::%{_flagname}%::%{_who}%} is false:
                        set {_item2} to red wool
                        set {_name2} to "&cDisabled"
                        set {_lore2} to "&6Click to &aEnable &6the &e%{_flagname}% &6flag for &e%{_who.name}%."
                        set {_command2} to "sudo %player% flags set %{_flagname}% %{_who.name}%"
                set {_what2} to {_item2} named {_name2} with lore {_lore2}
                format slot {_slot1} of player with {_what2} to be unstealable
                format slot {_slot1} of player with {_what2} to close then run {_command2}  
                clear {_slot1}
                clear {_what2}
                clear {_item2}
                clear {_name2}
                clear {_query}
                clear {_lore2}
                clear {_command2}
                clear {_found}
    Thats one I actually just had sitting in notepad ++ and by far not the most complicated (or cleaniest) thing I have made in skript.
     
  15. I'll say! :p CakeTube is 1200+ lines and itself is only a fraction of the Skript that runs on my server.
     
  16. Just wondering. What does your skript do?
    What are you doing with all the SQL Query stuff.

    Looks like a gui based permissions flag system for your own player protection skript?
     

  17. Indeed it is :D

    It pulls the builds of the menu from a database, so we can use the exact same build across servers without having to use Skript's shitty flatfile system. It is actually still active, one of the few Skript things I still have lurking around my server. But, the flags are simply 'permissions' that are based per chunk, which are handled in our survival land claiming system.
     
  18. F*ck don't even get me started on skripts flatfile system. I dont know how one can come up with that system.

    Skript is awesome though, I can do so much cool stuff and so easily too. Stuff where it would cost a good $50 to get made. I've made some insane stuff with its "limited" functionality. At the same time i'm ashamed to use it. I know I cant use it forever and that its not the answer. But java seems so damn daunting. I always look at the "Spigot Plugin" threads and see all the code snippets. Although I can read and understand what the code is doing. It just seems so difficult. Trust me, I would love to convert all my .sk's into .jar's. I want to start learning once I finish school and the server. But I have no idea where to start, there are so many ways to do so many things. So much information.

    Why write a plugin that has like 6 class files and 1k lines all together and take a whole weekend to write when in skript I could do the same in 500 and in a couple of hours? Thats what really kept me off the whole thing too. I don't even want an easy way to learn java. Just a set way. There are so many tutorials but then there are comments like "No, thats not how you do it" "There's a better way" Gets very confusing.

    ya know dawg?