Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Library: Auto Update Server item in the Interweb :P

Cryas Tokhes
Great Googley Moogley...
Join date: 8 Feb 2006
Posts: 124
07-03-2007 13:24
I know that there are many update server and client scripts that are out there. However all of these did not quite seem to work for me. So I made my own with these others as a guide line. It is a bit less confusing in review. All fields that need to be edited are indicated as such.

Notecard that is in the server prim (can be renamed by the owner and set in the server script).

Should have an item per line in the format of "Item:Version", Item must be spelled exactly the same as the item in the server.
From: someone

Gym Membership:1.0
Spandex Pants:1.0
Underarmor Sweat Tee Shirt:1.05


Client Script
From: someone

key serverID = "00000000-0000-0000-0000-000000000000"; // Fill this in with the UUID that the server spits out on rez.
key gkOwner;
string version = "1.0"; // Version number of the item
string item = "Spandex Pants"; // Name of the item
string company = "I work here"; // Name of the company
default
{
state_entry()
{
}

attach(key attached)
{
if (attached != NULL_KEY)
{
llOwnerSay("Checking for updates for your " + company + " product.";);
llEmail(serverID,"Update Request",item + ":" + version + "|" + (string)llGetOwner());
}


Server Script:
From: someone

// CTD Updater Script
// Server UUID:
// NOTE: This is an area to keep the UUID in the notes for reference.
key serverID;
string cardName = "Updates"; // Name of the Notecard with all of the Item:Version info
string company = "I work here"; // Name of the company
key lineTotalID;
key locateID;
integer lineCurrent = 0; // Line Offset
integer lineTotal; // Line Offset
string noteLine;
string noteFront;
string noteBack;
string item;
string version;
key user;
float watchdog = 10.0;
integer InUse = FALSE;

default
{
state_entry()
{
llWhisper(0,llGetKey());

llSetTimerEvent(5.0);

lineTotalID = llGetNumberOfNotecardLines(cardName);
}

touch_start(integer total_number)
{
llResetScript();
}

timer()
{
llGetNextEmail("","";);
}

email(string time, string address, string subject, string body, integer remaining)
{
llWhisper(0,"Received Request...";);

if (InUse == FALSE)
{
InUse = TRUE;

llSetText("In Use...",<1,1,1>,1.0);

string message = llDeleteSubString(body, 0, llSubStringIndex(body, "\n\n";) + 1);

integer itemMark = llSubStringIndex(message,":";);
integer verMark = llSubStringIndex(message,"|";);

item = llGetSubString(message,0,(itemMark - 1));
version = llGetSubString(message,(itemMark + 1),(verMark - 1));
user = (key)llGetSubString(message,(verMark + 1), -1);

llWhisper(0,"Item: " + item);
llWhisper(0,"Version: " + version);
llWhisper(0,"User: " + llKey2Name(user));
lineCurrent = 0;

locateID = llGetNotecardLine(cardName,0);
}
}

dataserver(key queryID, string data)
{
if (queryID == lineTotalID)
{
lineTotal = (integer)data;
llInstantMessage(llGetOwner(),"Found " + (string)lineTotal + " items on update server.";);
}

if (locateID == queryID)
{
if (data != EOF)
{
noteLine = data;

integer marker = llSubStringIndex(noteLine,":";);

if (marker != -1)
{
lineCurrent += 1;
noteFront = llGetSubString(noteLine,0,( marker - 1 ));
noteBack = llGetSubString(noteLine,( marker + 1 ), -1);
}
if (marker == -1)
{
llInstantMessage(llGetOwner(),"Error with Update Server Inventory line: " + (string)lineCurrent);
}

if (noteFront != item)
locateID = llGetNotecardLine(cardName,lineCurrent);

if (noteFront == item)
{
if ((float)noteBack > (float)version)
{
llGiveInventory(user,item);
llInstantMessage(user,"Sending you the updated version of: " + item);
}

if ((float)noteBack < (float)version)

llInstantMessage(user,"There was an error with the update of your " + item + ", please contact " + llKey2Name(llGetOwner()));

if ((float)noteBack == (float)version)

llInstantMessage(user,"Your " + item + " by " + company + " product is up to date.";);

InUse = FALSE;

llSetText("",<1,1,1>,0.0);
}
}
}
if (data == EOF)
{
InUse = FALSE;

llSetText("",<1,1,1>,0.0);
llInstantMessage(llGetOwner(),"Update Server Hit EOF on Update List";);
}
}
}


I did some last minute changes to make this public. It might have fudged the script a bit. So I am fully expecting this to have some syntax errors.

After you have the client script in the item that you want to sell, the server script in a prim that will ALWAYS be inworld, the most recent version of the sellable item in the server prim, and the notecard with all the items with matching names to the items in the prim with the specified versions. Then you are set.

Things to keep in mind.
There are always some draw backs to update servers.
- If you have your items set as transferable, it is possible that someone can get unlimited copies of your stuff. Keep this in mind. All they would have to do it detach, attach, get the updated item, give to friend.. detach, attach, get the updated item, give to friend, etc.

That is never good for business. Don't say that I never warned you.
Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
11-30-2008 13:06
i know this is probuly a old post that noone lookes at anymore but ive been trying to use it and it dosent seam to respond to any emails
Laurence Corleone
Registered User
Join date: 12 Oct 2006
Posts: 126
12-01-2008 02:20
How are you testing the emails? From your email account outside of SL? Test emails from a mail system outside of SL never seem to work for me :rolleyes: Any time I have something that seems to not be receiving emails I drop the following script into it. I found this test script somewhere here in the forums and the credit goes to whoever wrote it, all I did was clean it up.

CODE

default
{
state_entry()
{
llEmail((string)llGetKey() + "@lsl.secondlife.com", "Test!", "This is a test message."); // Send email to self.

llSetTimerEvent(2.5); // Poll for emails. (Yes, that is a retarded way on an event-based system!)
}
timer()
{
llGetNextEmail("", ""); // Check for email with any sender address and subject.
}
email(string time, string address, string subj, string message, integer num_left)
{
llSay(0, "You got mail! " + (string)num_left + " more mails.");
llSay(0, llList2CSV([time, address, subj, message]));
if (num_left == 0) llSetTimerEvent(0.0); // Stop timer when there's no more email.
}
}
_____________________
There are no stupid questions, just stupid people.
Bizcut Vanbrugh
Registered User
Join date: 23 Jul 2006
Posts: 99
12-14-2008 23:24
most likely a question that will get flamed but how do i get it to tell the object its a old version and then have the object llDie() ?
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
12-15-2008 09:30
From: Bizcut Vanbrugh
most likely a question that will get flamed but how do i get it to tell the object its a old version and then have the object llDie() ?

You'll need to get a response of some kind back from the server. In this case probably a return e-mail would be the thing. For HTTP servers the HTTP request response can do it easily. Keep in mind that llDie() won't have any effect in an attachment, though you could remove scripts, switch to a non-functional state or one that instantly detaches the object when it is put on or whatever.

Be careful about doing this. There's no way to guarantee that any object sent by a server reached the recipient. If you trash the only copy they have and they don't get a new one....
Cookie Bertone
Music & Audio
Join date: 13 May 2006
Posts: 13
Try this...
12-07-2009 05:39
From: Mrc Homewood
i know this is probuly a old post that noone lookes at anymore but ive been trying to use it and it dosent seam to respond to any emails


Try putting "@lsl.secondlife.com" after the ServerID in the client script.
_____________________
Bertone Audio Systems
Rossa (212, 98, 79)

Thanks to these forums the supplier of probably the best parcel music player in Second Life.