Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Read from notecard help..

Dogs Roo
Registered User
Join date: 13 Feb 2005
Posts: 6
05-21-2005 09:53
Ok im sure this has been asked a million times..
The read from notecard system seems rather simple but im just not getting it working..
Im creating a very very simple complimentary vendor for my customers to use to give out free t shirts or things at there club or store of just plain for what ever reason..
The catch is that the vendor will be forced to give a small notecard with the item and this notecard will contain a simple message saying something like compliments of blah blah and if youd like one please visit my shop and then a landmark..
The problem was this..

#1 We all know just simply deleate this notecard and the vendor is now yours to use as you will and I gain nothing from the vendor I have given...

I know that this vendor is about as basic as it gets but its kinda got me stumped and would like to figure out what im doing wrong so I can use the read from notecard in some of my future scripts..


key c;
integer line;
list number;
integer i;


default
{
state_entry()
{
line = 0; ////init line to 0
c = llGetNotecardLine("INFO",line++); ////get line from notecard and store in line
number = []; /// guess this tells what section of the line to read from
llList2Integer(number,i); //// this should convert the line over to integer value in i
llSay(0, "Vendor Working";); ///just to tell the user there vendor is working
}

touch_start(integer total_number)
{
if (i == 1) //// if i is 1 then do all of below..
{
llGiveInventory(llGetOwner(), "INFO";);
llGiveInventory(llGetOwner(), "ITEM";);
llSay(0, "Enjoy Your Free Item.";);
}
}
}




Ok this script looks like it would work ..
but one of two things is happening here..

#1 either the value is just not being read in because of some stupid thing i missed.. lol
#2 my if statement isnt working...

I even figured that if line = 0; is being init to 0 that mabe the value of number eventually is stored into line and even tried if (line == 1)....
Anyway its not working.. lol
The items are being given no matter what the number is in the first line of the notecard..


HELP HELP HELP LOL PLEASE
Olmy Seraph
Valued Member
Join date: 1 Nov 2004
Posts: 502
05-21-2005 10:05
I'm don't understand what the notecard is supposed to do. If you are giving it as a notecard, why are you trying to read its contents?

If you really want to read the notecard lines, you are missing a crucial piece. The llGetNotecardLine() call doesn't return anything. It submits a request to the asset server, and the data is returned to the script via a dataserver event about 0.1 second later. Anything you want to do with the data from the notecard you'll need to do in the dataserver event. If you want to process multiple lines, you'll need to keep a line counter around and call llGetNotecardLine() again at the end of the dataserver event handler. Check out the wiki page for more info and an example of use.

Also, I'd recommend using llGiveInventoryList() so the multiple items show up in a top-level category folder, so the notecard is right next to the items and doesn't get lost in the inventory.
_____________________
Some people are like Slinkies... not really good for anything, but they sure bring a smile to your face when you push them down the stairs.
Dogs Roo
Registered User
Join date: 13 Feb 2005
Posts: 6
05-21-2005 10:52
The notecard I want to set so that it cant be modified by anyone...
I dont really care what the first line is, could be Hello as far as i care lol...
But the reason for the reading from the notecard is so that if the notecard is removed or tampered with then the script wont give the item..
then was going to use an else to whisper the vendor has been tampered with if the notecard was removed or someone tried to replace it with a diff one...

Its more of a script im playing around with just to learn how to take something from a line of a notecard and get that value or string back and store it someplace that will effect the script..

Is there any examples that anyone may have doing something like this..?
Olmy Seraph
Valued Member
Join date: 1 Nov 2004
Posts: 502
05-21-2005 11:35
If you set the permissions on the notecard to no-mod, then you can use llGetInventoryCreator() to make sure it's a notecard you created. You still might have to worry about someone taking one of your mod notecards and changing the contents then setting the permissions to no-mod, but you can use llMD5String() to generate a signature to prevent that kind of tampering.

There are a number of scripts in the script library forum that use notecards. Try this one: /15/0a/33517/1.html
_____________________
Some people are like Slinkies... not really good for anything, but they sure bring a smile to your face when you push them down the stairs.
Keknehv Psaltery
Hacker
Join date: 11 Apr 2005
Posts: 1,185
05-21-2005 16:49
From: Olmy Seraph
If you set the permissions on the notecard to no-mod, then you can use llGetInventoryCreator() to make sure it's a notecard you created. You still might have to worry about someone taking one of your mod notecards and changing the contents then setting the permissions to no-mod, but you can use llMD5String() to generate a signature to prevent that kind of tampering.

