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!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Addon skript-db 0.2.0

Sensible SQL support for Skript

  1. mel_instagibson

    Joined:
    Feb 4, 2017
    Messages:
    71
    Likes Received:
    4
    So i had this working with skellett's syntax but i'm running into an (expected) issue now ith skript-db
    Code (Skript):
    1.  
    2. command /isonline <string>:
    3.         permission: *
    4.         trigger:
    5.                 send "%isonline(arg-1)%"
    6.  
    7. function isonline(p: string) :: boolean:
    8.         execute "SELECT server FROM playerdata.status WHERE ign='%{_p}%' and (faction=true or safe=true or vanilla=true or lobby=true)" in {playerdatadb} and store result in {_r}
    9.         if {_r} is set:
    10.                 return true
    11.         else:
    12.                 return false
    13.  
    It now throws this:

    A return statement after a delay is useless, as the calling trigger will resume when the delay starts (and won't get any returned value) (duel.sk, line 17: return false')

    is there not a way to wait for the database to complete the request in functions like it was possible with skellett?

    EDIT:
    Oh, and i also get the error mentioned above using mariadb :emoji_frowning:
    http://www.paste.org/88803
    my max connections are set to 151. After i encounter that error the database becomes unaccessible for all other things too, i had to stop the minecraft server to free up connections again.

    EDIT2:
    tl;dr basically the issues of the 2 people before me
     
    #21 mel_instagibson, Dec 1, 2017
    Last edited: Dec 1, 2017
  2. Pikachu

    Moderator Supporter Addon Developer

    Joined:
    Jan 25, 2017
    Messages:
    871
    Likes Received:
    125
    Medals:
    The first issue isn't an issue. Skellett should not have functioned the way it does, only because its done badly can it be used in functions. You can use skquery functions if you would like to have a wait or other asynchronous effect and still return a value. Why are you even using sql to detect if someone is online?
     
  3. mel_instagibson

    Joined:
    Feb 4, 2017
    Messages:
    71
    Likes Received:
    4
    yeah i know, i was a bit surprised when skellett worked like that out of the box but it was really handy and performed well. as a skript user i dont see a reason to moan about (hacky) workarounds, thats its primary use anyways :emoji_stuck_out_tongue:.
    because i want to improve my knowledge about databases and their syntaxes,
    also thats just an example.

    hmm i tried doing it with skq functions but it didnt get me too far...
     
  4. pepper82

    pepper82 Member

    Joined:
    Jan 26, 2017
    Messages:
    239
    Likes Received:
    1
    I really don't know but I hope for a hotfix to make my mysql scripts work :emoji_slight_smile:

    @btk5h : any ideas, yet?
     
  5. Snow-Pyon

    Moderator Resource Staff

    Joined:
    Jan 25, 2017
    Messages:
    1,233
    Likes Received:
    172
    Medals:
    I doubt it worked with Skellet to be honest, I'm sure it returned old values from the former call of the function instead of returning the actual value, just because how Skript works.

    And skQ functions aren't hard to learn, it's just declaring the function:

    Code (Skript):
    1. func "isOnline":
    Run your code, for example:

    Code (Skript):
    1. func "isOnline":
    2.  
    3.   set {_player} to parameter 1
    4.   execute "SELECT server FROM playerdata.status WHERE ign='%{_player}%' and (faction=true or safe=true or vanilla=true or lobby=true)" in {playerdatadb} and store result in {_r}
    then using the access pragma to access the variable with a transient object:

    Code (Skript):
    1. func "isOnline":
    2.  
    3.   set {_player} to parameter 1
    4.   execute "SELECT server FROM playerdata.status WHERE ign='%{_player}%' and (faction=true or safe=true or vanilla=true or lobby=true)" in {playerdatadb} and store result in {_r}
    5.  
    6.   #you need use a transient object so the value gets passed correctly
    7.   set transient "output" to {_r} != null
    8.  
    9.   $ access #this is called access pragma
    10.   set {_isOnline} to transient "output"
    And lastly, return so skQuery knows when you want return the value:

    Code (Skript):
    1. func "isOnline":
    2.  
    3.   set {_player} to parameter 1
    4.   execute "SELECT server FROM playerdata.status WHERE ign='%{_player}%' and (faction=true or safe=true or vanilla=true or lobby=true)" in {playerdatadb} and store result in {_r}
    5.  
    6.   #you need use a transient object so the value gets passed correctly
    7.   set transient "output" to {_r} != null
    8.  
    9.   $ access #this is called access pragma
    10.   set {_isOnline} to transient "output"
    11.   return
    Now, you just have to access it:

    Code (Skript):
    1. command /isonline <string>:
    2.   permission: *
    3.   trigger:
    4.    
    5.     access "isOnline" from arg-1
    6.     send "%{_isOnline}%"
     
    • Useful Useful x 2
    • Like Like x 1
  6. mel_instagibson

    Joined:
    Feb 4, 2017
    Messages:
    71
    Likes Received:
    4
    wow, this should be in the docs

    awesome explanation, thank you
     
  7. Pikachu

    Moderator Supporter Addon Developer

    Joined:
    Jan 25, 2017
    Messages:
    871
    Likes Received:
    125
    Medals:
    There is or at least was a doc page on it
     
  8. ayoungcoder

    ayoungcoder Member

    Joined:
    Aug 23, 2017
    Messages:
    17
    Likes Received:
    0
    im trying to get the value of the field tokens but if i do

    Code (Skript):
    1.         execute "SELECT Tokens FROM Users WHERE Name='l'" in {sql} and store the result in {output::*}
    2.         broadcast "SELECT Tokens FROM Users WHERE Name='l'"
    3.         loop {output::*}:
    4.             broadcast loop-value
    5.         broadcast "%{output::*}%"
    i get Tokens instead of the desired value
     
  9. btk5h

    Addon Developer

    Joined:
    Jan 25, 2017
    Messages:
    154
    Likes Received:
    155
    The first layer of the list variable contains the names of the columns. You want to loop through the second layer, or {output::Tokens::*}
     
  10. ayoungcoder

    ayoungcoder Member

    Joined:
    Aug 23, 2017
    Messages:
    17
    Likes Received:
    0
    t
    hanks
     
  11. pepper82

    pepper82 Member

    Joined:
    Jan 26, 2017
    Messages:
    239
    Likes Received:
    1
    Any update on the issue with mariadb ?
     
    • Like Like x 1
  12. wokka

    wokka Member

    Joined:
    Nov 29, 2017
    Messages:
    3
    Likes Received:
    0
    I'm having the same issue as pepper82 and the others, when this skript gets loaded: https://gist.github.com/wokka1/b83a1494d5dc466d96bde204d5e4dad4 it creates 10 connections to mysql, from looking at show processlist at the console. If I reload the skript after an edit, it doesn't close those 10, but opens 10 more. They do not seem to close until you stop the minecraft server.

    It's possible I have something in my code wrong, I'm not a programmer.

    Also, my select statement works fine in the mysql console, but I'm getting "
    set Invalid argument value: java.io.NotSerializableException to last database error" output via the last sql error statement.

    This is running paperclip b1264, latest skript dev32c, skRayFall and skUtilities addons, plus several spigot/bukkit plugins. I can give you that list if needed for troubleshooting.

    Thanks
     
  13. Spartan9802

    Spartan9802 Member

    Joined:
    Jan 26, 2017
    Messages:
    158
    Likes Received:
    8
    Good evening,
    Can you give me an example?
    [​IMG]
     
  14. wokka

    wokka Member

    Joined:
    Nov 29, 2017
    Messages:
    3
    Likes Received:
    0
    @btk5h would you prefer we open up issues on github for you on these reports or is this forum the best/easiest way for you?
     
  15. btk5h

    Addon Developer

    Joined:
    Jan 25, 2017
    Messages:
    154
    Likes Received:
    155
    I would prefer if you guys created Github issues since they're a lot easier to track. I'll try to remember any issues brought up on the forums, but there's always the chance I'll forget.
     
  16. wokka

    wokka Member

    Joined:
    Nov 29, 2017
    Messages:
    3
    Likes Received:
    0
  17. T

    Tai1er Member

    Joined:
    Jan 30, 2017
    Messages:
    6
    Likes Received:
    0
    Hi, :emoji_slight_smile:
    Does Skript-db support NVAR?
    I have problem with this for exemple:

    set {_id} to "♂"
    execute "INSERT INTO Table(`id`) VALUES (%{_id}%)" in {sql}

    I get "?".
     
  18. pepper82

    pepper82 Member

    Joined:
    Jan 26, 2017
    Messages:
    239
    Likes Received:
    1
    How can you list all the values you receive from SELECT query in one row?

    Example:
    execute "SELECT spieler,grund,strafe,moderator,datum,jailname FROM {@jail_table} WHERE spieler = %{_warnplayer}% AND strafe = 'WARNING'" in {sql} and store the result in {_output::*}

    Now I want to list all the results in this format:
    PLAYER: ABC - GRUND: ABC etc.
    PLAYER: ABC - GRUND: ABC etc.
    etc.
     
    #38 pepper82, Jan 4, 2018
    Last edited: Jan 4, 2018
  19. btk5h

    Addon Developer

    Joined:
    Jan 25, 2017
    Messages:
    154
    Likes Received:
    155
    Entries in the same row share the same loop-index.
    Code (Skript):
    1. execute "SELECT spieler,grund,strafe,moderator,datum,jailname FROM {@jail_table} WHERE spieler = %{_warnplayer}% AND strafe = 'WARNING'" in {sql} and store the result in {_output::*}
    2. loop {_output::spieler::*}:
    3.   message "%loop-value% - %{_output::grund::%loop-index%}%"
     
    • Like Like x 1
  20. Spartan9802

    Spartan9802 Member

    Joined:
    Jan 26, 2017
    Messages:
    158
    Likes Received:
    8
    Hello,
    I have error :/
    Code (Skript):
    1. HikariPool-1 - Driver does not support get/set network timeout for connections. (com.mysql.jdbc.JDBC4Connection.getNetworkTimeout()I)
    Edit: After two or three requests my mysql is blocked and also blocks access with phpmyadmin.
    Edit: I found, the connections are not closed at each reload, could you add an effect to close a connection to the database?
     
    #40 Spartan9802, Jan 12, 2018
    Last edited: Jan 12, 2018
Loading...