Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Demographic Data Demo Vendor

Sean Martin
Yesnomaybe.
Join date: 13 Sep 2005
Posts: 584
05-31-2007 18:42
Here is a simple demographic vendor that some have asked me for in the past so I thought I'd post it here.
The vendor has a simple dialog menu for the owner.
It holds 5 keys in memory to keep people from taking more than one demo object within a specified amount of time. Or at least until 5 others have taken a copy. Whichever comes first.

It will also keep the last 5 names of people who have clicked the vendor and how many clicks it has in total since you last reset it.
Mainly just for demographic data if you need to send it to another server object for auto loging.

I don't know why but I'm unable to put this in code format on the forums. I haven't used the forums in awhile so I'm guessing they took that option out. So here's the code in quotes:

From: someone
integer CHANNEL = -654321;//Change this channel to your own value.
integer Handle; // For tempoarary listener.
list MENU_PANEL = ["Give Test", "Clicks", "IDs"];//Owners Menu
integer GivenAmount = 0; //How many items have I given.
string RecentName; // The recent name of the customer.
key ClickID; //The recent key of the customer.

key Stage1; //Memory keys
key Stage2;
key Stage3;
key Stage4;
key Stage5;
string Name1; //Memory names.
string Name2;
string Name3;
string Name4;
string Name5;

GiveIt()
{
//Give your items here.
llGiveInventory(ClickID, "Your Demo Object";);
llGiveInventory(ClickID, "Your Demo Manual or Landmark";);
llInstantMessage(llGetOwner(),"Your Demo vendor gave items to: " + (string)RecentName);
}
SetStages()
{
//Rotate ID's in memory.
//Must be calculated in reverse order as displayed. Otherwise the key will pass all stages with one click.
Stage5 = Stage4;
Stage4 = Stage3;
Stage3 = Stage2;
Stage2 = Stage1;
Stage1 = ClickID;

Name5 = Name4;
Name4 = Name3;
Name3 = Name2;
Name2 = Name1;
Name1 = RecentName;
}

default
{
state_entry()
{
llSetTimerEvent(21600);//Sets timer for 6 hours.
}
touch_start(integer total_number)
{
ClickID = llDetectedKey(0);//Get the ID of the person clicking.
RecentName = llDetectedName(0);
if (ClickID == llGetOwner())
{
//This area only activates if the vendor see's the owner clicking.

llListenRemove(Handle);//Ensure listens are not stacking.
Handle = llListen(CHANNEL, "", NULL_KEY, "";);//Make new listener.
llDialog(llGetOwner(), "OWNER OPTIONS:", MENU_PANEL, CHANNEL);//Give owner the menu.

}
else if (ClickID != llGetOwner())
{
//This area only activates if someone other than the owner has clicked the vendor.

if (ClickID != Stage1 && ClickID != Stage2 && ClickID != Stage3 && ClickID != Stage4 && ClickID != Stage5)
{
//This area only activates if the person currently clicking is not in any stage of memory.
GiveIt();
GivenAmount = GivenAmount + 1;
SetStages();

//If you use a server object to log daily customer transactions, for demographic data, you could also use this area to email and update the server.
}
else
{
//This area activates if the person clicking is found in memory.
llInstantMessage(ClickID, "Sorry you have clicked this vendor recently. Try again in 6 hours.";);
}
}
}
listen(integer channel, string name, key id, string message)
{
if(id != llGetOwner()) {return;}// prevents others from abusing your vendor.

if (llListFindList(MENU_PANEL, [message]) != -1)
{
//Events for menu buttons.
if (message == "Give Test";)
{
//
GiveIt();
llListenRemove(Handle);
}
if (message == "Clicks";)
{
//How many clicks this vendor has.
llInstantMessage(llGetOwner(), "This vendor has been clicked " + (string)GivenAmount + " times.";);
llListenRemove(Handle);
}
if (message == "IDs";)
{
//Show names of those people in memory.
//These values can also be useful in updating a external customer server.
//Rather than the llOwnerSay command you could put these values into an llEmail command to your main server.
llOwnerSay("Recent clicks by: " +(string)Name1 + ", "+(string)Name2 + ", "+(string)Name3 + ", "+(string)Name4+ ", "+(string)Name5);
}
}
}
timer()
{
llListenRemove(Handle);//Removes listener if left on due to server lag issues.

//Reset all keys in memory.
ClickID = "";
Stage1 = "";
Stage2 = "";
Stage3 = "";
Stage4 = "";
Stage5 = "";
Name1 = "";
Name2 = "";
Name3 = "";
Name4 = "";
Name5 = "";
//You could just place the llResetScript(); command here.
//However if you need other values to stay after the timer goes off you'll need to reset each memory value manually as displayed above.
//Such as the GivenAmount value. I wish for that to stay after the 6 hour reset.
//I personally would rather reset the script myself if I find it nessesary.
}
}


I'm sure others could shorten this code up a bit.
But it should work as is.
Setup requires you to place this code in a single prim. Along with your demo objects. And change the name to your object under the GiveIt() section.
I use demo objects that have sell kill timers. They work fine as long as the demo version is no-mod/no-copy.

Here is a demo script with a self kill after 5 minutes.
From: someone

integer TimeLeft = 300;
integer AlreadyRezed = FALSE;

default
{
on_rez(integer RezAmount)
{
if (AlreadyRezed == FALSE)
{
AlreadyRezed = TRUE;
TimeLeft = 300;
llOwnerSay("5 Minute demo started. Timer only counts while this product is rezed. Take item back to inventory to pause timer as needed.";);
llSetTimerEvent(1);
}
}
timer()
{
if(TimeLeft == 60)
{
llOwnerSay("Demo has 60 seconds left.";);
}
if(TimeLeft <= 0)
{
llOwnerSay("Demo Timer elapsed.. deleting.";);
llDie();
}
else if (TimeLeft >= 1)
{
TimeLeft = TimeLeft - 1;
}
}
}

Remember this demo script only works right if the object is NO-Mod and NO-copy. So people can't take the script out and copy the demo object to bypass the timer.
Hope these are useful. :D
_____________________
Doofus Mayo
Registered User
Join date: 7 Jun 2007
Posts: 33
Not sure that works?
09-18-2007 03:18
Just a thought on your self kill script for demo items.
Cant people just delete the scripts in the demo object, even if it is no Mod?