Adding MySQL to script?

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

Status
Not open for further replies.

Adrihun

Member
Feb 1, 2017
368
6
0
Hi. Thanks for clicking on my post. I need help with Script + MySQL. I would like to add MySQL to this so whenever players go on Lobby-1 and change something it also changes in Lobby-2.

Please if you know MySQL+Script, help me with this. Also, the creator of this script is no longer updating this script. He is now doing Java.

code_language.skript:
options:
    #The world which Lobby Preferences effect is enabled
    Pref.Enabled: world
  
    #Command prefix
    Pref.Prefix: &3[&9Preferences&3]
  
    #GUI (chest) name
    Pref.GUIname: Player Preferences
  
    #Hide Kick and Death message
    Pref.KickMsgHide: true
    Pref.DeathMsgHide: true
  
    #Customize the Join/Leave message
    Pref.MsgJoin: &1[&dJoin/Leave&1] &7%event-player% has joined the server.
    Pref.MsgLeave: &1[&dJoin/Leave&1] &7%event-player% has left the server.
  
    #Hide system default Join/Leave mesasge
    Pref.HideSysJoin: true
    Pref.HideSysLeave: true
  
    #Admin permission, to configure player's options via commands
    Pref.AdminPerm: Pref.Admin
  
    #Restricted commands
    Pref.NoPerm: &cYou don't have permission to perform this command.
  
    #Default walk speed and Boosted walk speed
    Pref.Boosted: 20
    Pref.BoostDefault: 0.2
  
    #Stacker not enabled message
    Pref.SelfStacker: &e[&2Stacker&e] &cYour Stacker option is not enabled.
    Pref.TargetStacker: &e[&2Stacker&e] &cTarget's Stacker option is not enabled.
  
    #The items in the GUI for you to enable/disable options
    Pref.EnabledItem: dye:10
    Pref.DisabledItem: dye:8
  
on inventory click:
    if "%inventory name of player's current inventory%" is "{@Pref.GUIname}":
        cancel event
        if name of clicked item is "&aPlayer Visibility Enabled":
            make event-player execute command "/pref visibility"
        else if name of clicked item is "&cPlayer Visibility Disabled":
            make event-player execute command "/pref visibility"
          
        if name of clicked item is "&aStacker Enabled":
            make event-player execute command "/pref stacker"
        else if name of clicked item is "&cStacker Disabled":
            make event-player execute command "/pref stacker"
          
        if name of clicked item is "&aSpeed Boost Enabled":
            make event-player execute command "/pref boost"
        else if name of clicked item is "&cSpeed Boost Disabled":
            make event-player execute command "/pref boost"
          
        if name of clicked item is "&aDouble Jump Enabled":
            make event-player execute command "/pref jump"
        else if name of clicked item is "&cDouble Jump Disabled":
            make event-player execute command "/pref jump"
          
        if name of clicked item is "&aMessage Enabled":
            make event-player execute command "/pref message"
        else if name of clicked item is "&cMessage Disabled":
            make event-player execute command "/pref message"
          
        if name of clicked item is "&c&lReset Preferences":
            make event-player execute command "/pref reset"
      
        if name of clicked item is "&cExit":
            close event-player's inventory

command /pref [<text>] [<text>] [<text>]:
    aliases: /perference, /preferences
    trigger:
        if arg-1 is not set:
            open chest with 6 rows named "{@Pref.GUIname}" to player
            set slot 2 of player's current inventory to clock named "&aPlayer Visibility"
            set slot 4 of player's current inventory to potion:8265 named "&aStacker" with no nbt
            set slot 6 of player's current inventory to sugar named "&aSpeed Boost"
            set slot 29 of player's current inventory to feather named "&aDouble Jump"
            set slot 31 of player's current inventory to paper named "&aPlayer Join Leave Message"
            set slot 49 of player's current inventory to arrow named "&cExit"
            #--------------------#
            #Visibility
            #--------------------#
            if {Pref.Visibility.%event-player%} is not set:
                set slot 11 of player's current inventory to {@Pref.EnabledItem} named "&aPlayer Visibility Enabled"
            else:
                set slot 11 of player's current inventory to {@Pref.DisabledItem} named "&cPlayer Visibility Disabled"
            #--------------------#
            #Stacker
            #--------------------#
            if {Pref.Stacker.%event-player%} is not set:
                set slot 13 of player's current inventory to {@Pref.EnabledItem} named "&aStacker Enabled"
            else:
                set slot 13 of player's current inventory to {@Pref.DisabledItem} named "&cStacker Disabled"
            #--------------------#
            #Boost
            #*Default disable*
            #--------------------#
            if {Pref.Boost.%event-player%} is not set:
                set slot 15 of player's current inventory to {@Pref.DisabledItem} named "&cSpeed Boost Disabled"
            else:
                set slot 15 of player's current inventory to {@Pref.EnabledItem} named "&aSpeed Boost Enabled"
            #--------------------#
            #Double Jump
            #--------------------#
            if {Pref.Jump.%event-player%} is not set:
                set slot 38 of player's current inventory to {@Pref.EnabledItem} named "&aDouble Jump Enabled"
            else:
                set slot 38 of player's current inventory to {@Pref.DisabledItem} named "&cDouble Jump Disabled"
            #--------------------#
            #Join/Leave Message
            #--------------------#
            if {Pref.Message.%event-player%} is not set:
                set slot 40 of player's current inventory to {@Pref.EnabledItem} named "&aMessage Enabled"
            else:
                set slot 40 of player's current inventory to {@Pref.DisabledItem} named "&cMessage Disabled"
            #--------------------#
            #Reset button
            #--------------------#
            set slot 53 of player's current inventory to dye:1 named "&c&lReset Preferences"
