Help with MySQL

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

Status
Not open for further replies.

Lukhausen

Active Member
Mar 20, 2017
145
11
18
Hey I'm new to MySQL :emoji_wink: i need this because im creating a coins system for my bungee network. but i don't know anything.. pls help :emoji_slight_smile: may there is someone who has the time to explain. These codes I found in the forums:
code_language.skript:
on script load:
    set mysql host to "localhost"
    set mysql username to "Skript"
    set mysql password to "rNJ0DBfO7go4loq2"
    set mysql database to "Skript"
    connect to mysql
    set {_test} to mysql result of query "SELECT * FROM Customers, Example"
    set {_final} to mysql string "Customers" in {_test}
    set {_final2} to mysql integer "Example" in {_test}
    broadcast "%{_final}% and %{_final2}%"
I found this in HiiqhFive coins.sk but i dont understand anything...
code_language.skript:
update "CREATE TABLE IF NOT EXISTS `language` (`uuid` varchar(255), `amount` float(20))"
update "ALTER table `cash` ADD id int NOT NULL AUTO_INCREMENT primary key FIRST"
update "ALTER table `cash` ADD UNIQUE (id, uuid)"
[doublepost=1494300682,1494256409][/doublepost]
Hey im new to MySQL :emoji_wink: i need this because im creating a coins system for my bungee network. but i don't know anything.. pls help :emoji_slight_smile:
code_language.skript:
on script load:
    set mysql host to "localhost"
    set mysql username to "Skript"
    set mysql password to "rNJ0DBfO7go4loq2"
    set mysql database to "Skript"
    connect to mysql
    set {_test} to mysql result of query "SELECT * FROM Customers, Example"
    set {_final} to mysql string "Customers" in {_test}
    set {_final2} to mysql integer "Example" in {_test}
    broadcast "%{_final}% and %{_final2}%"
I found this in HiiqhFive coins.sk but i dont understand anything...
code_language.skript:
update "CREATE TABLE IF NOT EXISTS `language` (`uuid` varchar(255), `amount` float(20))"
update "ALTER table `cash` ADD id int NOT NULL AUTO_INCREMENT primary key FIRST"
update "ALTER table `cash` ADD UNIQUE (id, uuid)"
Does anyone have a clue how to use this stuff?
[doublepost=1494414693][/doublepost]
Hey I'm new to MySQL :emoji_wink: i need this because im creating a coins system for my bungee network. but i don't know anything.. pls help :emoji_slight_smile: may there is someone who has the time to explain. These codes I found in the forums:
code_language.skript:
on script load:
    set mysql host to "localhost"
    set mysql username to "Skript"
    set mysql password to "rNJ0DBfO7go4loq2"
    set mysql database to "Skript"
    connect to mysql
    set {_test} to mysql result of query "SELECT * FROM Customers, Example"
    set {_final} to mysql string "Customers" in {_test}
    set {_final2} to mysql integer "Example" in {_test}
    broadcast "%{_final}% and %{_final2}%"
I found this in HiiqhFive coins.sk but i dont understand anything...
code_language.skript:
update "CREATE TABLE IF NOT EXISTS `language` (`uuid` varchar(255), `amount` float(20))"
update "ALTER table `cash` ADD id int NOT NULL AUTO_INCREMENT primary key FIRST"
update "ALTER table `cash` ADD UNIQUE (id, uuid)"
[doublepost=1494300682,1494256409][/doublepost]
Does anyone have a clue how to use this stuff?
:emoji_confounded:
[doublepost=1494559494][/doublepost]Is there any idea?
 
I will get you some examples 1 sec...
[doublepost=1494560569,1494559693][/doublepost]Here you go

code_language.skript:
#Options (fix them to your needs)
script options:
    $ db url jdbc:mysql://localhost:3306/Skript
    $ db username root
    $ db password password

#Load Code:
on load:
    update "CREATE TABLE IF NOT EXISTS `coindata` ( `id` INT NULL DEFAULT NULL AUTO_INCREMENT , `uuid` VARCHAR(30) NOT NULL , `coins` VARCHAR(30) NOT NULL ,  UNIQUE (`id`)) ENGINE = InnoDB;"

#Join Code
on join:
    If {coins.firstjoin.%uuid of player%} is not set:
        update "INSERT INTO `coindata` (`uuid`, `coins`) VALUES ('%uuid of player%', '0')"
        set {coins.firstjoin.%uuid of player%} to true

#To change player's coin amount:
command /setcoin <number>:
    trigger:
        update "UPDATE `coindata` SET `coins` = '%arg-1%' WHERE `coindata`.`uuid` = '%uuid of player%'"
 
I will get you some examples 1 sec...
[doublepost=1494560569,1494559693][/doublepost]Here you go

code_language.skript:
#Options (fix them to your needs)
script options:
    $ db url jdbc:mysql://localhost:3306/Skript
    $ db username root
    $ db password password

#Load Code:
on load:
    update "CREATE TABLE IF NOT EXISTS `coindata` ( `id` INT NULL DEFAULT NULL AUTO_INCREMENT , `uuid` VARCHAR(30) NOT NULL , `coins` VARCHAR(30) NOT NULL ,  UNIQUE (`id`)) ENGINE = InnoDB;"

#Join Code
on join:
    If {coins.firstjoin.%uuid of player%} is not set:
        update "INSERT INTO `coindata` (`uuid`, `coins`) VALUES ('%uuid of player%', '0')"
        set {coins.firstjoin.%uuid of player%} to true

#To change player's coin amount:
command /setcoin <number>:
    trigger:
        update "UPDATE `coindata` SET `coins` = '%arg-1%' WHERE `coindata`.`uuid` = '%uuid of player%'"
What should I put in data base url?
I've created a database named skript and ist the URL of it just that that you posted?
 
I will get you some examples 1 sec...
[doublepost=1494560569,1494559693][/doublepost]Here you go

code_language.skript:
#Options (fix them to your needs)
script options:
    $ db url jdbc:mysql://localhost:3306/Skript
    $ db username root
    $ db password password

#Load Code:
on load:
    update "CREATE TABLE IF NOT EXISTS `coindata` ( `id` INT NULL DEFAULT NULL AUTO_INCREMENT , `uuid` VARCHAR(30) NOT NULL , `coins` VARCHAR(30) NOT NULL ,  UNIQUE (`id`)) ENGINE = InnoDB;"

#Join Code
on join:
    If {coins.firstjoin.%uuid of player%} is not set:
        update "INSERT INTO `coindata` (`uuid`, `coins`) VALUES ('%uuid of player%', '0')"
        set {coins.firstjoin.%uuid of player%} to true

#To change player's coin amount:
command /setcoin <number>:
    trigger:
        update "UPDATE `coindata` SET `coins` = '%arg-1%' WHERE `coindata`.`uuid` = '%uuid of player%'"
And how can I show the money of a player in the chat?
 
code_language.skript:
command /getcoins:
    set {_coins::*} to objects in column "coins" from result of query "SELECT * FROM `coindata` WHERE `coindata`.`uuid` = '%uuid of player%"
    send "%{_coins::1}%"
 
Status
Not open for further replies.