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

    L0v0lup Member

    Joined:
    Feb 19, 2017
    Messages:
    16
    Likes Received:
    2
    Hello, i've found a strange bug what is probably caused by skript-db.
    Whenever i use the line 3, i cant get the %event-block% anymore. It always tells me "air".
    Code (Skript):
    1. on break:
    2.     set {_sk_ID} to "%x-coord of event-block%,%y-coord of event-block%,%z-coord of event-block%"
    3.     execute "SELECT * FROM `SkriptJobs` WHERE `sk_ID` = '%unsafe {_sk_ID}%'" in {sql} and store result in {_output::*}
    4. event-block%,%z-coord of event-block%'"
    5.    send "%event-block%"
    You might think now; Just store the event-block in a local variable?
    Code (Skript):
    1. set {_block} to event-block
    That works only for a moment and i'm getting the right block-type. But (!) when placed after line 3 it tells me again "Air". Is skript-db affecting variables? It seems like they are getting changed when i use that line.

    Do you have any idea why this happens?
     
  2. T

    TheRazorGod Member

    Joined:
    Jun 9, 2018
    Messages:
    17
    Likes Received:
    0
    Code (Skript):
    1.         execute "UPDATE nickname SET nick='%arg 1%' WHERE player_name='%name of player%'" in {sql}
    Although I wrote this code, it does not work. How can do it?
     
  3. btk5h

    Addon Developer

    Joined:
    Jan 25, 2017
    Messages:
    154
    Likes Received:
    155
    Did you try setting the variable to type of event-block instead?

    This is not a bug. Skript's event-block refers to the live state of the block, not a snapshot of the block when the event was dispatched. You can see this by replacing the query with a delay.
    When you embed variables in a query, do not surround it in quotes.
     
    • Like Like x 2
  4. L0v0lup

    L0v0lup Member

    Joined:
    Feb 19, 2017
    Messages:
    16
    Likes Received:
    2
    Thanks for the reply :emoji_slight_smile:
    I found a solution:
    set {_block} to "%event-block%" parsed as item type
     
  5. T

    TheRazorGod Member

    Joined:
    Jun 9, 2018
    Messages:
    17
    Likes Received:
    0
    Code (Skript):
    1. command /ap-update <text>:
    2.     trigger:
    3.         broadcast "UPDATE nickname SET balance=%balance of arg 1% WHERE playername=%arg 1%"
    4.         execute "UPDATE nickname SET balance=%balance of arg 1% WHERE playername=%arg 1%" in {sql}
    This code don't work. How can fix this?
    --- Double Post Merged, Jun 21, 2018, Original Post Date: Jun 20, 2018 ---
    Can someone help me?
     
  6. btk5h

    Addon Developer

    Joined:
    Jan 25, 2017
    Messages:
    154
    Likes Received:
    155
    Please post whatever errors you're getting.
     
  7. T

    TheRazorGod Member

    Joined:
    Jun 9, 2018
    Messages:
    17
    Likes Received:
    0
    It's not a error. It doesn't update in his database.
     
  8. btk5h

    Addon Developer

    Joined:
    Jan 25, 2017
    Messages:
    154
    Likes Received:
    155
    There's nothing in last sql error?
     
  9. T

    TheRazorGod Member

    Joined:
    Jun 9, 2018
    Messages:
    17
    Likes Received:
    0
    I found the problem.

    This code run:
    Code (Skript):
    1. command /ap-update <text>:
    2.     trigger:
    3.         execute "UPDATE nickname SET balance='100' WHERE playername=%arg 1%" in {sql}
    But if I do "% balance of arg 1%", it does not work.
     
  10. L0v0lup

    L0v0lup Member

    Joined:
    Feb 19, 2017
    Messages:
    16
    Likes Received:
    2
    Hey, sorry its me again with the same problem :/
    It seems like the new Skript dev37 Update has broken the option to use local variables with skript-db completley.

    Code (Skript):
    1. set {_x} to "%x-coord of event-block%"
    2. set {_y} to "%y-coord of event-block%"
    3. set {_z} to "%z-coord of event-block%"
    4. set {_world} to "%event-world%" parsed as text
    5. execute "SELECT * FROM SkriptJobs WHERE X=%{_x}% and (Y=%{_y}% and Z=%{_z}% and World=%{_World}%)" in {sql} and store result in {_output}
    (Not working - none of the local variables are usable, it only works with standard variable, which would produce a massiv variable.csv) - But that worked in Skript dev36 :emoji_astonished:

    I have also tried to use after the "Select":
    Code (Skript):
    1. set {_block} to "%event-block%" parsed as item type
    2. #Or
    3. %type of event-block%
    which arent working anymore on Skript dev37+ :emoji_frowning:
    Is there a way you can fix that? I kinda works with Skellett but that isnt an option for me, since its Skellett's mysql strings are not working.
     
  11. btk5h

    Addon Developer

    Joined:
    Jan 25, 2017
    Messages:
    154
    Likes Received:
    155
    Are you getting any errors?
     
  12. L0v0lup

    L0v0lup Member

    Joined:
    Feb 19, 2017
    Messages:
    16
    Likes Received:
    2
    Yes, it basically say's that the variables are empty.
    [​IMG]
    Also, every other used local variables are empty after i use "execute "SELECT * FROM (...)"
    Bensku wrote into his changelog, that he "Fixed local variables being local to events instead of triggers"
    Maybe that caused the current problem?
     
  13. k

    krulaks Member

    Joined:
    Aug 9, 2017
    Messages:
    17
    Likes Received:
    0
    So is there any way to use "return {_something}" in skript functions while using "execute "SELECT..."?
    I know that there are SkQuery functions, but they are unecessary complicated and there are no syntax or examples for it...

    Also:

    Code (Skript):
    1.     execute "SELECT `wave` FROM `infected` WHERE `arenaID` = %{_arena}%" in {sql.minigames} and store the result in {_r::*}
    2.     broadcast "%{_r::wave::1}%"
    Returns "true", but it should broadcast wave number.
    --- Double Post Merged, Jul 19, 2018, Original Post Date: Jul 19, 2018 ---
    Found the problem:

    Skript-db returns true or false if your column type is tinyint.
    Not funny ;-;
     
  14. btk5h

    Addon Developer

    Joined:
    Jan 25, 2017
    Messages:
    154
    Likes Received:
    155
    Skript's functions expect your code to return without delays. skript-db delays your code until a response is returned to prevent your server from freezing. You can use skript-mirror's custom effects for this.
     
  15. k

    krulaks Member

    Joined:
    Aug 9, 2017
    Messages:
    17
    Likes Received:
    0
    Code (Skript):
    1. effect getPlayerAmount %string%:
    2.     trigger:
    3.         delay the effect
    4.         execute "SELECT `playersAmt` FROM `infected` WHERE `arenaID` = %expr-1%" in {sql.minigames} and store the result in {_r::*}
    5.         return {_r::playersAmt::1}
    Error:
    Code (Skript):
    1. The return statement can only be used in a function (afunctions.sk, line 22: return {_r::playersAmt::1}')
    @btk5h how can I return value using skript-mirror's effects?
     
    #95 krulaks, Jul 20, 2018
    Last edited: Jul 20, 2018
  16. Uzumaki

    Uzumaki Well-Known Member

    Joined:
    Feb 20, 2017
    Messages:
    290
    Likes Received:
    8
    Code (Skript):
    1. [00:57:59 WARN]: java.util.concurrent.CompletionException: java.lang.RuntimeException: Failed to get driver instance for jdbcUrl=jdbc:sqlite:/C:/Users/Me/Desktop/TEST/plugins/jobs.db
    2. [00:57:59 WARN]:        at java.util.concurrent.CompletableFuture.encodeThrowable(Unknown Source)
    3. [00:57:59 WARN]:        at java.util.concurrent.CompletableFuture.completeThrowable(Unknown Source)
    4. [00:57:59 WARN]:        at java.util.concurrent.CompletableFuture$AsyncSupply.run(Unknown Source)
    5. [00:57:59 INFO]: [Skript] Successfully reloaded test.sk.
    6. [00:57:59 WARN]:        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    7. [00:57:59 WARN]:        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    8. [00:57:59 WARN]:        at java.lang.Thread.run(Unknown Source)
    9. [00:57:59 WARN]: Caused by: java.lang.RuntimeException: Failed to get driver instance for jdbcUrl=jdbc:sqlite:/C:/Users/Me/Desktop/TEST/plugins/jobs.db
    10. [00:57:59 WARN]:        at com.zaxxer.hikari.util.DriverDataSource.<init>(DriverDataSource.java:88)
    11. [00:57:59 WARN]:        at com.zaxxer.hikari.pool.PoolBase.initializeDataSource(PoolBase.java:325)
    12. [00:57:59 WARN]:        at com.zaxxer.hikari.pool.PoolBase.<init>(PoolBase.java:114)
    13. [00:57:59 WARN]:        at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:104)
    14. [00:57:59 WARN]:        at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:97)
    15. [00:57:59 WARN]:        at com.btk5h.skriptdb.skript.EffExecuteStatement.executeStatement(EffExecuteStatement.java:104)
    16. [00:57:59 WARN]:        at com.btk5h.skriptdb.skript.EffExecuteStatement.lambda$execute$1(EffExecuteStatement.java:72)
    17. [00:57:59 WARN]:        ... 4 more
    18. [00:57:59 WARN]: Caused by: java.sql.SQLException: No suitable driver
    19. [00:57:59 WARN]:        at java.sql.DriverManager.getDriver(Unknown Source)
    20. [00:57:59 WARN]:        at com.zaxxer.hikari.util.DriverDataSource.<init>(DriverDataSource.java:81)
    21. [00:57:59 WARN]:        ... 10 more
    22. >
    Code (Skript):
    1. on load:
    2.     set {test} to the database "sqlite:/C:/Users/Me/Desktop/TEST/plugins/jobs.db"
    3.     execute unsafe "CREATE TABLE IF NOT EXISTS `sqlite` (`ID` int(11) NOT NULL AUTO_INCREMENT,primary key (id))" in {test}
    i'm doing it wrong?
     
  17. pepper82

    pepper82 Member

    Joined:
    Jan 26, 2017
    Messages:
    239
    Likes Received:
    1
    I have a question to the author of this plugin @btk5h
    Will your plugin work with 1.13 skript as well?
     
  18. Tinkot

    Tinkot Well-Known Member

    Joined:
    Feb 10, 2018
    Messages:
    57
    Likes Received:
    1
    Is it possible to have multiple sql statements within the same query? i tried to separate them using a semicone but it somehow rejects those
     
  19. YuDylan

    YuDylan Member

    Joined:
    Jul 10, 2017
    Messages:
    2
    Likes Received:
    0
    Is it possible to check if the skript is connected to the database?
     
  20. pepper82

    pepper82 Member

    Joined:
    Jan 26, 2017
    Messages:
    239
    Likes Received:
    1
    @btk5h How can I use the result from this query in a message:

    SELECT SUM(amount) FROM `currency` WHERE 1

    I tried:
    execute "SELECT SUM(amount) FROM `currency` WHERE 1;" in {_sql} and store the result in {_r::*}
    message "&2%{_r::1}% Dollar"

    But does not work.
    --- Double Post Merged, Jan 28, 2019, Original Post Date: Dec 17, 2018 ---
    Can mysql stuff be used in functions?
    --- Double Post Merged, Jan 29, 2019 ---
    I can not get it to work in 1.13.2. Always receiving this error:
    https://i.imgur.com/8st6iEf.png
    --- Double Post Merged, Feb 13, 2019 ---
    Any update on the error, yet? Is thi plugin abandoned?
     
Loading...