#=============
#format again after change
#=============
        if arg-1 is "visibility":
            if arg-2 is not set:
                if {Pref.Visibility.%event-player%} is not set:
                    set {Pref.Visibility.%event-player%} to true
                    set slot 11 of event-player's current inventory to {@Pref.DisabledItem} named "&cPlayer Visibility Disabled"
                    hide all players from event-player
                else:
                    delete {Pref.Visibility.%event-player%}
                    set slot 11 of event-player's current inventory to {@Pref.EnabledItem} named "&aPlayer Visibility Enabled"
                    reveal all players from event-player
            else if event-player has permission "{@Pref.AdminPerm}":
                if {Pref.Visibility.%arg-2%} is set:
                    delete {Pref.Visibility.%arg-2%}
                    message "{@Pref.Prefix} &eYou set %arg-2%'s &bPlayer Visibility &eto &aenable."                 
                else:
                    set {Pref.Visibility.%arg-2%} to true
                    message "{@Pref.Prefix} &eYou set %arg-2%'s &bPlayer Visibility &eto &cdisable."
            else:
                message "{@Pref.NoPerm}"
        if arg-1 is "stacker":
            if arg-2 is not set:
                if {Pref.Stacker.%event-player%} is not set:
                    set {Pref.Stacker.%event-player%} to true
                    set slot 13 of event-player's current inventory to {@Pref.DisabledItem} named "&cStacker Disabled"
                else:
                    delete {Pref.Stacker.%event-player%}
                    set slot 13 of event-player's current inventory to {@Pref.EnabledItem} named "&aStacker Enabled"
            else if event-player has permission "{@Pref.AdminPerm}":
                if {Pref.Stacker.%arg-2%} is set:
                    delete {Pref.Stacker.%arg-2%}
                    message "{@Pref.Prefix} &eYou set %arg-2%'s &bStacker &eto &aenable."
                else:
                    set {Pref.Stacker.%arg-2%} to true
                    message "{@Pref.Prefix} &eYou set %arg-2%'s &bStacker &eto &cdisable."                 
            else:
                message "{@Pref.NoPerm}"
        #default disable
        if arg-1 is "boost":
            if arg-2 is not set:
                if {Pref.Boost.%event-player%} is set:
                    delete {Pref.Boost.%event-player%}
                    set slot 15 of event-player's current inventory to {@Pref.DisabledItem} named "&cSpeed Boost Disabled"
                    set the walk speed of event-player to 0.2
                else:
                    set {Pref.Boost.%event-player%} to true
                    set slot 15 of event-player's current inventory to {@Pref.EnabledItem} named "&aSpeed Boost Enabled"               
                    set the player's walk speed to 20
            else if event-player has permission "{@Pref.AdminPerm}":
                if {Pref.Boost.%arg-2%} is set:
                    delete {Pref.Boost.%arg-2%}
                    message "{@Pref.Prefix} &eYou set %arg-2%'s &bBoost &eto &cdisable."
                    set {_Pref.temp} to arg-2 parsed as player
                    set {_Pref.temp}'s walk speed to 0.2
                else:
                    set {_Pref.temp} to arg-2 parsed as player
                    set {_Pref.temp}'s walk speed to 20
                    set {Pref.Boost.%arg-2%} to true
                    message "{@Pref.Prefix} &eYou set %arg-2%'s &bBoost &eto &aenable."             
            else:
                message "{@Pref.NoPerm}"
        if arg-1 is "jump":
            if arg-2 is not set:
                if {Pref.Jump.%event-player%} is not set:
                    set {Pref.Jump.%event-player%} to true
                    set slot 38 of event-player's current inventory to {@Pref.DisabledItem} named "&cDouble Jump Disabled"
                else:
                    delete {Pref.Jump.%event-player%}
                    set slot 38 of event-player's current inventory to {@Pref.EnabledItem} named "&aDouble Jump Enabled"                 
            else if event-player has permission "{@Pref.AdminPerm}":
                if {Pref.Jump.%arg-2%} is set:
                    delete {Pref.Jump.%arg-2%}
                    message "{@Pref.Prefix} &eYou set %arg-2%'s &bDouble Jump &eto &aenable."
                else:
                    set {Pref.Jump.%arg-2%} to true
                    message "{@Pref.Prefix} &eYou set %arg-2%'s &bDouble Jump &eto &cdisable."
            else:
                message "{@Pref.NoPerm}"
        if arg-1 is "message":
            if arg-2 is not set:
                if {Pref.Message.%event-player%} is not set:
                    set {Pref.Message.%event-player%} to true
                    set slot 40 of event-player's current inventory to {@Pref.DisabledItem} named "&cMessage Disabled"
                else:
                    delete {Pref.Message.%event-player%}
                    set slot 40 of event-player's current inventory to {@Pref.EnabledItem} named "&aMessage Enabled"
            else if event-player has permission "{@Pref.AdminPerm}":
                if {Pref.Message.%arg-2%} is set:
                    delete {Pref.Message.%arg-2%}
                    message "{@Pref.Prefix} &eYou set %arg-2%'s &bJoin/Leave Message &eto &aenable."               
                else:
                    set {Pref.Message.%arg-2%} to true
                    message "{@Pref.Prefix} &eYou set %arg-2%'s &bJoin/Leave Message &eto &cdisable."
            else:
                message "{@Pref.NoPerm}"
        if arg-1 is "reset":
            delete {Pref.Visibility.%event-player%}
            delete {Pref.Boost.%event-player%}
            delete {Pref.Stacker.%event-player%}
            delete {Pref.Jump.%event-player%}
            delete {Pref.Message.%event-player%}
            set the walk speed of event-player to {@Pref.BoostDefault}
            close event-player's inventory
            message "{@Pref.Prefix} &eYour Lobby Preferences menu has been reset."
        if arg-1 is "help":
            message "{@Pref.Prefix}&cAuthor: i998979"
            message "&aCommands:"
            message "&6[Player] can be ommited or replace with player's name."
            message "    &6If it is specified, the commands will apply on that player."
            message "    &6Otherwise, it will apply on your own."
            message "&b/preferences /pref /preference: &9Open the Preferences GUI"
            message "&b/pref visibility [Player]: &9Switch someone's Player Visibility option"
            message "&b/pref stacker [Player]: &9Switch someone's Player Stacker option"
            message "&b/pref boost [Player]: &9Switch someone's Boost option"
            message "&b/pref jump [Player]: &9Switch someone's Double Jump option"
            message "&b/pref message [Player]: &9Switch someone's Join/Leave Message option"
            message "&b/pref reset [Player]: &9Reset someone's option to default"
            message "&b/pref help [Player]: &9Show thie help page"
          
