Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Allowed users list notecard script

Thorne Kaiser
Nice Guy
Join date: 29 Nov 2005
Posts: 132
03-06-2006 18:22
Could someone kindly post a script with notecard that will only allow users on the list to touch/use and object? I am having a hard time grasping the notecard protocol and would be very greatful to anyone who could assist me.

:)
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
03-06-2006 21:29
Assuming the notecard doesn't have hundreds of lines, what you want to do is read the notecard into a list, and then when someone interacts with the object, check if their name is on the list of allowed users.

And the notecard "protocol" - you call llGetNextNotecardLine, starting at line number 0. The text in that line comes back in a dataserver() event. so you process the data (in this case, add it to a list or whatever), increment the variable that tracks the current line number, and call llGetNotecardLine again. Eventually you'll hit the end of the notecard, and the dataserver event will get EOF (end of file). Then you know you're done, and can stop trying to read the next line in the notecard.

So something like...

CODE

list users = [];
integer lineNum = 0;

default
{
state_entry()
{
llGetNotecardLine("NotecardName", lineNum);
}

dataserver(key id, string data)
{
if (data != EOF) // Not EOF, so we're still reading lines
{
users += [data]; // Assuming each line of the notecard is a name
lineNum++; // Go read the next line
llGetNotecardLine("NotecardName", lineNum);
}
}

touch_start(integer num)
{
// See if this person's name is on the list
string userName = llDetectedName(0);
if (llListFindList(users, [userName]) != -1)
{
// He's on the list. Do whatever you need to do...
}
}
}


Not tested in-world so it probably has some errors, but that's the basic flow of the logic.