[Server Scripting] sys.sendAll behavior for next update

Discussion in 'Server and Client Scripting' started by coyotte508, Jun 7, 2013.

  1. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    There are some implementation changes. And a question's come up:

    For now, sys.sendAll(xxx) sends a message to every channel. sys.sendAll(xxx, channel) sends it to a specific channel. sys.sendAll(xxx, null) or sys.sendAll(xxx, undefined) sends it to channel 0, aka the main channel, due to automatic conversion to int.

    Would you rather that a null or undefined value as the channel argument sends to every channel?
     
  2. TheUnknownOne

    TheUnknownOne Member

    Joined:
    Mar 28, 2011
    Messages:
    988
    Likes Received:
    3
    Why not both? Obviously if you'd want to send it to a specific channel you'd specify an int.
     
  3. Lamperi

    Lamperi I see what you did there

    Joined:
    Apr 25, 2010
    Messages:
    2,647
    Likes Received:
    11
    The old behaviour is kinda difficult to go around sometimes, but I think most scripts have been adjusted to it.

    I would really take undefined second parameter as same as one parameter, since most Javascript native scripts work that way (only arguments.length changes).
     
  4. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    What if you do sys.sendAll("aaa", staffchannel) and staffchannel is undefined (doesn't exist) due to some script error?
     
  5. ArchZombie

    ArchZombie Member

    Joined:
    Aug 1, 2012
    Messages:
    65
    Likes Received:
    0
    PO Trainer Name:
    ArchZombie0x
    Code (text):
    1. sys.sendAll("aaa", staffchannel || 0)
    ?
     
  6. TheUnknownOne

    TheUnknownOne Member

    Joined:
    Mar 28, 2011
    Messages:
    988
    Likes Received:
    3
    That would throw a reference error.
     
  7. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    Currently undefined is converted to 0 automatically (javascript conversion)
     
  8. TheUnknownOne

    TheUnknownOne Member

    Joined:
    Mar 28, 2011
    Messages:
    988
    Likes Received:
    3
    Well yes, but you said if it isn't defined.
     
  9. Lamperi

    Lamperi I see what you did there

    Joined:
    Apr 25, 2010
    Messages:
    2,647
    Likes Received:
    11
    It's complicated. Doing sys.channelId("I do not exist") returns ScriptEngine.undefinedValue() AKA undefined for it and then sys.sendAll("foobar", variableWhichResolvesToUndefined) works like that
     
  10. TheUnknownOne

    TheUnknownOne Member

    Joined:
    Mar 28, 2011
    Messages:
    988
    Likes Received:
    3
    No, I meant this:

    [​IMG]

    Of course this works fine (well, most likely unwanted behavior):
    [​IMG]
     
  11. Lamperi

    Lamperi I see what you did there

    Joined:
    Apr 25, 2010
    Messages:
    2,647
    Likes Received:
    11
    That's what you meant, but coyo meant the latter case ^