Jump to content
Krystara

change active group

You are about to reply to a thread that has been inactive for 871 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

 

I am curious, does there exist any way, through LSL script, for a player to change the active group with a script?

Assuming you know exactly what group you are in and going to, and are a member of the group.

Share this post


Link to post
Share on other sites

Just for the sake of completeness, there is a way if the person whose group is to be changed uses RLV.   Then you can do it with @setgroup.   But of course you can't normally rely on people using RLV, so that's probably not much help.

Share this post


Link to post
Share on other sites

 

No, thats awesome, I am using it for my own purposes, and I dont mind running with rlv enabled, I usually do anyhow.  Thanks a ton.  Now to continue investigating the idea then.  

 

 

Share this post


Link to post
Share on other sites

I have just the script you want I think, made it with a friend a few months ago.

 

list settings=["sim 1", "group 1","sim 2", "group 2"];integer msgchan=614523;integer locked=0;string unlockedgroup="default group"; string nogroup="none";integer groupwait=0;float scan_range = 50.0;float scan_interval = 10.0;string scanner_target_avatar = "MyBestFriend Resident";string group_on_scanner = "His Favourite Group";restoregroup(){    llOwnerSay("@setgroup=y,setgroup:"+nogroup+"=force");}setgroup(string g){    setlock(1);    llOwnerSay("@setgroup=y,setgroup:"+g+"=force");}cleargroup(){    setlock(0);    llOwnerSay("@setgroup=y,setgroup:"+unlockedgroup+"=force");    llOwnerSay("You are free to change your group now.  (use \"/1 lockgroup\" to lock-in the group for this sim)");}unlockgroup(){    setlock(2);    llOwnerSay("@setgroup=y");}setlock(integer i){    if (locked==i) return;    if (i==1)    {        groupwait=1;        llOwnerSay("@getgroup="+(string)msgchan);    }    locked=i;}update(){    string region=llGetRegionName();    integer i;    for (i=0; i<llGetListLength(settings); i+=2)    {        if (region==llList2String(settings, i))        {            llOwnerSay("setting group " + llList2String(settings, i+1) + " for region " + region);            setgroup(llList2String(settings, i+1));                        return;        }    }    if (locked) cleargroup();}    default{    state_entry()    {        update();                llListen(msgchan, "", llGetOwner(), "");        llListen(1, "", llGetOwner(), "");        llSensorRepeat("", "", AGENT, scan_range, PI, scan_interval);            }        on_rez(integer i)    {        update();    }        listen(integer channel, string name, key sender, string msg)    {        if (channel==1)        {            if (msg=="lockgroup" && !locked)            {                locked=1;                llOwnerSay("Group fixed for "+llGetRegionName()+"!");                groupwait=2;                llOwnerSay("@getgroup="+(string)msgchan);            }else if (msg=="list")            {                string str="\nlist settings=[\n";                string endcap=,\n";                integer i;                for (i=0; i<llGetListLength(settings); i+=2)                {                    if (i==llGetListLength(settings)-2) endcap="\n";                                        str+="\""+llList2String(settings, i)+"\", \""+                    llList2String(settings, i+1)+"\""+endcap;                }                str+=];";                llOwnerSay(str);            }            else if (msg == "unlockgroup")            {                cleargroup();            }            else if (llSubStringIndex(msg, "setdefault") >= 0)             {                unlockedgroup = llGetSubString(msg, llSubStringIndex(msg, " ")+1, llStringLength(msg)-1);                cleargroup();                update();            }        } else if (groupwait)        {            if (groupwait==2)            {                settings+=[llGetRegionName(), msg];            }            groupwait=0;        }    }        changed(integer change)    {        if (change & CHANGED_OWNER)        {            llResetScript();        }        if (change & CHANGED_REGION)        {            update();        }    }    sensor(integer num_detected)    {        integer i = -1;        while (num_detected > ++i)        {            if (llToLower(llDetectedName(i)) == llToLower(scanner_target_avatar))            {                setgroup(group_on_scanner);                return;            }        }    }        }

 

Caveat: due to a bug in @setgroup() this will not work if the group name contains a comma (confirmed by Marine Kelley) and probably several other characters like equals sign, colon, etc. that have special meaning in RLV commands.
Marine is looking at ways to solve that without breaking existing code.

Caveat: requires group names. UUIDs are not supported because of LSL security issues.

  • Like 1

Share this post


Link to post
Share on other sites

i modified that script a bit... but i'm still not satisfied

//modified by Ray Zopf (Raz): notecard//17. Sept 2013 v0.7//todo: change notecard format from line each value to single line for group (place + group)//list settings=[//	"sim 1", "group 1",//	"sim 2", "group 2"//		];string 		SETTINGS_NC = "PlaceGroupNC";integer 		setChannel = 11;//string unlockedgroup="default group";string 		unlockedgroup="none";//friends//string scanner_target_avatar = "MyBestFriend Resident";//string group_on_scanner = "His Favourite Group";//internal variables//integer    	scanInterval = 256;//integer    	scanRange = 20;string 		NOGROUP="none";list 		PlaceGroupList = [ ]; integer    	comHandle = 0;integer    	comChannel = 0;key			aQuery = NULL_KEY;integer 		msgchan=614523;integer 		locked=0;integer 		groupwait=0;//PREDEFINED FUNCTIONS//where is that used?//restoregroup() {//	llOwnerSay("@setgroup=y,setgroup:"+NOGROUP+"=force");//}setgroup(string g) {	setlock(1);	llOwnerSay("@setgroup=y,setgroup:"+g+"=force");}cleargroup() {	setlock(0);	llOwnerSay("@setgroup=y,setgroup:"+unlockedgroup+"=force");	llOwnerSay("You are free to change your group now.  (use '\\"+(string)setChannel+ " lockgroup' to lock-in the group for this sim)");}//where is that used?//unlockgroup() {//	setlock(2);//	llOwnerSay("@setgroup=y");//}setlock(integer i) {	if (locked==i) return;	if (i==1) {		groupwait=1;		llOwnerSay("@getgroup="+(string)msgchan);	}	locked=i;}update() {		string region = llGetRegionName();	integer i = llListFindList(PlaceGroupList, (list)region);	if (i > -1) {		string group = llList2String(PlaceGroupList, i+1);		setgroup(group);		llOwnerSay("setting group '" + group + "' for region " + region);		return;	}	if (locked) cleargroup();}slist() {	string str="list settings=[\n";	integer i;	integer lenght = llGetListLength(PlaceGroupList);	for (i=0; i<lenght; i+=2) {		str+=llList2String(PlaceGroupList, i)+" , "+llList2String(PlaceGroupList, i+1)+"\n";	}			str+="];";			llOwnerSay("------ Region, Group ------");			llOwnerSay(str);}//MAINdefault{	state_entry()	{		aQuery = llGetNotecardLine(SETTINGS_NC,comHandle);				llListen(msgchan, "", llGetOwner(), "");		llListen(setChannel, "", llGetOwner(), "");		llOwnerSay("###### Automatic Group Changer started ######");		//		llSensorRepeat("", NULL_KEY, AGENT, scanRange, PI, scanInterval);	}	on_rez(integer i)	{		update();	}		changed(integer change) {		if (change & CHANGED_INVENTORY) {			llOwnerSay("old settings:");			slist();			PlaceGroupList = [];			comHandle = 0;			aQuery = llGetNotecardLine(SETTINGS_NC,comHandle);			llOwnerSay("Rereading settings-notecard "+(string)SETTINGS_NC+":");		}		if (change & CHANGED_REGION) update();		if (change & CHANGED_OWNER) llResetScript();	}	listen(integer channel, string name, key sender, string msg)	{		if (channel==setChannel) {			if (msg=="help") {				llOwnerSay("help; lockgroup, list, unlockgroup, setdefault 'group'");				jump zout;			}			if (msg=="lockgroup" && !locked) {				locked=1;				groupwait=2;				llOwnerSay("Group fixed for "+llGetRegionName()+"!");				llOwnerSay("@getgroup="+(string)msgchan);			} 			if (msg=="list") {				slist();				jump zout;			}			if (msg == "unlockgroup") {				cleargroup();				jump zout;			}			if (llSubStringIndex(msg, "setdefault") >= 0) {				unlockedgroup = llGetSubString(msg, llSubStringIndex(msg, " ")+1, llStringLength(msg)-1);				cleargroup();				update();				llOwnerSay("Defaultgroup set to: "+unlockedgroup);				jump zout;			}		} else if (groupwait) {			if (groupwait==2) PlaceGroupList+=[llGetRegionName(), msg];			groupwait=0;		}		@zout;	}//	sensor(integer num) {//		integer i = -1;//        while (num > ++i) {//friends//			if (llToLower(llDetectedName(i)) == llToLower(scanner_target_avatar)) {//				setgroup(group_on_scanner);//				return;//			}//		}//	}			//get presets from notecard	dataserver(key query_id,string data) {		if (query_id != aQuery) return;		if (data == EOF) {			slist();			update();			return;		}		PlaceGroupList += (list)data;		aQuery = llGetNotecardLine(SETTINGS_NC,++comHandle);	}}

 

Share this post


Link to post
Share on other sites

It's pretty clear how it works.  Innula explained that in this ancient thread five years ago ^^ and it's in the Listing Description for that product. ... "Note: This product requires an RLV compatible viewer."   9_9

Share this post


Link to post
Share on other sites
You are about to reply to a thread that has been inactive for 871 days.

Please take a moment to consider if this thread is worth bumping.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...