Vanilla 1.1.4 is a product of Lussumo. More Information: Documentation, Community Support.
1 to 1 of 1
I recently made some changes to a couple of products - the .455 Webley and .45 Shansi, if anyone is interested - that were supplied without any sort of update function, and for which I only had a list of purchaser names. Given that there were a good 150 or so of these names it was hardly as if I was going to drop items and send IMs to each and every customer by hand.
Being disinclined to create a bot to do this I thought that I might use a simple list of names in a notecard, and the W-Hat name to key database, to send out updated versions, and herein I post the script I used.
string MESSAGE = "Hello! You are listed as a purchaser of the .455 Webley - a new version has been developed with built-in updating functions and drawing/holstering animations, which you will be receiving shortly. This is a one-time only message, sorry for any inconvenience!";
string ITEM = ".455 Webley Mk6 Revolver Delivery Box";
integer gLine = 0;
integer gDelivered = 0;
string gResident = "";
update()
{
llSetText("Delivering (" + (string)gDelivered + " done)", <1.0, 1.0, 0.0>, 1.0);
}
get_key(string name)
{
gResident = name;
llHTTPRequest("http://w-hat.com/name2key?name=" + llEscapeURL(name), [HTTP_METHOD,"GET"], "");
}
default
{
state_entry()
{
llOwnerSay(llGetScriptName() + " ready");
llSetText("Touch to send message and item to list", <0.0, 1.0, 0.0>, 1.0);
}
touch_start(integer n)
{
state delivering;
}
}
state delivering
{
state_entry()
{
if (llGetInventoryType(ITEM) == INVENTORY_NONE) {
llOwnerSay("Can't find '" + ITEM + "' in inventory");
state default;
}
gDelivered = 0;
gLine = 0;
update();
llGetNotecardLine(llGetInventoryName(INVENTORY_NOTECARD, 0), gLine++);
}
dataserver(key query, string data)
{
if (data == EOF) {
llOwnerSay("Finished.");
state default;
}
get_key(data);
}
http_response(key request_id, integer status, list metadata, string body)
{
integer i;
key id = NULL_KEY;
if ( ( i = llSubStringIndex(body, gResident) ) != -1 ) {
id = (key)llGetSubString(body,i + llStringLength(gResident) + 1, i + llStringLength(gResident) + 36);
llOwnerSay("Sending to " + gResident + " - " + (string)id);
llInstantMessage(id, MESSAGE);
llGiveInventory(id, ITEM);
gDelivered++;
update();
}
else {
llSay(0,"No resident named \""+gResident+"\" found in the w-hat name2key database");
}
llGetNotecardLine(llGetInventoryName(INVENTORY_NOTECARD, 0), gLine++);
}
}
As you can see, the prim used should have a list of names in a notecard, as well as the item to be sent out - the MESSAGE string is IMed to the recipient, and they then receive the item itself.
1 to 1 of 1