Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Scripting help

Cheynnne Beaumont
Registered User
Join date: 25 Jun 2007
Posts: 43
09-08-2007 22:29
I have a sign that I'm using to advertise. The sign contains a landmark and notecard and the user has to click and buy for 0 lindens to take the notecard and LM. Is there a way I can add a script to the sign that will tell me how many times it has been clicked?
Oryx Tempel
Registered User
Join date: 8 Nov 2006
Posts: 7,663
09-08-2007 23:47
From: Cheynnne Beaumont
I have a sign that I'm using to advertise. The sign contains a landmark and notecard and the user has to click and buy for 0 lindens to take the notecard and LM. Is there a way I can add a script to the sign that will tell me how many times it has been clicked?

If it's a sale for L$0, it will show up in your transaction history, I think. You can check that daily on the SL website.

Otherwise, you can add a couple of lines to the script that make a list of all those who click on it.

Just curious, why make it a sale for L$0? Why not just give out upon click?
_____________________
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
09-09-2007 00:08
Before ruminating on how such a script might work, I'd just observe that this is a kinda strange way for a notecard/landmark giver to work because, if the takers really Buy for L$0, they'll be getting the sign as well as its contents, and they'll have to rez the sign and get the landmark and notecard from inside. Is that really the way it's supposed to work? (Instead, such things usually give the desired contents on a simple mouseclick, and then record what they've done either with a simple counter or a list of recent recipient names.) If it really works this way, the account transaction history will be full of L$0 transactions, by the way, so one could go in there and count them up, and even know the names of everybody who picked up copies of the sign.

If it really wants to be a "Buy" interface, then it could contain a script that reacted to a CHANGED_OWNER event: if it's running in the original sign (llGetOwner() == the sign's rightful owner), then it counts the event; if it's running in a copy of the sign, the script just deletes itself.

What I'm afraid is happening, though, is that the "Buy" operation is selling the *contents* of the sign, in which case counting is actually impossible: No event is triggered in the original sign when this is done, so there's nothing for a script to count. (If the contents included an object, a script in that object would get that CHANGED_OWNER event when it was first rezzed in-world, and then in theory it could do something like email an in-world "counting" server... but that's no help in this case.)
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
09-09-2007 01:55
I modified a standard notecard giver to IM me when the notecard is given out, if you have IM -> email on, you'll get emails when not online as well.

// Gives a note card to a person clicking on it.
//
string AvatarName;
string FLOAT_TEXT="Click for NoteCard/LM";
vector FLOAT_COLOR=<1.0,1.0,0.0>;
float FLOAT_ALPHA=1.0;


default
{

state_entry()
{
llWhisper(0, "Ready!";);
llSetText(FLOAT_TEXT, FLOAT_COLOR, FLOAT_ALPHA);
}

touch_start(integer total_number)
{
AvatarName = llDetectedName(0);
llRequestAgentData (llGetOwner(), DATA_ONLINE);
key giver;
giver = llDetectedKey(0);
string name = llDetectedName(0);

if (giver != NULL_KEY) {
integer InvNum;
string NoteName;
integer NumCards = llGetInventoryNumber(INVENTORY_NOTECARD);
for ( InvNum = 0; InvNum < NumCards; InvNum++) {
NoteName = llGetInventoryName(INVENTORY_NOTECARD, InvNum);
llGiveInventory(giver, NoteName);
}
}
}
dataserver (key queryid, string data)
{
vector ObjPos = llGetPos();
string SimName = llGetRegionName();

if (data == "1";)
{
llInstantMessage (llGetOwner(), AvatarName + " received notecard from sign at: " + SimName + ": (" + (string)ObjPos+";)";);
}
}
}
Yumi Murakami
DoIt!AttachTheEarOfACat!
Join date: 27 Sep 2005
Posts: 6,860
09-09-2007 05:49
The script above won't give a landmark, though..

From: someone

// Gives a note card to a person clicking on it.
//
string AvatarName;
string FLOAT_TEXT="Click for NoteCard/LM";
vector FLOAT_COLOR=<1.0,1.0,0.0>;
float FLOAT_ALPHA=1.0;
int clicks;

default
{

state_entry()
{
llWhisper(0, "Ready!";);
clicks = 0;
llSetText(FLOAT_TEXT, FLOAT_COLOR, FLOAT_ALPHA);
}

on_rez(integer junk) {
llResetScript();
}

touch_start(integer total_number)
{
key giver;
giver = llDetectedKey(0);

if (giver == llGetOwner()) {
llOwnerSay("I have given out " + (string)clicks + " notecards.";);
return;
}

if (giver != NULL_KEY) {
integer InvNum;
string ItemName;
integer NumItems = llGetInventoryNumber(INVENTORY_ALL);
clicks++;
for ( InvNum = 0; InvNum < NumItems; InvNum++) {
ItemName = llGetInventoryName(INVENTORY_ALL, InvNum);
if (llGetInventoryType(ItemName) != INVENTORY_SCRIPT) {
llGiveInventory(giver, ItemName);
}
}
}
}
}
Cheynnne Beaumont
Registered User
Join date: 25 Jun 2007
Posts: 43
09-09-2007 06:02
to be honest... I can't figure out the touch option works. No matter what settings I change, I can't get an option to touch?

When left clicked touch/grab, doesn't work? what am I not doing?
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
09-09-2007 06:17
Not sure of the current state. If Johan's script is running in the prim, then it will have a touch_start handler and should respond to a touch. (Glancing at the script, I think it *will* give both notecards and landmarks--and indeed everything contained in the prim except scripts.) But if the prim doesn't have a script inside that responds to touch, then "Touch" won't be available on the pie menu.
Cheynnne Beaumont
Registered User
Join date: 25 Jun 2007
Posts: 43
09-09-2007 06:23
oh, thank you!

That explains a lot!