There are a number of scripts in the script library forum that use notecards. Try this one: /15/0a/33517/1.html


If that's too much trouble, you can just encode some messages into the script, so that it would IM the avatar with the information. That way you don't have to worry about tampering.
Dogs Roo
Registered User
Join date: 13 Feb 2005
Posts: 6
Thanks everyone
05-22-2005 12:57
I just want to thank everyone for there great info ...
I looked at the info from the wikki and funny no wonder i was getting nowhere fast lol..
Thanks very much for all the help..
Dogs Roo
Registered User
Join date: 13 Feb 2005
Posts: 6
05-23-2005 12:59
Ok I hate to bug about this still..
I looked in to how the scripting works for reading from a notecard..
I see it seems quite simple..

I got this example from the wikki

string gName = "Testnotecard"; // name of a notecard in the object's inventory
integer gLine = 0; // current line number


default {
state_entry() {
llGetNotecardLine(gName, gLine); // request first line
gLine++; // increase line count
}

dataserver(key query_id, string data) {
if (data != EOF) { // not at the end of the notecard
llSay(0, data); // output the line
llGetNotecardLine(gName, gLine); // request next line
gLine++; // increase line count
}
}
}


Here is my problem...
I really dont want to have someone else write this for me..
Its sopose to be for me to learn with lol...
But I just may need someones help here..

My guess is that the dataserver is returning the value back to the script as a string value at a defualt location called data...
If im wrong please set me strait..
Well this script is working fine above, but lets say I wanted to insted of outputing the string to the screen from the first line of the notecard that maybe I wanted to use that string as a setting for something in my script..
I know this is done all the time but the problem im having is this..
Can i change the type from string to integer..?

Example

If (data == 12345)

do whatever...

else reload script


Now I could put 12345 on the first line of the notecard and that would become a useable value for my script..
When I try to do this its of course of type mismatch..
How do I use this system for integer values that will efect a event or be stored in a location that I can use other then data..?

I hope everyone understands where the problem is for me...
at this point I dont even mind if you show me code.. lol
Id just like to figure this out lol..

Thanks for any help anyone can give..
Ushuaia Tokugawa
Nobody of Consequence
Join date: 22 Mar 2005
Posts: 268
05-23-2005 13:25
From: Dogs Roo

Can i change the type from string to integer..?


You can typecast the data variable to an integer.

CODE

dataserver(key query_id, string data) {
if (data != EOF) { // not at the end of the notecard
integer number = (integer)data;

if (number == 12345) {
doWhatever();
}
}
}

Keknehv Psaltery
Hacker
Join date: 11 Apr 2005
Posts: 1,185
05-23-2005 13:41
Or, even more efficiently,
CODE

dataserver(key query_id, string data) {
if (data != EOF) { // not at the end of the notecard
if ((integer)data == 12345) {
doWhatever();
}
}
}


But I'm still confused... why are you trying to read messages from the notecard?
Dogs Roo
Registered User
Join date: 13 Feb 2005
Posts: 6
05-23-2005 23:19
LOL.. Ill try to explain it agian..
Im making a advertisment vendor free..
It will give out anything they put in the contents mostly shirts ill provide them with there bussiness logo on them...
The catch is that its going to give a notecard as well and in that notecard its going to say compliments of blah blah to get your free t shirt with your logo and a free vendor go here.. and then my landmark to my store..

But people are going to just remove that notecard or clean it out and put there own stuff in insted..

To protect what is on the notecard I want to make it so that you cant edit the notecard that fixes that problem..
But you can deleate it and just put one in with the same name with your own info...

So on the first line I want to have a code or just text maybe the entire warning that if its removed that it wont work anymore..
Then if the notecard is removed or changed the vendor will display that they have violated the rights that where given to them and the vendor will no longer funtion...


This is a learning project as well...
I plan to use the read from notecard in other scripts as well.. so id like to know how to convert it to both integer and the string both because ill be using both in the future..

I hope you know understand what im doing..

