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

bombrider130

Member
Dec 26, 2017
1
0
1
24
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.

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:
[*]
[/LIST]
 
Status
Not open for further replies.