Getting values from MySQL database

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

_Proxxxy_

Member
Apr 14, 2017
1
0
0
34
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!
 
Status
Not open for further replies.