1. 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!

  2. LOOKING FOR A VERSION OF SKRIPT??:

    You can always check our our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Getting values from MySQL database

Discussion in 'Skript' started by _Proxxxy_, Apr 17, 2017.

Thread Status:
Not open for further replies.
  1. _Proxxxy_

    _Proxxxy_ Member

    Joined:
    Apr 14, 2017
    Messages:
    1
    Likes Received:
    0
    Hi all,
    I have been using skript for a couple months. Right now I have a plugin that is storing player data in a MySQL database. I'm trying to use Skellet in order to retrieve players data and use it for other commands. However there aren't many examples of how to do this out there, and I'm new to MySQL and coding. This is also my first forum post.

    I want to write a skript where players can access their account balance. Right now that is stored in the database 'minigame', the table 'players' and the column 'balance.' The table 'players' also has the columns 'UUID' and 'NAME'.

    So something like:

    command /bal:
    trigger:
    set {_playername} to player
    set mysql host to "somehost"
    set mysql username to "someusername"
    set mysql password to "somepassword"
    set mysql database to "minigame"
    connect to mysql
    set {_result} to mysql result of query "SELECT * FROM players WHERE NAME="%{_playername}%" "
    set {_balance} to integer in {_result}
    send "%{_balance}% is your balance" to player

    Thanks in advance for any help you can provide!
     
Thread Status:
Not open for further replies.
Loading...