#--------------------#
#Player visibility
#--------------------#
on join:
    if event-player is in world "{@Pref.Enabled}":
        if {Pref.Visibility.%event-player%} is not set:
            reveal all players from event-player
        else:
            hide all players from event-player
#--------------------#
#Stacker
#--------------------#
on right click on player:
    if event-player is in world "{@Pref.Enabled}":
        if {Pref.Stacker.%clicked player%} is not set:
            if {Pref.Stacker.%player%} is not set:
                make clicked player ride event-player
            else:
                message "{@Pref.SelfStacker}" to event-player
        else:
            message "{@Pref.TargetStacker}" to event-player
on left click:
    if event-player is in world "{@Pref.Enabled}":
        dismount passenger from event-player

#--------------------#
#Speed Boost
#--------------------#
on join:
    if event-player is in world "{@Pref.Enabled}":
        if {Pref.Boost.%event-player%} is not set:
            set the walk speed of event-player to {@Pref.BoostDefault}
        else:
            set the player's walk speed to {@Pref.Boosted}

#--------------------#
#Join Leave message
#--------------------#
on join:
    if event-player is in world "{@Pref.Enabled}":
        if {@Pref.HideSysJoin} is true:
            set join message to ""
        loop all players:
            if {Pref.Message.%loop-player%} is not set:
                if event-player is not loop-player:
                    message "{@Pref.MsgJoin}" to loop-player
on quit:
    if event-player is in world "{@Pref.Enabled}":
        if {@Pref.HideSysLeave} is true:
            set leave message to ""
        loop all players:
            if {Pref.Message.%loop-player%} is not set:
                if event-player is not loop-player:
                    message "{@Pref.MsgLeave}" to loop-player
                  
#--------------------#
#Kick Death message hide
#--------------------#
on kick:
    if event-player is in world "{@Pref.Enabled}":
        if {@Pref.KickMsgHide} is true:
            set kick message to ""
on death:
    if event-player is in world "{@Pref.Enabled}":
        if {@Pref.DeathMsgHide} is true:
            set death message to ""
 
