Examples ScriptLibrary AnorcaCalamari BlindWanderer
This script can IM anyone in the W-HAT key database and on the grid you're on.
It can also give any inventory it has to people on command.
Channel | Parameters | Description | Example |
40 | Avatar Name | Gets the users key from W-Hat database | /40 Anorca Calamari |
50 | Message | Sends the message to the last avatar queried by the script | /50 Hello Hello |
60 | Item | Sends an item from the objects inventory to the last avatar queried by the script | /60 InstantMessage |
//Original Script Created by AnorcaCalamari
//Modified by BlindWanderer
//BlindWanderer added lag reducing features,Inventory check,non cap sensitive inventory and a few other things.
//Please do not sell this script except as a part of a larger creation. You may modify it.
//You can give this script away for free.
key requestid;
string resident;
key target;
key owner;
string owner_name;
string InventoryType(string name, integer type)
{//finds an item in a case insensitive fashion of the given type and returns its true name.
integer a = llGetInventoryType(name);
if(!~a)//a == INVENTORY_NONE
{
string b;
a = llGetInventoryNumber(type);
name = llToLower(name);
while(a)
{//(a = ~-a) is equivalent to --a, but runs faster.
if(llToLower(b = llGetInventoryName(type, a = ~-a)) == name)
{//we found a match ^^
return b;
}
}
}
else if((a == type) ^ (!~type))//when type == INVENTORY_ALL, invert the result.
{//the reason for this mess is that INVENTORY_NONE == INVENTORY_ALL
return name;
}
return "";
}
default
{
state_entry()
{
owner = llGetOwner();
owner_name = llKey2Name(owner);//never changes.
if(owner_name == "")
requestid = llRequestAgentData(owner, DATA_NAME);//this should never need to be called but it's here just in case.
llListen(40, "", owner, "");
llListen(50, "", owner, "");
llListen(60, "", owner, "");
}
listen(integer channel, string name, key id, string message)
{
if(channel == 40)
{
if((key)message)//check to see if message is a valid key.
{//if it is, skip the lookup.
target = message;
resident = "";
}
else
{//look up the name.
list names = llList2List(llParseString2List(message, [" "], []), 0, 1);
resident = llDumpList2String(names, " ");
requestid = llHTTPRequest("http://w-hat.com/name2key?name=" + llDumpList2String(names, "+"), [HTTP_METHOD, "GET"], "");
target = "";
}
}
else if(target)
{//make sure 'target' is a valid key.
if(channel == 50)
{
llInstantMessage(target, owner_name + ": " + message);
}
else if(channel == 60)
{
name = InventoryType(message, INVENTORY_ALL);
if(name)
{//make sure name is not null.
llGiveInventory(target, name);
}
else
{//if name is null, then the item could not be found.
llOwnerSay("Item \"" + message + "\" not found in inventory");
}
}
}
else
{//since it wasn't channel 40, and target is invalid, it must be channel 50 or 60
llOwnerSay("Invalid user, please lookup a user with \"/40 User Name\"");
}
}
http_response(key request_id, integer status, list metadata, string body)
{
if (request_id == requestid)
{
integer i = llSubStringIndex(body,resident);
if ( i != -1 )
{
i += llStringLength(resident) + 1;//length of name plus a space.
target = llGetSubString(body, i, i + 35);
if(target)
{//test the key to make sure it is valid
llOwnerSay("Headset set to: \"" + resident + "\" at key: " + (string)target);
return;
}//if it is not valid fall through to the error message.
}
llSay(0,"No resident named \"" + resident + "\" found in the w-hat name2key database");
}
else
{
llSay(0, (string)status + " error");
}
}
on_rez(integer rez_code)
{
if(llGetOwner() != owner)
{
llResetScript();
}
}
dataserver(key id, string data)
{
if(id == requestid)
{
owner_name = data;
}
}
}
Original script by Anorca Calamari
Full names required.
Cap sensitive.
key requestid;
string resident;
string target;
default
{
state_entry()
{
llListen(40,"",llGetOwner(),"");
llListen(50,"",llGetOwner(),"");
llListen(60,"",llGetOwner(),"");
}
listen(integer channel,string name,key id,string message)
{
if(channel==40)
{
list names = llParseString2List(message,[" "],[]);
resident = llDumpList2String(names," ");
requestid = llHTTPRequest("http://w-hat.com/name2key?name="+llDumpList2String(names,"+"),[HTTP_METHOD,"GET"],"");
target=message;
}
if(channel==50)
{
llInstantMessage((key)target,llKey2Name(llGetOwner())+":"+message);
}
if(channel==60)
{
llGiveInventory(target,message);
}
}
http_response(key request_id, integer status, list metadata, string body)
{
if (request_id == requestid)
{
integer i = llSubStringIndex(body,resident);
if ( i != -1 )
{
string avatarkey=llGetSubString(body,i,i+llStringLength(resident)+36);
llOwnerSay("Headset set to: "+target+" at key: "+avatarkey);
avatarkey=llGetSubString(avatarkey,llStringLength(avatarkey) - 36,llStringLength(avatarkey));
target=avatarkey;
}
else
llSay(0,"No resident named \""+resident+"\" found in the w-hat name2key database");
} else
llSay(0,(string)status+" error");
}
}