Hello, I've just been using skript, I'm learning how to use skellett. I want to create a money system. I managed to add some money to MySql thanks to a command, but I want to create a command where I can see how much money I have, then export the value from MySql and show it on minecraft.
[/LIST]
Code:
(Skript):
[LIST=1]
[*]
[*]on load:
[*] set mysql host to "localhost"
[*] set mysql username to "root"
[*] set mysql password to "mypass"
[*] set mysql database to "testcoins"
[*] connect to mysql
[*]
[*]on join:
[*] set {_result} to mysql result of query "SELECT * FROM players WHERE `uuid` = '%uuid of player%'"
[*] set {_name::*} to mysql string "name" in {_result}
[*] if {_name::1} is set:
[*] mysql update "UPDATE `players` SET `name` = '%name of player%', `ip` = '%ip of player%', `last_seen` = '%now%' WHERE `uuid` = '%UUID of player%'"
[*] else:
[*] mysql update "INSERT INTO `players` (`name`, `uuid`, `ip`, `last_seen`) VALUES ('%name of player%', '%UUID of player%', 0, '%ip of player%', '%now%')"
[*]
[*]function addCoins(player: player, number: number):
[*] set {_result} to mysql result of query "SELECT * FROM players WHERE `uuid` = '%uuid of {_player}%'"
[*] set {_name::*} to mysql string "name" in {_result}
[*] if {_name::1} is set:
[*] mysql update "UPDATE `players` SET `coins` = coins + %{_number}% WHERE `uuid` = '%UUID of {_player}%'"
[*]
[*]command /addcoin <offline player> <number>:
[*] trigger:
[*] addCoins(arg-1, arg-2)
[*] broadcast "[&8Coins&f] &7They have been added: &e%arg 2% &7Coin/s for &a%players%"
[*]
[*]function resetCoins(player: player):
[*] set {_result} to mysql result of query "SELECT * FROM players WHERE `uuid` = '%uuid of {_player}%'"
[*] set {_name::*} to mysql string "name" in {_result}
[*] if {_name::1} is set:
[*] mysql update "UPDATE`players` SET `coins` = coins = 0 WHERE `uuid` = '%UUID of {_player}%'"
[*]
[*]command /resetcoin <offline player>:
[*] trigger:
[*] resetCoins(arg-1)
[*] broadcast "[&8Coins&f] &7All the Coin/s has been reseted for &a%players%"
[*]
[*]function leaveCoins(player: player, number: number):
[*] set {_result} to mysql result of query "SELECT * FROM players WHERE `uuid` = '%uuid of {_player}%'"
[*] set {_name::*} to mysql string "name" in {_result}
[*] if {_name::1} is set:
[*] mysql update "UPDATE`players` SET `coins` = coins - %{_number}% WHERE `uuid` = '%UUID of {_player}%'"
[*]
[*]command /leavecoin <offline player> <number>:
[*] trigger:
[*] leaveCoins(arg-1, arg-2)
[*] broadcast "[&8Coins&f] &7They have been removed: &e%arg 2% &7Coin/s from &a%players%"
[*]
[*]#? how can I do
[*]function checkCoins() :
[*]
[*]
[*]command /coin <offline player>:
[*] trigger:
[*]