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

Solved "Func" Function doesn't work in java 1.12.2

Discussion in 'Skript' started by iStopcontact, Apr 15, 2019.

  1. iStopcontact

    iStopcontact Member

    Joined:
    Feb 18, 2017
    Messages:
    92
    Likes Received:
    0
    Hey guys, i am working on a server network but found a little mistake.

    Now i have diffrent servers 1.8/1.9 but now im working on a gamemode for 1.12.2 and i found out that the "function" part doesnt work in my skript.

    Now i allready updated my skript to a 1.12.2 version but i still get the error:
    Can't understand this event: 'func "WoWgetvalue"

    I have this in my skript:
    Code (Text):
    1. func "WoWgetValue":
    2.     set {_p} to parameter 1
    3.     set {_p} to {_p} parsed as offline player
    4.     set {_uuid} to uuid of {_p}
    5.     set {_table} to parameter 2
    6.     set {_column} to parameter 3
    7.     execute "SELECT * FROM %unsafe {_table}% WHERE uuid=%{_uuid}%" in {WoWDB} and store the results in {_value::*}
    8.     set {_value} to {_value::%{_column}%::1}
    9.     set transient "output" to {_value}
    10.     $ access
    11.     set {_WoWgetValue} to transient "output"
    12.     return
    can someone help me with this?
    --- Double Post Merged, Apr 15, 2019, Original Post Date: Apr 15, 2019 ---
    just saw a error popping up in the console when i reload the skript:

    Code (Text):
    1. [19:35:14 WARN]: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
    2. [19:35:14 WARN]: SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
    3. [19:35:14 WARN]: SLF4J: Defaulting to no-operation (NOP) logger implementation
     
  2. ELROMPEDIENTES

    Joined:
    Feb 24, 2017
    Messages:
    188
    Likes Received:
    7
    I am not good with function but I think you need to define names and types here you have a tutorial I hope this can help you
     
  3. iStopcontact

    iStopcontact Member

    Joined:
    Feb 18, 2017
    Messages:
    92
    Likes Received:
    0
    I use SkQuery for the "Func" so that should be good...
    And it works when i use it in an 1.8.9 server but doenst in 1.12.2 while the plugins are all up to date
     
  4. ELROMPEDIENTES

    Joined:
    Feb 24, 2017
    Messages:
    188
    Likes Received:
    7
    ok then I'm not the one to fix the problem for you sorry. Good luck!
     
  5. BaeFell

    BaeFell I'm Poppy
    Admin

    Joined:
    Nov 27, 2016
    Messages:
    412
    Likes Received:
    213
    You need to use the updated fork by @LimeGlass (but not sure what he removed). You could also convert it to a Skript function but as there is a delay in the execute effect, it wouldn't actually return a value so you'd need to workaround that.

    Code (Skript):
    1. function WoWgetValue(p: player, table: string, column: string):
    2.     set {_p} to {_p} parsed as offline player
    3.     set {_uuid} to uuid of {_p}
    4.     execute "SELECT * FROM %unsafe {_table}% WHERE uuid=%{_uuid}%" in {WoWDB} and store the results in {_value::*}
    5.     set {_WoWgetValue} to {_value::%{_column}%::1}
    6.  
     
  6. T

    TPGamesNL Well-Known Member

    Joined:
    Jan 20, 2018
    Messages:
    907
    Likes Received:
    54
    Medals:
    If Skript functions don't work because of the delay, you can also use skript-mirror with custom effects, since that does support delays.
     
  7. iStopcontact

    iStopcontact Member

    Joined:
    Feb 18, 2017
    Messages:
    92
    Likes Received:
    0
    and also reply to @BaeFell

    I used a updated SKQuery, but now i got another error:

    Code (Text):
    1. [19:01:03 ERROR]: Can't understand this condition/effect: $ access (WorldOfWar.sk, line 15: $ access')
    2. [19:01:03 ERROR]: Can't understand this condition/effect: return (WorldOfWar.sk, line 17: return')

    because i don't really know how to use like the origional skript fuction i learned it with SkQuery
     
  8. T

    TPGamesNL Well-Known Member

    Joined:
    Jan 20, 2018
    Messages:
    907
    Likes Received:
    54
    Medals:
  9. iStopcontact

    iStopcontact Member

    Joined:
    Feb 18, 2017
    Messages:
    92
    Likes Received:
    0
    Can't you make like a skript function, for the Func i use now?

    so i have an example to work with if i wanna make other functions, it would help me allot
     
  10. T

    TPGamesNL Well-Known Member

    Joined:
    Jan 20, 2018
    Messages:
    907
    Likes Received:
    54
    Medals:
    Sure (I think this should be it):
    Code (Text):
    1. function WoWgetValue(p: offline player, table: string, column: string):
    2.     execute "SELECT * FROM %unsafe {_table}% WHERE uuid=%uuid of {_p}%" in {WoWDB} and store the results in {_value::*}
    3.     return {_value::%{_column}%::1}
    How to use it:
    Code (Text):
    1. set {_value} to WoWgetValue(player, "table", "column")
    There is a chance that that doesn't work, since the MySQL command could have a delay bound to it. If that is the case, tell me if it doesn't work (it might even give a parsing error), and I'll make the code in skript-mirror
     
  11. iStopcontact

    iStopcontact Member

    Joined:
    Feb 18, 2017
    Messages:
    92
    Likes Received:
    0
    Allright thanks man! I will try to use this
    --- Double Post Merged, Apr 16, 2019, Original Post Date: Apr 16, 2019 ---
    i cant really get it working, maybe im doing something wrong im not sure...
    Is it possible we go in discord call or smt and i screen share what i have
     
  12. T

    TPGamesNL Well-Known Member

    Joined:
    Jan 20, 2018
    Messages:
    907
    Likes Received:
    54
    Medals:
    Sure, but not today, and maybe also not tomorrow. I might be able to solve it if you send your code tho
     
  13. iStopcontact

    iStopcontact Member

    Joined:
    Feb 18, 2017
    Messages:
    92
    Likes Received:
    0
    I now have this code:

    Code (Text):
    1. function WoWgetValue(p: offline player, table: string, column: string):
    2.     set {_p} to {_p} parsed as offline player
    3.     set {_uuid} to uuid of {_p}
    4.     execute "SELECT * FROM %unsafe {_table}% WHERE uuid=%{_uuid}%" in {WoWDB} and store the results in {_value::*}
    5.     set {_value} to WoWgetValue(player, "table", "column")
    and just to test it i have this code:

    Code (Text):
    1. command /testcmd:
    2.     trigger:
    3.         access "WoWgetValue" from "%name of player%" and "WoW_Playerstats" and "Country"
    4.         if {_value} is not set:
    5.             broadcast "test"

    And when i reload i get this error:

    Code (Text):
    1. Functions cannot be used here (or there is a problem with your arguments). (WorldOfWar.sk, line 27: set {_value} to WoWgetValue(player, "table", "column")')
    2. [22:23:57 ERROR]: Can't understand this condition/effect: access "WoWgetValue" from "%name of player%" and "WoW_Playerstats" and "Country" (WorldOfWar.sk, line 46: access "WoWgetValue" from "%name of player%" and "WoW_Playerstats" and "Country"')
     
  14. T

    TPGamesNL Well-Known Member

    Joined:
    Jan 20, 2018
    Messages:
    907
    Likes Received:
    54
    Medals:
    Try to copy the function and the line to call the function exactly.
    Code (Text):
    1. function WoWgetValue(p: offline player, table: string, column: string) :: object:
    2.     set {_uuid} to uuid of {_p}
    3.     execute "SELECT * FROM %unsafe {_table}% WHERE uuid=%{_uuid}%" in {WoWDB} and store the results in {_value::*}
    4.     return {_value::%{_column}%::1}
    5.    
    6. command /testcmd:
    7.     trigger:
    8.         set {_value} to WoWgetValue(player, "WoW_Playerstats", "Country")
    9.         broadcast "value: %{_value}%"
     
    #14 TPGamesNL, Apr 17, 2019 at 7:24 AM
    Last edited: Apr 17, 2019 at 8:27 PM
  15. iStopcontact

    iStopcontact Member

    Joined:
    Feb 18, 2017
    Messages:
    92
    Likes Received:
    0
    I get these 2 errors:
    Code (Text):
    1. 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) (WorldOfWar.sk, line 72: return {_value::%{_column}%::1}')
    and
    Code (Text):
    1. Functions cannot be used here (or there is a problem with your arguments). (WorldOfWar.sk, line 76: set {_value} to WoWgetValue(player, "WoW_Playerstats", "Coins")')
     
  16. T

    TPGamesNL Well-Known Member

    Joined:
    Jan 20, 2018
    Messages:
    907
    Likes Received:
    54
    Medals:
    Sorry, I forgot to add a return type. But it doesn't matter, since the mysql execute command effect has a delay built in, so you have to use skript-mirror. I'm currently on my phone, so I can't make it for you. Meanwhile, give it a try yourself (google skript-mirror docs)
     
  17. iStopcontact

    iStopcontact Member

    Joined:
    Feb 18, 2017
    Messages:
    92
    Likes Received:
    0
    Yheaa i will try and see if i can work something out, btw thank you are doing this it helps me allot
    --- Double Post Merged, Apr 18, 2019 at 5:15 PM, Original Post Date: Apr 17, 2019 at 10:01 PM ---
    I have to be honnest, didnt really got it working and dont really understand how to work with it...

    So i hope you or someone can help me to make it for me
     
    • Friendly Friendly x 1
  18. T

    TPGamesNL Well-Known Member

    Joined:
    Jan 20, 2018
    Messages:
    907
    Likes Received:
    54
    Medals:
    Sure:
    Code (Text):
    1. effect WoWgetValue from [[offline] player] %offline player%, [table] %string% (and|,) [column] %string%:
    2.     trigger:
    3.         delay the effect
    4.         set {_uuid} to uuid of expression-1
    5.         delete {effect::WoWgetValue::return}
    6.         execute "SELECT * FROM %unsafe expression-2% WHERE uuid=%{_uuid}%" in {WoWDB} and store the results in {_value::*}
    7.         set {effect::WoWgetValue::return} to {_value::%expression-3%::1}
    8.         continue
    9.        
    10. expression [last] WoWgetValue result:
    11.     get:
    12.         return {effect::WoWgetValue::return}
    13.        
    14. on skript unload:
    15.     delete {effect::WoWgetValue::return}
    How to use:
    Code (Text):
    1. command /getvalue:
    2.     trigger:
    3.         WoWgetValue from player, "test" and "test"
    4.         set {_value} to last WoWgetValue result
    5.         message "value: %{_value}%"
     
    • Useful Useful x 1
  19. iStopcontact

    iStopcontact Member

    Joined:
    Feb 18, 2017
    Messages:
    92
    Likes Received:
    0
    Thank you man... sorry for all the work you had to do for mee man
    Really appreciate it!
     
  20. T

    TPGamesNL Well-Known Member

    Joined:
    Jan 20, 2018
    Messages:
    907
    Likes Received:
    54
    Medals:
Loading...