1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

お友達が On Line かチェックするスクリプト (LSL)

Last updated at Posted at 2019-04-13

###注意事項
確認相手にブロックされていてもオンラインの確認が取れてしまいます。
BIG6 を守っておたのしんでください!

[OnLineChecker.LSL]
/*
 UUID が On line か Off line か判定する
 
 Username は SIM の記録から消えている可能性があるので
 Username を Request して SIM 以外から取得する。
 (ここで名前が出ないようなら退会しているのかもしれない)
*/


string uuid = "";
string user_name;
key name_query;

float gap = 15.0;

integer listen_edit_handle;
integer dlg_edit_channel;

open_input_uuid_dlg(key user)
{
    if(listen_edit_handle != 0)
    {
        llListenRemove(listen_edit_handle);
        listen_edit_handle = 0;
    }
    listen_edit_handle = llListen(dlg_edit_channel, "", NULL_KEY, "");
    
    string msg = "\nInput Avator UUID.\n\n" +
        "if u wanna stop this program.\npls input \"STOP\".\n\n";
                
    llTextBox(user, msg, dlg_edit_channel);    
}

default
{
    state_entry()
    {
        dlg_edit_channel = (integer)("0x" + (string)llGetKey());
        listen_edit_handle = llListen(dlg_edit_channel, "", NULL_KEY, "");
        
        llSetText("",<1,1,1>,1);
    }
    
    touch_start(integer param)
    {
        if(llDetectedKey(0) == llGetOwner())
        {
            integer face = llDetectedTouchFace(0);
            
            if(uuid != "" && face == 4)
            {
                llOwnerSay("Script found : " + 
                        "secondlife:///app/agent/" + (string)uuid + "/inspect");
            }
            else
            {
                open_input_uuid_dlg(llGetOwner());
            }
        }
    }
    
    listen( integer channel, string name, key id, string message )
    {
        if(llGetOwnerKey(id) == llGetOwner() && channel == dlg_edit_channel)
        {
            if(message == "STOP")
            {
                llSetTimerEvent(0);
                llSetText("",<1,1,1>,1);
                uuid = "";
            }
            else
            {
                uuid = message;
                
                if(uuid != "")
                {
                    name_query = llRequestUsername(uuid);
                    llSetTimerEvent(gap);
                }
            }
        }
    }
    
    timer()
    {
        llRequestAgentData( uuid, DATA_ONLINE );
    }

    dataserver(key req, string data)
    {
        if( name_query == req )
        {
            user_name = data;
            
            if(user_name != "")
            {
                llOwnerSay("Script found : " + 
                    "secondlife:///app/agent/" + (string)uuid + "/inspect");
            }
            else
            {
                llOwnerSay("Not Found...");
                llSetTimerEvent(0);
                llSetText("",<1,1,1>,1);
                uuid = "";
            }
        }
        else
        {
            integer check = (integer) data;
            
            string msg;
            if( check == 1 )
            {
                msg = user_name + "\nis online";
                llSetText(msg,<0,1,0>,1.0);
                //llOwnerSay(msg);
            }
            else
            {
                msg = user_name + "\nis offline";
                llSetText(msg,<1,0,0>,1.0);
                //llOwnerSay(msg);
            }
        }
    }
}
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?