Jump to content

change active group


Krystara
 Share

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

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

Recommended Posts

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
Link to comment
Share on other sites

  • 7 months later...

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);	}}

 

Link to comment
Share on other sites

  • 4 years later...
You are about to reply to a thread that has been inactive for 2347 days.

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

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...