You guys have been great help by the way.. thanks very much.. ill try what has been posted and see if that is what im looking for.. thanks agian..
Olmy Seraph
Valued Member
Join date: 1 Nov 2004
Posts: 502
05-24-2005 08:14
Dogs, it seems like you are committed to doing something a particular way, as your learning exercise. I'd suggest that if you really want to learn, you should take the advice of more experienced scripters and try a different approach. There are many toy projects you could better use to learn how to read from notecards. Your needs for maintaining integrity of your build are best addressed with either embedding the advertising plug as text in the script, or checking the notecard in other ways. If you really want to do it by reading the notecard contents, use the MD5 check I suggested before.

By the way, there are a number of good freebie vendors available, and I'm not sure how much of a market there would be for the system you have described. Giving out a bunch of t-shirts can be done with a very short touch-start handler that just calls llGiveInventoryList. I'm not sure how much you'd be able to charge for that, even just as advertising.
_____________________
Some people are like Slinkies... not really good for anything, but they sure bring a smile to your face when you push them down the stairs.
Dogs Roo
Registered User
Join date: 13 Feb 2005
Posts: 6
05-24-2005 14:47
Ok lol..
Everyone is taking me wrong here..
I dont want to make any money off the vendor at all..
I simply want it to give out a notecard with some info that no one can remove..
Yes i have taken it into consideration just haveing the script whisper it when someone uses the vendor..
But that is a one time thing and dosnt give them a landmark to my store..
Now if there is a way to script landmarks without haveing to use an actual landmark then id consider this approch as it would have been done a long time ago then lol..
But as far as i knew you had to drop a landmark into the contents of the object and then the vendor would give that landmark..This is not what I want again.. as its simple for someone to remove this landmark and replace it with there own..
Maybe insted of reading from notecard..
Maybe there is a way to verify the landmark being given..
So that vendor will only work if that land mark is present and if the landmark has been removed from the vendor then it wont work anymore...
That i would consider as an alternative ...


The scripting of sl is a bit different and im just messing around with it right now..
So bare with me as im pretty much a newbie to sl scripts..

If there is a way to script a landmark without actually haveing to drop one into the contents then id rather do it that way.. would be much simpler im sure..

Thanks again for your advise and help..
Coldfire Nightfire
Registered User
Join date: 25 May 2008
Posts: 48
this might help
01-31-2009 13:29
I found this to protact scripts might be able to mod for notecards

Non-Portable Script

--------------------------------------------------------------------------------

Here is a generic little function that can prevent people from ripping your scripts from the items you make and stuffing them into Objects that you did not create.
Change Variables and Funcionality as needed.

//-----------------------------------------------------------------------------------
// NON-PORTABLE SCRIPT FUNCTION
// By
// Mitzpatrick Fitzsimmons
//-----------------------------------------------------------------------------------
// This little function is based on something I use to prevent
// some of my scripts from being ripped out of my creations
// and re-used in something I did not make.
// This particular function is not 100% foolproof, but generally gets the job done.
// Feel free to mod this to make it 100% foolproof for your usage.
//-----------------------------------------------------------------------------------


CheckSum()
{
key ObjectCreator = llGetCreator(); // The UUID of the Creator this script is in (might not be you!)
key Scripter = "YOUR UUID HERE"; // Hard-code YOUR UUID here
key ObjectOwner = llGetOwner(); // The Owner of the Object this script is in

if(ObjectCreator != Scripter) // The Creator of the Object this script is in does not match the Script Creator (you)
{
// UNCOMMENT ANY OPTIONS BELOW TO TAKE THE APPROPRIATE ACTION (OR MAKE YOUR OWN)

llSay(0, "You have violated the rights to use this script.";); // Say a Message to the Owner of this violation
//llInstantMessage(Scripter, llKey2Name(ObjectOwner) + " has violated your script usage terms.";); // Send yourself a message about the violation
//llRemoveInventory("THIS SCRIPT NAME";); // Delete this script from the Object's Inventory
// llDie(); // Delete the Entire Object

}
}

default
{
state_entry()
{
CheckSum();
}
}

Hope that helps out
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
Um..... maybe this should have been a new thread?
01-31-2009 14:03
This thread's a zombie, 3 1/2 years old. :rolleyes:
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
01-31-2009 15:30
From: Rolig Loon
This thread's a zombie, 3 1/2 years old. :rolleyes:

Yep! I don't think it's a necropost record but it is up there!
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum