sys.info() not a string?

Discussion in 'Server and Client Scripting' started by Homura, Jun 11, 2013.

  1. Homura

    Homura Member

    Joined:
    May 22, 2012
    Messages:
    43
    Likes Received:
    0
    I wrote this command to view player's info:
    Code (text):
    1. try
    2. {
    3.       sys.sendMessage(src, sys.info(parseInt(sys.id(commandData))), chan);
    4.       return;
    5. }
    6. catch(e){
    7.       sys.sendMessage(src, e, chan);
    8. }
    which, on the test subject results in an output of:

    (11:32:05) Here's a test info


    So, at some point, it's cast to a String to be printed right?

    Well when I try this:

    Code (text):
    1.  
    2. if (sys.info(src) == "Here's a test info") //line 1492
    3. {
    4.     sys.sendAll("Passed!");
    5. }
    6. else
    7. {
    8.     sys.sendAll("Failed!");
    9. }
    10.  
    I get:
    (11:24:30) ~~Server~~: Script Error line 1492: TypeError: Result of expression 'sys.info(src)' [undefined] is not an object.


    So when I change that:

    Code (text):
    1.  
    2. if (String(sys.info(src)) == "Here's a test info") //line 1492
    3. {
    4.     sys.sendAll("Passed!");
    5. }
    6. else
    7. {
    8.     sys.sendAll("Failed!");
    9. }
    10.  
    Now it doesn't print any errors, but the test never passes.


    Does anyone have any advice on working sys.info()? I want to treat it like a String.
     
  2. Crystal Moogle

    Crystal Moogle Ayaya~ Administrator Administrator

    Joined:
    Jul 19, 2010
    Messages:
    3,205
    Likes Received:
    531
    PO Trainer Name:
    Hanako
    When I used sys.info(src) I got my trainer info as "TOSHINOU KYOUKO~!". When I did print(sys.info(src) === "TOSHINOU KYOUKO~!") it returned true :x
    I'm not sure why it's not working for you

    Try printing out the output of sys.info(src), since the first part of the post refers to commandData where as the second refers to src. I'm assuming both pointed to the same person, but you can't be too careful!
     
  3. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    undefined seems to indicate that the one you're trying to get info from is not logged on.

    Also to convert to string use ''+sys.info(src).
     
  4. Homura

    Homura Member

    Joined:
    May 22, 2012
    Messages:
    43
    Likes Received:
    0
    Ah, I see. Now it prints completely blank for everyone when I try to print it out just before the line marked 1492.

    EDIT: Ah, your post helped explain, Coyotte.

    EDIT 2: Yep, I moved it from beforeLogIn to afterLogIn and it works fine. Thanks!
     
    Last edited: Jun 11, 2013