Returning the player's cauth level by client script.

Discussion in 'Implemented' started by Nightfall Alicorn, Dec 20, 2014.

  1. Nightfall Alicorn

    Nightfall Alicorn Left Pokémon Online, most likely not coming back.

    Joined:
    Oct 15, 2013
    Messages:
    491
    Likes Received:
    171
    PO Trainer Name:
    Nightmare Moon
    This is something I've been thinking about recently. I've had a look through the current functions but couldn't find it.

    I know you can get information about players that are visible in channel by:
    // Returns user's Id even though it's already there.
    var vPlayerId = client.player(player_id_here).id;

    // Returns user's PO name.
    var vPlayerName = client.player(player_id_here).name;

    // Returns user's Trainer Information.
    var vPlayerTrainerInfo = client.player(player_id_here).info;

    // Returns user's server auth level value from 0 to 4. User/Mod/Admin/Owner
    var vPlayerServerAuthLevel = client.player(player_id_here).auth;

    // Returns user's settings from 0 to 7 depending on if their idle on/off, ratings on/off, in battle yes/no.
    var vPlayerSetting = client.player(player_id_here).avatar.flags;

    // Returns user's avatar number from 1 to 300. I don’t know how some users get 0 though.
    var vPlayerAvatar = client.player(player_id_here).avatar;

    // Returns user's font colour in #rrggbb hex format. rr = red, gg = green, bb = blue
    var vPlayerFontColor = client.player(player_id_here).color;

    What if it could return the user's /cauth level in a channel. So users that are channel owner for example could manipulate the settings if the script owner isn't currently present. For example:
    // Return's the user's cauth level from 0 to 4 from the input channel id.
    // 0 = Not in /cauth, 1 = Channel Member, 2 = Channel Mod, 3 = Channel Admin, 4 = Channel Owner
    var vPlayerCauth = client.player(player_id_here).cauth(channel_id_here);

    I'm not sure if that's how you return a result by input 2 values but I'm still learning. But it be great if it was possible.
     
  2. Crystal Moogle

    Crystal Moogle Ayaya~ Administrator Administrator

    Joined:
    Jul 19, 2010
    Messages:
    3,205
    Likes Received:
    531
    PO Trainer Name:
    Hanako
    It's not possible. Everything else is specifically coded into PO. Cauth is something specific to the scripts used on the main server.
    You have to parse to result from /cauth

    Actually I just added a way to get a JSON object from /cauth to make things easier
    Use "/cauth ~" and you'll get a JSON object of the cauth list like so:
    (19:50:03) +cauth: {"members":["this is a test"],"operators":["guest"],"admins":["test"],"owners":["katsuragi"]}

    Then you check for messages where the name is +cauth and attempt to use "JSON.parse" on the message it sends and it'll give you a JSON object with the cauth of the channel.
    You'd probably have to set a timer to keep using /cauth ~, or use it on demand when needed.
     
    Last edited: Dec 20, 2014
  3. Crystal Moogle

    Crystal Moogle Ayaya~ Administrator Administrator

    Joined:
    Jul 19, 2010
    Messages:
    3,205
    Likes Received:
    531
    PO Trainer Name:
    Hanako
    Also did /auth whilst I was at it. It works in the same way.
    If there's anything else you need, I might add it.
     
  4. Nightfall Alicorn

    Nightfall Alicorn Left Pokémon Online, most likely not coming back.

    Joined:
    Oct 15, 2013
    Messages:
    491
    Likes Received:
    171
    PO Trainer Name:
    Nightmare Moon
    Thanks for your help, Crystal. Guess I have to use a secondary alt so I don't see the results from /cauth ~ too often. But I know it be very helpful to use. I could always use -update command to manually update the list, I just hope users don't keep /passcauth too often.

    Just a random thought. Would it possible to webcall a Json of a channel object? Just a random thought.

    Anyway, thanks again.
     
  5. Crystal Moogle

    Crystal Moogle Ayaya~ Administrator Administrator

    Joined:
    Jul 19, 2010
    Messages:
    3,205
    Likes Received:
    531
    PO Trainer Name:
    Hanako
    You could block the results of /cauth ~ from displaying using sys.stopEvent(). The script will still read it, but you won't :D

    I don't really understand the webcall question though.
     
  6. Nightfall Alicorn

    Nightfall Alicorn Left Pokémon Online, most likely not coming back.

    Joined:
    Oct 15, 2013
    Messages:
    491
    Likes Received:
    171
    PO Trainer Name:
    Nightmare Moon
    That's perfect. Thanks again, Crystal. I forgot about sys.stopEvent().

    Doesn't matter about the webcall thing. I was thinking of Jenora's script that gets json objects of defines from urban dictionary. I thought that webcall could get /cauth ~ data without it being printed. But you just give me a much easier solution. Thanks again.