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.

Return function across 2 sk files

Discussion in 'Skript' started by Jordan, Jan 31, 2017.

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

    Jordan Member

    Joined:
    Jan 25, 2017
    Messages:
    190
    Likes Received:
    12
    So not to sure if this is a bug or not but i'm unable to return a function over 2 skript files, i can access the function fine if it does not return anything however if i try get it to return something across 2 files it'll give me an error like this

    Code (Skript):
    1. [15:12:23] [Server thread/ERROR]: #!#! ch.njol.skript.SkriptAPIException: Signature of function is null when return type is asked!
    If i try return the function in the same file it's created in then it works however if i try return it in a different file to where it's created it will return this error, here's my skript.

    File1.sk
    Code (Skript):
    1.  
    2. on skript load:
    3.     set mysql host to "localhost" # Connecting to MYSQL database to update server status
    4.     set mysql username to "root"
    5.     set mysql password to "jordan1"
    6.     set mysql database to "RebornEncrypt"
    7.     set {_GetServerID} to yml value "ServerID" of file "plugins/Reborn/Config.yml"
    8.     skellett connect to mysql
    9.     mysql update "UPDATE Servers SET Status='Avaliable' WHERE ServerID='%{_GetServerID}%'"
    10.  
    11.      
    12. function CheckServerStatus(s: string) :: string:
    13.     set {_s} to yml value "ServerID" of file "plugins/Reborn/Config.yml"
    14.     set {_result} to mysql result of query "SELECT Status FROM servers WHERE ServerID='%{_s}%'"
    15.     set {_s::*} to mysql string "Status" in {_result}
    16.     return {_s::1}
    17.  
    File2.sk
    Code (Skript):
    1. on join:
    2.     set {_temp} to CheckServerStatus("Check")
    Also note if it wasn't clear, File1 loads before File2 so it's not a matter of the function not loading.
     
    #1 Jordan, Jan 31, 2017
    Last edited: Jan 31, 2017
  2. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,185
    Likes Received:
    215
    I don't know how the mySQL stuff of Skellett works but the function only executes that code and unless the connection you did in the File1.sk is globally for all scripts you'll have todo it in the File2.sk too
     
  3. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,185
    Likes Received:
    215
    I've also tried making the connection in File2 and it's the same result. I've also removed all the sql stuff and just tried to return a simple "Hello" string and i get the same result.
     
  4. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,185
    Likes Received:
    215
    That's a weird issue then, can you show your version of Skript and of your server?
     
  5. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,185
    Likes Received:
    215
    Code (Skript):
    1. [15:12:23] [Server thread/ERROR]: #!#! Version Information:
    2. [15:12:23] [Server thread/ERROR]: #!#!   Skript: 2.2-dev23
    3. [15:12:23] [Server thread/ERROR]: #!#!   Bukkit: 1.10.2-R0.1-SNAPSHOT
    4. [15:12:23] [Server thread/ERROR]: #!#!   Minecraft: 1.10.2
     
  6. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,185
    Likes Received:
    215
    Hmm, so strange, can you try on a fresh server only with Skript and see if you have the same issue?
     
  7. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,185
    Likes Received:
    215
    Hmm works on a fresh server with only skript installed, so either a problem with skelletts SQL or skquery's functions
     
  8. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,185
    Likes Received:
    215
    skQuery functions wouldn't be a problem such as the Skript ones override them, it's either an issue trying to connect to the database or something, can you show me the full stack trace (console error) anyways?
     
  9. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,185
    Likes Received:
    215
    try replace string with text?
    Code (Skript):
    1. function CheckServerStatus(s: string) :: text:
     
  10. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,185
    Likes Received:
    215
    text is an just alias of string, both are the same thing.
     
  11. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,185
    Likes Received:
    215
    As a suggestion, look at which script is loading first.

    Bensku's 2.2-dev23 seems to load scripts in alphabetical order. And functions must be declared before they are used. Thus if the script the function is declared in is loading after the script it is being called in you will receive this error.
     
Thread Status:
Not open for further replies.

Share This Page

Loading...