Solved Making a simple SQL script that will save player names

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

xdprojosh1

Member
May 31, 2017
23
0
0
25
Category: SQL/Skript/MySQL

Suggested name: SaveNames

What I want:
A simple, easy to use script that will save player names to the database, and uuids when the player joins. @HiiqhFive :emoji_slight_smile:

Ideas for commands:
No Commands

Ideas for permissions:
No Permissions

When I'd like it by: Today
 
code_language.skript:
on join:
    if {SAVEDATA::%uuid of player%::%player%} is not set:
        loop {SAVEDATA::%uuid of player%::*}:
            set {SAVEDATA::%uuid of player%::%loop-index%} to false
        set {SAVEDATA::%uuid of player%::%player%} to true
   
command /Database [<offline player>]:
    trigger:
        if arg-1 is set:
            set {_UUID} to uuid of arg-1
            loop {SAVEDATA::%{_UUID}%::*}:
                if loop-value is true:
                    send "Currently Name: %loop-index%"
                else:
                     send "Called before: %loop-index%"
 
I just skripted this simple thinks, i was think maybe you know with mysql? So just change a little...


i have 0 plan about mysql. so i can't help you
 
  • Like
Reactions: xdprojosh1
Right now this is what i have

But when a player joins, it changes my name and uuid in the database to their name and uuid.
@HiiqhFive Maybe you could help me?
code_language.skript:
on join:
    update "UPDATE data SET `username` = '%player%'"

code_language.skript:
on first join:
    update "INSERT INTO data (`username`, `uuid`) VALUES ('%player%', '%uuid of player%',)"
[doublepost=1496542796,1496536174][/doublepost]Solved.
 
code_language.skript:
script options:
    $ db url jdbc:mysql:/HOST:3306/DATABASE
    $ db username NAME
    $ db password PASS

on first join:
    $ thread # async, advisable for sql syntaxes.
    update "INSERT INTO `data` (`username`,`uuid`) VALUES (`%player%`, `%player's uuid%`)"

on join:
    $ thread
    update "UPDATE `data` SET `username`='%player%' WHERE `uuid`='%player's uuid%'"