Last edited:
Actually, this would be more easy if you're using the config sql option.
Just define a prefix and change any variable the variables.
 
Actually, this would be more easy if you're using the config sql option.
Just define a prefix and change any variable the variables.
Config sql? What do you mean?
I enabled MySQL in Skript and downloaded the Skript SQL jar.

Define a prefix? What do you mean?
Sorry... I'm a noob. :emoji_frowning:
 
Open your script config which is located in plugins\Skript\config.sk

Look for this code:
code_language.skript:
MySQL example:
        # A MySQL database example, with options unrelated to MySQL removed.
        
        type: disabled # change to line below to enable this database
        # type: MySQL
        
        pattern: synced_.* # this pattern will save all variables that start with 'synced_' in this MySQL database.
        
        host: localhost
        port: 3306
        user: root
        password: pass
        database: skript
        
        monitor changes: true
        monitor interval: 20 seconds

Change to:
code_language.skript:
MySQL example:
        # A MySQL database example, with options unrelated to MySQL removed.
        
        type: MySQL
        
        pattern: sql_.*
        
        host: YOURHOST
        port: 3306
        user: YOURUSER
        password: YOURPASS
        database: Skript
        
        monitor changes: true
        monitor interval: 20 seconds

Later, you have to change the names of the variables, for example:
code_language.skript:
{normalvariable::%player%}
to
{sql_.normalvariable::%player%}
 
Okay, thanks it works now. I need help with your Eco script now!
I changed your command a little bit:

code_language.skript:
command /moneyset [<offline player>] [<number>]:
    permission: money.set
    permission message: &cNo permission.
    trigger:
        set {_player} to "%player%"
        arg 1 is set:
            arg 2 is set:
                if arg 1 is online:
                    if arg 1 is {_player}:
                        send "&cYou can't change the amount of money you have."
                        stop
                {@run_async} is "true":
                    $ thread
                set {_message} to addCoins(arg 1, arg 2, 1)
                send "%{_message}%"
            else:
                send "&cWrong usage."
        else:
            send "&cWrong usage."

And it doesn't work. Can you please help me. Lol
 
Okay, thanks it works now. I need help with your Eco script now!
I changed your command a little bit:

code_language.skript:
command /moneyset [<offline player>] [<number>]:
    permission: money.set
    permission message: &cNo permission.
    trigger:
        set {_player} to "%player%"
        arg 1 is set:
            arg 2 is set:
                if arg 1 is online:
                    if arg 1 is {_player}:
                        send "&cYou can't change the amount of money you have."
                        stop
                {@run_async} is "true":
                    $ thread
                set {_message} to addCoins(arg 1, arg 2, 1)
                send "%{_message}%"
            else:
                send "&cWrong usage."
        else:
            send "&cWrong usage."

And it doesn't work. Can you please help me. Lol
I don't know what is not working in your changes because i tested it and it's working, but i think you need to do this
Code:
if "%arg 1%" is "%{_player}%"
instead of
Code:
if arg 1 is {_player}
 
code_language.skript:
command /moneyset [<offline player>] [<number>]:
    permission: money.set
    permission message: &cNo permission.
    trigger:
        if arg 1 is set:
            if arg 2 is set:
                if arg 1 is online:
                    if arg 1 is player:
                        send "&cYou can't change the amount of money you have."
                        stop
                if {@run_async} is "true":
                    $ thread
                set {_message} to addCoins(arg 1, arg 2, 1)
                send "%{_message}%"
            else:
                send "&cWrong usage."
        else:
            send "&cWrong usage."
 
  • Like
Reactions: HiiqhFive
Code:
command /moneyset [<offline player>] [<number>]:
    permission: money.set
    permission message: &cNo permission.
    trigger:
        arg 1 is set:
            arg 2 is set:
                if arg 1 is online:
                    if arg 1 is player:
                        send "&cYou can't change the amount of money you have."
                        stop
                else:
                    send "%arg-1% is not online"
                {@run_async} is "true":
                    $ thread
                set {_message} to addCoins(arg 1, arg 2, 1)
                send "%{_message}%"
            else:
                send "&cWrong usage."
        else:
            send "&cWrong usage."
 
Code:
command /moneyset [<offline player>] [<number>]:
    permission: money.set
    permission message: &cNo permission.
    trigger:
        arg 1 is set:
            arg 2 is set:
                if arg 1 is online:
                    if arg 1 is player:
                        send "&cYou can't change the amount of money you have."
                        stop
                else:
                    send "%arg-1% is not online"
                {@run_async} is "true":
                    $ thread
                set {_message} to addCoins(arg 1, arg 2, 1)
                send "%{_message}%"
            else:
                send "&cWrong usage."
        else:
            send "&cWrong usage."
thanks
 
Status
Not open for further replies.