Product Update Server
Sorry if this is kind of badly written, I wrote it quickly in notepad, and I have yet to compile it yet. Please improve it further, or fix anything I did wrong!
Edited and Updated to allow compiling, by
CryasTokhes
Server
//Comet Aero
//12-11-06
//Reviewed and updated to compile by: Cryas Tokhes (19.06.07)
//This script is under the protection of the
//DNSOIWKY License
//A.K.A. The "Do Not Sell Or I Will Kill You" License*
string productGiveName = "gGadget 1.1";//Object name inside of the object to give if it is out of date.
string password = "password";//Password to protect from people stealing your hard work!!
string product = "gGadget";//The product series name, this is in place so you can handle multiple products per prim ^.^
integer latestVersion = 1;//This is the latest version of your product.
integer updateNotify = FALSE;//Want the server to email you when a product has been updated?
integer sendOldMessage = FALSE;//Want the server to message user that their product is out of date.
integer sendCurrentMessage = FALSE;//Want the server to message user stating that their product is up to date.
integer sendNewMessage = TRUE;//Want the server to message user that THEY have a newer product version then the server.
integer sendNewProduct = FALSE;//Want the server to RECEIVE the newer product from the user.
string emailAddress = "name@isp.com";//Your email address.
string currentMessage = "Your product is up to date.";
string overMessage = "Your product is newer then what is currently available. Sending to server...";
string oldMessage = "Your product is out of date. Sending new version...";
//====================================================================================================
//===Subject Format: password|product|version=========================================================
//===Message Format: UserKey==========================================================================
//==========================================WARNING===================================================
//===========There MUSNT be any spaces in between the "|" and all of them MUST match EXACTLY!!========
//====================================================================================================
default {
state_entry() {
llSetTimerEvent(2.5);//Poll for emails.
llSetObjectDesc((string)llGetKey());//You will need the key when setting up you client
llWhisper(0, (string)llGetKey());
}
timer() {
llGetNextEmail("","");
if(llGetFreeMemory() < 100){
llInstantMessage(llGetOwner(), "/me is running low on available memory, script is resetting in 5 seconds.");
llSleep(5);//There is nothing really to store in the runtime, so if were running
//low on memory, just notify the owner and reset.
llResetScript();
}
}
email(string time, string address, string subj, string message, integer num_left) {
list messageList = llParseString2List(subj, ["|"], []);//Parses the subject into the parts by "|"
string inputPassword = llList2String(messageList,0);//Get the first parced part.
string inputProduct = llList2String(messageList,1);//Get the second parsed part.
string inputVersionString = llList2String(messageList,2);//Get the THIRD parsed part.
integer inputVersion = (integer)inputVersionString;//Just thought it would be better if we did it this way :)
key inputUser = llDeleteSubString(message, 0, llSubStringIndex(message, "\n\n") + 1);
//===========================================================================================
if(inputPassword == password && inputProduct == product){
if(inputVersion < latestVersion){//If its older then the newest version...
if(sendOldMessage) llInstantMessage(inputUser, oldMessage);//If you want to send a message, then do!
llGiveInventory(inputUser,productGiveName);//Send newest product
if(updateNotify) llEmail(emailAddress, product + " has been updated.", product + " has been updated.");//Sends YOU a notification.
}
else if (inputVersion == latestVersion){//If it is the newest version...
if(sendCurrentMessage) llInstantMessage(inputUser, currentMessage);//If you want to send a message, then do!
}
else if(inputVersion > latestVersion){//If its NEWER then the newest versiion..............
if(sendNewMessage) llInstantMessage(inputUser, overMessage);//If you want to send a message, then do.
if(sendNewProduct) llGiveInventory(inputUser,productGiveName);//If you want to give them YOUR newest version, then do.
}
}
}
}
//*Comet Aero does not support the killing of Kittens, humans or goldfish.
Client
//Comet Aero
//12-11-06
//Reviewed and updated to compile by: Cryas Tokhes (19.06.07)
//This script is under the protection of the
//DNSOIWKY License
//A.K.A. The "Do Not Sell Or I Will Kill You" License*
//
//==========================================WARNING===================================================
//=======The password, productName and serverKey MUST match EXACTLY=======================================
string serverKey = "1b685a6d-fec9-4f2a-9c3f-53be0ae25164";//What the server whispers when you put the script in the server or reset it.
string productName = "gGadget";//The product name you set in your script.
string password = "password";//The password you set in your server.
integer currentVersion = 1;//The current version of the product.
default {
on_rez(integer param){
llEmail(serverKey + "@lsl.secondlife.com", password + "|" + productName + "|" + (string)currentVersion, (string)llGetOwner());
//Send the server the request.
llSay(0, "Thank you," + llKey2Name(llGetOwner()) + ", we are currently checking to see if there is a product update available.");
}
}
//Comet Aero does not support the killing of Kittens, humans or goldfish.