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

Skellett - See the MySQL currency with a command

Discussion in 'Skript' started by bombrider130, Jun 11, 2018.

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

    bombrider130 Member

    Joined:
    Dec 26, 2017
    Messages:
    1
    Likes Received:
    0
    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 (Text):
    1.  (Skript):
    2. [LIST=1]
    3. [*]
    4.  
    5. [*]on load:
    6. [*]    set mysql host to "localhost"
    7. [*]    set mysql username to "root"
    8. [*]    set mysql password to "mypass"
    9. [*]    set mysql database to "testcoins"
    10. [*]    connect to mysql
    11. [*]
    12.  
    13. [*]on join:
    14. [*]    set {_result} to mysql result of query "SELECT * FROM players WHERE `uuid` = '%uuid of player%'"
    15. [*]    set {_name::*} to mysql string "name" in {_result}
    16. [*]    if {_name::1} is set:
    17. [*]        mysql update "UPDATE `players` SET `name` = '%name of player%', `ip` = '%ip of player%', `last_seen` = '%now%' WHERE `uuid` = '%UUID of player%'"
    18. [*]    else:
    19. [*]        mysql update "INSERT INTO `players` (`name`, `uuid`, `ip`, `last_seen`) VALUES ('%name of player%', '%UUID of player%', 0, '%ip of player%', '%now%')"
    20. [*]
    21.  
    22. [*]function addCoins(player: player, number: number):
    23. [*]    set {_result} to mysql result of query "SELECT * FROM players WHERE `uuid` = '%uuid of {_player}%'"
    24. [*]    set {_name::*} to mysql string "name" in {_result}
    25. [*]    if {_name::1} is set:
    26. [*]        mysql update "UPDATE `players` SET `coins` = coins + %{_number}% WHERE `uuid` = '%UUID of {_player}%'"
    27. [*]
    28.  
    29. [*]command /addcoin <offline player> <number>:
    30. [*]    trigger:
    31. [*]        addCoins(arg-1, arg-2)
    32. [*]        broadcast "[&8Coins&f] &7They have been added: &e%arg 2% &7Coin/s for &a%players%"
    33. [*]    
    34. [*]function resetCoins(player: player):
    35. [*]    set {_result} to mysql result of query "SELECT * FROM players WHERE `uuid` = '%uuid of {_player}%'"
    36. [*]    set {_name::*} to mysql string "name" in {_result}
    37. [*]    if {_name::1} is set:
    38. [*]        mysql update "UPDATE`players` SET `coins` = coins = 0 WHERE `uuid` = '%UUID of {_player}%'"
    39. [*]    
    40. [*]command /resetcoin <offline player>:
    41. [*]    trigger:
    42. [*]        resetCoins(arg-1)
    43. [*]        broadcast "[&8Coins&f] &7All the Coin/s has been reseted for  &a%players%"
    44. [*]    
    45. [*]function leaveCoins(player: player, number: number):
    46. [*]    set {_result} to mysql result of query "SELECT * FROM players WHERE `uuid` = '%uuid of {_player}%'"
    47. [*]    set {_name::*} to mysql string "name" in {_result}
    48. [*]    if {_name::1} is set:
    49. [*]        mysql update "UPDATE`players` SET `coins` = coins - %{_number}% WHERE `uuid` = '%UUID of {_player}%'"
    50. [*]    
    51. [*]command /leavecoin <offline player> <number>:
    52. [*]    trigger:
    53. [*]        leaveCoins(arg-1, arg-2)
    54. [*]        broadcast "[&8Coins&f] &7They have been removed: &e%arg 2% &7Coin/s from &a%players%"    
    55. [*]    
    56. [*]#? how can I do      
    57. [*]function checkCoins() :
    58. [*]
    59.  
    60. [*]    
    61. [*]command /coin <offline player>:
    62. [*]    trigger:
    63. [*]
    [/LIST]
     
Thread Status:
Not open for further replies.

Share This Page

Loading...