Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Changing a script to recognize group/owner...help

Danika Boucher
Registered User
Join date: 10 Jun 2008
Posts: 11
12-19-2008 19:07
Hi I need a general addition to a script which will alllow either anyone or anyone in the same group to access the object...... I need to change a few scripts that only allow those on a list (in the script) to access the object.

I would prefer not to have to change the access list on a script to recognize myself or any other person in the same group. Since I am new ...ok i don't script but do change them alot.... I need the help of those who script .

I figure it is fairly simple and I just need to add a simple line or so.....
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
12-19-2008 21:41
The function you want is llSameGroup(). Take a look in the LSL wiki at http://lslwiki.net/lslwiki/wakka.php?wakka=llSameGroup. You'll just need to add a test like

CODE

key id = llDetectedKey(0);
if (llSameGroup(id)== TRUE)
{
// Then do all your stuff
}
Billybob Flatley
Registered User
Join date: 9 Nov 2007
Posts: 36
12-20-2008 06:30
What I would like to do is change a money giver script so it only pays if you are wearing the group tag. I have the object deeded to the group I want to use. What do I need to do to the script. Im not very good at scripting at all.
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
12-20-2008 06:44
From: Billybob Flatley
What I would like to do is change a money giver script so it only pays if you are wearing the group tag. I have the object deeded to the group I want to use. What do I need to do to the script. .
Find the touch_start event, and do something like this:
CODE

touch_start(integer total_number)
{
integer i;
for(i=0;i<total_number;i++)
{
if( llDetectedGroup(i)==FALSE )
{
llSay(0, "Sorry, " + llDetectedName(i) + " but I'm not giving you anything because you're not wearing the right group tag.");
}
else
{
llSay(0, "Good news, " + llDetectedName(i) + " you are wearing the right tag, so you get the money.");
// plus whatever it does to give them money, obviously.
}
}
}

}
Billybob Flatley
Registered User
Join date: 9 Nov 2007
Posts: 36
12-20-2008 07:47
i got that to work only by putting it at the end of the script. it pays out before it asks about group
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
12-20-2008 08:37
Without seeing your script, I can't really comment. I had assumed -- mistakenly, it would appear -- that you have to touch the object to get it to pay you. Your script seems to use a different method.

Anyway, you've clearly grasped the logic -- once the script knows with whom it's interacting, be it because they've touched something, or spoken to it or collided with it or whatever, use some variant of if (llSameGroup(id) == TRUE ) to check if they're in the same group before you do anything else.
Billybob Flatley
Registered User
Join date: 9 Nov 2007
Posts: 36
12-21-2008 03:07
integer amount=02;// how much you wanna give away

default//this is the normal state we are used to, call it the first one
{
touch_start(integer num_detected)
{
if(llDetectedKey(0)==llGetOwner())
{
llRequestPermissions(llGetOwner(), PERMISSION_DEBIT);//asks for permission to give out L$
}
}

run_time_permissions(integer perm)
{
if (perm & PERMISSION_DEBIT)
{
llOwnerSay("Permissions passed...ready to work";);
state run; //if you give it permission it goes to the next state
}
else
{
llOwnerSay("Invalid Permissions...resetting now";);
state reset; //if not it goes to the reset state
}
}
changed(integer change) { // something changed
if (change & CHANGED_OWNER) { state reset;}}
}


state run // the state what runs (the main one in this case)
{
state_entry()
{

llOwnerSay("Ok its time to give out some L$";);
}


touch_start(integer total_number)
{
llGiveMoney(llDetectedKey(0),amount);
state sleep; // The state that sleeps (massachuesetttes?)
}

}


state reset // Saves writing llResetScript all ove the place
{
state_entry()
{
llResetScript();
}
}
state sleep // The sleepy bit sets the time and then goes to the main state
{
state_entry()
{
llSetTimerEvent(00060);
}
timer()
{
state run;
}
touch_start(integer total_number)
{
integer i;
for(i=0;i<total_number;i++)
{
if( llDetectedGroup(i)==FALSE )
{
llSay(0, "Sorry, " + llDetectedName(i) + " but I'm not giving you anything because you're not wearing the right group tag.";);
}
else
{
llSay(0, "Good news, " + llDetectedName(i) + " you are wearing the right tag, so you get the money.";);
// plus whatever it does to give them money, obviously.
}
}
}

}
I cant seem to find the right place to put the get group id so heres the script. One other thing also If im right here this will allow the giver to reset every hour. is that just for the person who touched it or can someone else touch it to take ? In other words is the hour reset on each person?