Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

automatically create unic notecard

Perl Hallstrom
Registered User
Join date: 12 Jun 2007
Posts: 33
11-18-2009 18:53
I need a way to automatically create a notecard with a uniqe number in it The number should be created randomly. The number will be used as a certificate or licensenumber and the notcard will be put i a box together with some objects to be sold.

The buyer of the box shall use the licencenumber in case he needs support.

I havent found any way to create notecards automatically.

If this is not possible do you know any other way to have a unique identification of the bought object.

/Perl
Viktoria Dovgal
Join date: 29 Jul 2007
Posts: 3,593
11-18-2009 19:11
The only way you can create a notecard automatically, is with a bot. LSL can't do that.

You might be happier tracking stuff like this with a web service.
Perl Hallstrom
Registered User
Join date: 12 Jun 2007
Posts: 33
What is a bot
11-18-2009 19:21
Can you tell me more what a bot is? And how I can use it.
What I want is that the buyer should buy a box and somehow in that box there should be a unique identification number.

In waht wasy this is created is not so important.

/Per
Viktoria Dovgal
Join date: 29 Jul 2007
Posts: 3,593
11-18-2009 19:32
A bot is just a regular avatar that is logged in with an automated client (only avatars can make notecaerds, there is no LSL function to do this). Most such things are built around libopenmetaverse. There are quite a few SL bots and lightweight clients around for sale, for free, and as roll-your-own kits (including examples that come with libomv). A little web searching will kind of be required for this one, you'll want to evaluate what's out there for yourself.
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
11-18-2009 20:31
From: Perl Hallstrom
Can you tell me more what a bot is? And how I can use it.
What I want is that the buyer should buy a box and somehow in that box there should be a unique identification number.

In waht wasy this is created is not so important.

/Per
If you mean "somewhere in that box there should be a unique identification number" literally, you could make the box no mod and try something like this, I think:
CODE
default
{
state_entry()
{
//llSay(0, "Hello, Avatar!");
}

touch_start(integer total_number)
{
llOwnerSay(llGetObjectDesc());
}

on_rez(integer p){
integer id;
if(llGetObjectDesc()==""||llGetObjectDesc()=="(No Description)"){
id = -1*((integer)("0x"+llGetSubString((string)llGetKey(),-8,-1)) & 0x3FFFFFFF) ^ 0xBFFFFFFF;
llSetObjectDesc((string)id);
}
}
}
What this does is, the first time the box is rezzed (i.e. the description field is blank or says ";(No Description)" -- I'm never sure when it says which), it generates a number based on the box's uuid and puts it into the box's description field. It won't do this again, since the field is no longer blank, and if the box is no-mod, it can't be changed or altered.

You'd have to figure out a way of having the box communicate its number to you, using llEmail, I guess, or sending it to an off-world web server, but I think this might well be the solution. It's not guaranteed to be a unique number but the chances of the numbers being duplicated are vanishingly small.
ElQ Homewood
Sleeps Professionally
Join date: 25 Apr 2007
Posts: 280
11-19-2009 01:02
yes, for decent scalability of a registration system you'd need to generate the number such as Innula did there, and then communicate that to an offworld database. Now, if the box is a container for your item(s), this will cause problems. The only way to really effectively do this to my way of thinking would be with a no mod item. Otherwise you will have people deleting the container and the registration has gotten you nowhere.
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
11-19-2009 02:45
I guess maybe you could have a no-copy, no mod "guarantee prim" the buyer rezzed (and you make the script it contains no transfer), and tell them to keep that safe.

Why do you need this, may I ask? Depending on the rights you set for the product, I'm pretty sure there are simpler and more robust ways of making sure you end up providing support only for bona fide products.
Perl Hallstrom
Registered User
Join date: 12 Jun 2007
Posts: 33
11-19-2009 16:58
Thank you for the help. I have used the example with creating a unik number by using the identity.
My idea behind this is to add a gift card to the box. But I have to check so that noone uses this gift card more tna ones. I have a communication with a webserver so I can check that.

I have tested and its working pretty well.

The idea is that when you want to use the card you rez it on the ground. And at that moment the unique key is generated and registered in my webserver. When you touch the card you can purchace some new stuff from me. And in this way you can use the card only ones.

You can also give the card to someone else and tha person can use it in the same way.

But I noticed a problem. I you dont rez the card on the gound but instead wear it. You can also use it. But in that case the solution doesnt work. In that way you can use it many times. And each time you wear it you get anew key.

So it you have any idea on how to avoid this. A way to detect that someone is wearing the card or a way to stop them from wearing it and just allow them to rez it on the ground.
Ron Khondji
Entirely unlike.
Join date: 6 Jan 2007
Posts: 224
11-19-2009 22:04
You can check if the thing is attached and then tell the wearer it only works if they rezz on the floor.

From the wiki: http://wiki.secondlife.com/wiki/LlDetachFromAvatar

CODE


default
{
attach(key AvatarKey)
{//give instructions for use and prevent item from being attached to avatar
if(AvatarKey)
{//event is called on both attach and detatch, but Key is only valid on attach
llOwnerSay ("
We hope you will enjoy your purchase,
but if you really want to use this item properly, you should:
1) drag it from your inventory to the ground
2) Right click on it and select \"open\"
3) copy its contents to inventory.");

llRequestPermissions(AvatarKey, PERMISSION_ATTACH );
}
}
run_time_permissions(integer perm)
{
if(perm & PERMISSION_ATTACH)
{
llDetachFromAvatar( );
}
}
}
Perl Hallstrom
Registered User
Join date: 12 Jun 2007
Posts: 33
11-20-2009 03:00
Thanks for all help from everybody.

My script is now working well.