The Online Status script, I have got to a stage where it will give the status of the owner or landowner only, and keeps giving the status at the set 30 second interval. I don't know how to tell the script to only give the blue menu if the status has changed.
CODE
list dialog = ["OK"];
integer dialog_channel = 1111;
key target = "";
integer flags;
integer gIsOnline = FALSE;
integer gLandOwner = FALSE;
key gKey = NULL_KEY;
string avatarName = "";
float UPDATE_INTERVAL = 30.0;
updateStatus(string s)
{
key k = llGetLandOwnerAt(llGetPos());
if(s=="1")
{
gIsOnline = TRUE;
}
else
{
gIsOnline = FALSE;
}
}
key getWhom()
{
if(gKey == NULL_KEY)
{
if(gLandOwner)
{
return llGetLandOwnerAt(llGetPos());
}
else
{
return llGetOwner();
}
}
else
{
return gKey;
}
}
doUpdate()
{
llRequestAgentData(getWhom(),DATA_ONLINE);
}
updateName()
{
llRequestAgentData(getWhom(),DATA_NAME);
}
enable()
{
updateName();
doUpdate();
llSetTimerEvent(1);
llWhisper(0,"Online status display enabled.");
}
disable()
{
llWhisper(0,"Online status display disabled.");
}
default
{
state_entry()
{
llListen(0, "", llGetOwner(), "");
enable();
llWhisper(0,"Type /ol help for a list of commands");
}
on_rez(integer n)
{
llResetScript();
}
dataserver(key req, string data)
{
if(data == "1" || data == "0")
{
updateStatus(data);
}
else
{
avatarName = data;
llSetTimerEvent(UPDATE_INTERVAL);
}
}
timer()
{
doUpdate();
if(gIsOnline)
{
llDialog(llGetOwner(),avatarName + " is Online", dialog, dialog_channel);
}
else
{
llDialog(llGetOwner(),avatarName + " is Offline", dialog, dialog_channel);
}
}
listen(integer number, string name, key id, string msg)
{
if (llGetSubString(msg, 0,0) != "/")
{
return;
}
list argv = llParseString2List(msg, [" "], []);
integer argc = llGetListLength(argv);
string cmd = llToLower(llList2String(argv, 0));
if(cmd == "/ol")
{
string arg = llToLower(llList2String(argv, 1));
if(arg=="on")
{
enable();
}
else if(arg=="off")
{
disable();
}
else if(arg=="land")
{
gLandOwner = TRUE;
gKey = NULL_KEY;
updateName();
}
else if(arg=="key")
{
gKey = llList2Key(argv,2);
updateName();
}
else if(arg=="me")
{
gLandOwner = FALSE;
gKey = NULL_KEY;
updateName();
}
else if(arg=="help")
{
llWhisper(0,"/ol on - activate online status display");
llWhisper(0,"/ol off - disable online status display");
llWhisper(0,"/ol land - display online status for owner of this land");
llWhisper(0,"/ol me - display your online status");
}
}
}
}
The second script I have got to the stage where I can say any avatar name and get the online status.
CODE
key requestID;
key id;
list dialog = ["OK"];
string avatarName;
integer dialog_channel = 1111;
integer listenID;
default
{
state_entry()
{
llListenRemove(listenID);
listenID = llListen(100,"",llGetOwner(),"");
}
listen( integer chan, string name, key id, string msg )
{
string avatarName = llDumpList2String(llParseString2List(msg,[" "],[]),"+");
requestID = llHTTPRequest("http://www.sldata.com/public/name2key/query.php?avname="+avatarName,[HTTP_METHOD,"GET"],"");
}
http_response(key request_id, integer status, list metadata, string body)
{
//Check for a success response
if (status == 200 && request_id == requestID)
{
//Split the response up into its parts
list bits = llParseString2List(body,[","],[]);
//Extract the avatar name
string avatarName = llList2String(bits,0);
//Extract the avatar key
string avatarKey = llList2String(bits,1);
//If the avatar key == -1 then the service couldn't find the avatar
if (avatarKey == "-1")
{
llOwnerSay("There is no avatar named "+avatarName);
}
else
{
//Otheriwse we found the avatar and we ouput the key
llRequestAgentData(avatarKey, DATA_ONLINE);
}
}
else {
//If the system isn't available this code block will run
llOwnerSay("Sorry, the service is not currently available");
}
}
dataserver(key req, string data)
{
if(data == "1")
{
llDialog(llGetOwner(), "Online", dialog, dialog_channel);
}
else
{
llDialog(llGetOwner(), "Offline", dialog, dialog_channel);
}
}
}
If someone can help me or at least give me a kick in the right direction, I would be grateful!
Thanks
Keelia