Jump to content

How to script an object so it only works for people with a specific group tag?


Bittenbite
 Share

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

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

Recommended Posts

25 minutes ago, Bittenbite said:

Hi there!

Just wondering... how do I script an object to only be interactive for people wearing a specific group tag? 

You just need to copy the group UUID. It is best to hard code it as a string. You can then use it for a conditional.

Link to comment
Share on other sites

//OnReportBoard         2-17-2019       addes "DA to role titles
//                      9-2-2018        debug  miissing ")" line 416
//                        8-28-2018        Add "Deputy Head" role
//                      1-30-2018        update offender on timer event
//                      11-13-2017    use llGetObjectDetails to obtain role
//                         10-16-2014  make double sided
//                      12-14-2012  rteplace & by && line 800
//                      9-22-2012        for debug - monitor Daryl Carter
//                        12-31-2011  move AurhorizedNames and Prefect list to roleServer
//                      12-10-2011  add null touch events
//                      11-25-2011
//                      11-18-2011  Add: get_offender_data, wait_http, wait_response, update_status  states
//                      11-11-2011        add staff watch feature
//                      8-23-2011        to open offender profile
//                        5-2-2012    notify watchers when offener enters sim
//
//
//Detectors notify OffenderBoard of offenders
//        message format = "offender"_<gOffenderUsername>_<gOffenderId>_<gOffenderOffense>
//
//  Poster Floating text in 3 lines
//            <offender DisplayName>
//             "On Report For"
//         <offense description>
//

///////////////////
// Snippets and HTTPRequest bits were taken from:
//~ RANDOM PROFILE PROJECTOR v5.4.5 by Debbie Trilling ~

// Get Profile Picture by Valentine Foxdale
// optmisation by SignpostMarv Martin
// workaround for WEB-1384 by Viktoria Dovgal:
//  try meta tag instead of img first, try img as backup in case meta breaks
string gPROFILE_KEY_PREFIX = "<meta name=\"imageid\" content=\"";
string gPROFILE_IMG_PREFIX = "<img alt=\"profile image\" src=\"http://secondlife.com/app/image/";

integer profile_key_prefix_length; // calculated from profile_key_prefix in state_entry()
integer profile_img_prefix_length; // calculated from profile_key_prefix in state_entry()
/////////////////////
key gDEFAULT_PROFILE_PIC_TEXTURE = "0dcad1e2-a40a-8977-247a-2a1a9c513687" ;
/////////////////////

integer gPOSTER_COMM_CHANNEL = -1939;
integer gDIALOG_CHANNEL = -194;
float gDATA_SERVER_TIMEOUT = 30.0;
float gTOUCH_RESPONSE_TIMEOUT = 15.0;
float gHTTP_TIMEOUT = 30.0;
float gSTATUS_UPDATE_INTERVAL = 60.0; //60.0 - 6.0 FOR DEBUG
string gINITIAL_STATUS = "In Sim";
//string gTEST_OFFENDER_NAME = "reilly.hastings";
integer gOFFENDER_BOARD_PRIM_NUMBER = 1;
integer gLOWEST_OFFENDER_PRIM_NUMBER = 2;
integer gNUMBER_DATA_ITEMS = 7;
float gLINK_MESSAGE_TIMEOUT = 5.0;
key gDARYL_CARTERS_ID = "0aac5621-de33-45af-b8a4-6c8d0881b270";//THIS AND 
string gGROUP_NAME = "Derriere Academy";//THIS IS WHAY YOU ARE ON ABOUT.THE REST IS POINTLESS IF YOU HAVE NO EXTERNAL SERVER SET UP

list gOffenderIds = [];
list gOffenderUsernames = [];
list gOffenderDisplayNames = [];
list gOffenderProfilePicIds = [];
list gOffenderStatuses = [];
list gOffenderOffenses = [];

integer gOffenderIndex = 0;
key gOffenderId = NULL_KEY;
string gOffenderUsername = "";
string gOffenderDisplayName = "";
key gOffenderProfilePicId = NULL_KEY;
string gOffenderStatus = gINITIAL_STATUS;
string gOffenderOffense = "";
string gOffenderFloatingText = "";

integer gReceivedDataCount = 0;
integer gPrimNumber;

key gOffenderHttpRequest = NULL_KEY;
key gOnLineQuery = NULL_KEY;

string gMessage = "";
list gParsedMessage = [];
string gMessageHeader = "";
string gMessageData = "";

list gDialogButtons = [ ];
key gToucherId = NULL_KEY;
string gToucherUsername = "";
integer gTouchedPrimNumber;

list gWatcherIds = [];
key gWatcherId;
integer gWatcherIndex;

//functions

save_offender_data( )
{
	//llOwnerSay( "saving offender data" );
	gMessage = "savEgOffenderIds_" + llList2CSV( gOffenderIds );
	llMessageLinked( LINK_THIS, 0, gMessage, NULL_KEY );
	llSleep( 0.1 );
	gMessage = "savEgOffenderUsernames_" + llList2CSV( gOffenderUsernames );
	llMessageLinked( LINK_THIS, 0, gMessage, NULL_KEY );
	llSleep( 0.1 );
	gMessage = "savEgOffenderDisplayNames_" + llList2CSV( gOffenderDisplayNames );
	llMessageLinked( LINK_THIS, 0, gMessage, NULL_KEY );
	llSleep( 0.1 );
	gMessage = "savEgOffenderProfilePicIds_" + llList2CSV( gOffenderProfilePicIds );
	llMessageLinked( LINK_THIS, 0, gMessage, NULL_KEY );
	llSleep( 0.1 );
	gMessage = "savEgOffenderStatuses_" + llList2CSV( gOffenderStatuses );
	llMessageLinked( LINK_THIS, 0, gMessage, NULL_KEY );
	llSleep( 0.1 );
	gMessage = "savEgOffenderOffenses_" + llList2CSV( gOffenderOffenses );
	llMessageLinked( LINK_THIS, 0, gMessage, NULL_KEY );
}

request_offender_data( )
{
	//llOwnerSay( "requesting offender data" );
	llMessageLinked( LINK_THIS, 0, "senDgOffenderIds",NULL_KEY );
	llSleep( 0.1 );
	llMessageLinked( LINK_THIS, 0, "senDgOffenderUsernames",NULL_KEY );
	llSleep( 0.1 );
	llMessageLinked( LINK_THIS, 0, "senDgOffenderDisplayNames",NULL_KEY );
	llSleep( 0.1 );
	llMessageLinked( LINK_THIS, 0, "senDgOffenderProfilePicIds",NULL_KEY );
	llSleep( 0.1 );
	llMessageLinked( LINK_THIS, 0, "senDgOffenderStatuses",NULL_KEY );
	llSleep( 0.1 );
	llMessageLinked( LINK_THIS, 0, "senDgOffenderOffenses",NULL_KEY );
	llSleep( 0.1 );
	llMessageLinked( LINK_THIS, 0, "senDgWatcherIds",NULL_KEY );
	llSleep( 0.1 );
	llMessageLinked( LINK_THIS, 0, "askGroupName",NULL_KEY );
	llSleep( 0.1 );

}

clear_poster( integer posterLinkNumber )
{
	list paramRules = [ PRIM_TEXT, "", < 0.0, 0.0, 0.0 >, 0.0,
		PRIM_TEXTURE, ALL_SIDES, gDEFAULT_PROFILE_PIC_TEXTURE, < 1.0, 1.0, 1.0 >, < 0, 0, 0 >, 0,
		PRIM_COLOR, ALL_SIDES, < 1.0, 1.0, 1.0 >, 0.0,
		PRIM_FULLBRIGHT, ALL_SIDES, FALSE ];
	llSetLinkPrimitiveParams( posterLinkNumber, paramRules );
}

clear_all_posters( )
{
	//clear all poster text and blank texture
	//llOwnerSay( "clearing all posters" );
	for( gPrimNumber = gLOWEST_OFFENDER_PRIM_NUMBER; gPrimNumber <= llGetNumberOfPrims( ); gPrimNumber++ )
	{
		clear_poster( gPrimNumber );
	}
}

set_poster( integer index )
{
	//llOwnerSay( "setting poster - index = " + (string) index );
	gOffenderFloatingText = llList2String( gOffenderDisplayNames, index ) + "\n" + llList2String(gOffenderUsernames, index ) + "\n" + "( " + llList2String( gOffenderStatuses, index ) +
		" )" + "\n On Report For \n" +  llList2String( gOffenderOffenses, index ) ;
	list paramRules = [ PRIM_TEXT, gOffenderFloatingText, < 0.0, 0.0, 0.0 >, 1.0,
		PRIM_TEXTURE, ALL_SIDES, llList2Key( gOffenderProfilePicIds, index ), < 1.0, 1.0, 1.0 >, < 0, 0, 0 >, 0,
		PRIM_COLOR, ALL_SIDES, < 1.0, 1.0, 1.0 >, 1.0,
		PRIM_FULLBRIGHT, ALL_SIDES, TRUE ];
	llSetLinkPrimitiveParams( gLOWEST_OFFENDER_PRIM_NUMBER + index, paramRules );
}

set_active_posters( )
{
	integer highestOffenderIndex = ( llGetListLength( gOffenderUsernames ) - 1 );
	gOffenderIndex = 0;
	while( gOffenderIndex <= highestOffenderIndex )
	{
		//llOwnerSay( "setting poster gOffenderIndex = " + (string) gOffenderIndex );
		set_poster( gOffenderIndex );
		gOffenderIndex++;
	}
}

delete_offender( )
{
	//remove the deleted entries from lists
	//llOwnerSay( "deleting offender - gOffenderIndex = " + (string) gOffenderIndex );
	gOffenderIds = llDeleteSubList( gOffenderIds, gOffenderIndex, gOffenderIndex );
	gOffenderUsernames = llDeleteSubList( gOffenderUsernames, gOffenderIndex, gOffenderIndex );
	gOffenderDisplayNames = llDeleteSubList( gOffenderDisplayNames, gOffenderIndex, gOffenderIndex );
	gOffenderProfilePicIds = llDeleteSubList( gOffenderProfilePicIds, gOffenderIndex, gOffenderIndex );
	gOffenderOffenses = llDeleteSubList( gOffenderOffenses, gOffenderIndex, gOffenderIndex );
	gOffenderStatuses = llDeleteSubList( gOffenderStatuses, gOffenderIndex, gOffenderIndex );
	gPrimNumber = gLOWEST_OFFENDER_PRIM_NUMBER +  llGetListLength( gOffenderUsernames ) ;
	clear_poster( gPrimNumber );
	set_active_posters( );
	save_offender_data( );
}

add_offender( )
{
	//llOwnerSay( "adding offender" );
	//llOwnerSay( "gHighestPosterLinkNumber = " + (string) gHighestPosterLinkNumber );
	if( llGetListLength( gOffenderUsernames ) >= llGetNumberOfPrims( ) - 1 )
	{
		//list full delete first(oldest) entry
		gOffenderIndex = 0;
		delete_offender(  );
	}
	//add offender data to lists
	gOffenderIds += gOffenderId;
	gOffenderUsernames += gOffenderUsername;
	gOffenderDisplayNames += gOffenderDisplayName;
	gOffenderProfilePicIds += gOffenderProfilePicId;
	gOffenderStatuses += gINITIAL_STATUS ;
	gOffenderOffenses += gOffenderOffense;
	set_active_posters( );
	save_offender_data( );
	notify_watchers( "add", llGetListLength( gOffenderIds ) - 1 );
}


save_watcher_data( )
{
	//llOwnerSay( "saving watcherer data" );
	gMessage = "savEgWatcherIds_" + llList2CSV( gWatcherIds );
	llMessageLinked( LINK_THIS, 0, gMessage, NULL_KEY );
}

add_watcher( )
{
	gWatcherIds += gWatcherId;
	save_watcher_data( );
	//llOwnerSay( "gWatcherIds = " + llList2CSV( gWatcherIds ) );
}

delete_watcher( integer watcherIndex )
{
	//llOwnerSay( "gWatcherIds = " + llList2CSV( gWatcherIds ) );
	gWatcherIds = llDeleteSubList( gWatcherIds, watcherIndex, watcherIndex );
	//llOwnerSay( "gWatcherIds = " + llList2CSV( gWatcherIds ) );
	save_watcher_data( );
}

notify_watchers( string change, integer offenderIndex )
{
	string offenderId = llList2String( gOffenderIds, offenderIndex );
	string offenderDisplayName = llList2String( gOffenderDisplayNames, offenderIndex );
	string offenderOffense = llList2String( gOffenderOffenses, offenderIndex );
	string offenderLink = "secondlife:///app/agent/"  + offenderId  + "/about" ;
	if( change == "add" )
	{
		gMessage = offenderDisplayName + " has just been put on report for " + offenderOffense + ". \n" ;
	}
	else if( change == "log_on" )
	{
		gMessage = offenderDisplayName + " who is on report for " + offenderOffense + " has logged on. \n";
	}
	else if( change == "enter_sim" )
	{
		gMessage = offenderDisplayName + " who is on report for " + offenderOffense + " has entered the sim. \n";
	}
	gMessage += "Click the following link to open " + offenderDisplayName + "'s profile: \n" ;
	gMessage += offenderLink ;
	gWatcherIndex = 0;
	while( llGetListLength( gWatcherIds ) > gWatcherIndex )
	{
		llInstantMessage( llList2Key( gWatcherIds, gWatcherIndex ), gMessage );
		gWatcherIndex ++;
	}
}


default
{
	state_entry()
	{
		//llOwnerSay( "entering default state" );
		clear_all_posters( );
		/////////////////////
		//~ RANDOM PROFILE PROJECTOR v5.4.5 by Debbie Trilling ~
		profile_key_prefix_length = llStringLength(gPROFILE_KEY_PREFIX);
		profile_img_prefix_length = llStringLength(gPROFILE_IMG_PREFIX);
		//////////////////////////
		request_offender_data( );
		gReceivedDataCount = 0;
	}

	link_message( integer sender_number, integer number, string message, key id )
	{
		//llOwnerSay( "Offender Board link_message = " + message );
		gParsedMessage = llParseString2List( message, [ "_" ], [] );
		gMessageHeader = llList2String( gParsedMessage, 0 );
		gMessageData = llList2String( gParsedMessage, 1 );
		if( gMessageHeader == "gOffenderIds" )
		{
			gOffenderIds = llCSV2List( gMessageData );
			if( llList2String( gOffenderIds, 0 ) == "" ) gOffenderIds = [];
			gReceivedDataCount++ ;
		}
		else if( gMessageHeader == "gOffenderUsernames" )
		{
			gOffenderUsernames = llCSV2List( gMessageData );
			if( llList2String( gOffenderUsernames, 0 ) == "" ) gOffenderUsernames = [];
			//llOwnerSay( " gOffenderUsernames length = " + (string) llGetListLength( gOffenderUsernames ) );
			gReceivedDataCount++ ;
		}
		else if( gMessageHeader == "gOffenderDisplayNames" )
		{
			gOffenderDisplayNames = llCSV2List( gMessageData );
			if( llList2String( gOffenderDisplayNames, 0 ) == "" ) gOffenderDisplayNames = [];
			gReceivedDataCount++ ;
		}
		else if( gMessageHeader == "gOffenderProfilePicIds" )
		{
			gOffenderProfilePicIds = llCSV2List( gMessageData );
			if( llList2String( gOffenderProfilePicIds, 0 ) == "" ) gOffenderProfilePicIds = [];
			gReceivedDataCount++ ;
		}
		else if( gMessageHeader == "gOffenderStatuses" )
		{
			gOffenderStatuses = llCSV2List( gMessageData );
			if( llList2String( gOffenderStatuses, 0 ) == "" ) gOffenderStatuses = [];
			gReceivedDataCount++ ;
		}
		else if( gMessageHeader == "gOffenderOffenses" )
		{
			gOffenderOffenses = llCSV2List( gMessageData );
			if( llList2String( gOffenderOffenses, 0 ) == "" ) gOffenderOffenses = [];
			gReceivedDataCount++ ;
		}
		else if( gMessageHeader == "gWatcherIds" )
		{
			gWatcherIds = llCSV2List( gMessageData );
			if( llList2String( gWatcherIds, 0 ) == "" ) gWatcherIds = [];
			gReceivedDataCount++ ;
		}

		//llOwnerSay( "gReceivedDataCount = " + (string) gReceivedDataCount );
		if( gReceivedDataCount >= gNUMBER_DATA_ITEMS )
		{
			gReceivedDataCount = 0;
			//llOwnerSay( "setting active poster" );
			set_active_posters( );
			state ready;
		}
	}

	on_rez( integer start_param )
	{
		llResetScript( );
	}
}


state ready
{
	state_entry()
	{
		//llOwnerSay( " entering ready state " );
		llListen( gPOSTER_COMM_CHANNEL, "", NULL_KEY, "" );
		llSetTimerEvent( gSTATUS_UPDATE_INTERVAL );
	}

	listen( integer channel, string name, key id, string message )
	{
		//llOwnerSay( "comm message = " + message );
		gParsedMessage = llParseString2List( message, [ "_" ], [ ] );
		gMessageHeader = llList2String( gParsedMessage, 0 );
		if( gMessageHeader == "offender" )
		{
			//message format = "offender"_<gOffenderUsername>_<gOffenderId>_<gOffenderOffense>
			gOffenderUsername = llList2String( gParsedMessage, 1 );
			gOffenderId = llList2Key( gParsedMessage, 2 );
			gOffenderOffense = llList2String( gParsedMessage, 3 );
			list details = llGetObjectDetails( gOffenderId, [ 33 ] );
			string offenderGroupTag = llList2String( details, 0 );
			//llOwnerSay( "offenderGroupTag = " + offenderGroupTag );
			if( ( offenderGroupTag == "DA Student" ) || ( offenderGroupTag == "DA Brat" ) || ( offenderGroupTag == "DA Prefect" ) )
			{
				//check to see if offender is already listed
				integer i = llListFindList( gOffenderIds, [ gOffenderId ] );
				if( i == -1 )
				{
					gOffenderDisplayName = llGetDisplayName( gOffenderId );
					state get_profile_pic;
				}
			}
			else
			{
				gMessage = "Only students wearing a DA Studnet, DA Brat or DA Prefect group tag will be posed on the Students on Report board.  If you are a " + gGROUP_NAME +
					" student and wish to be placed on report, please set your active group to " + gGROUP_NAME + ".";
				//llOwnerSay( gMessage );
				llInstantMessage( gOffenderId, gMessage );
			}
		}
	}

	touch_start( integer total_number )
	{
		//llOwnerSay( "Touched in ready state" );
		gToucherId = llDetectedKey( 0 );
		gTouchedPrimNumber = llDetectedLinkNumber( 0 );
		gToucherUsername = llGetUsername( gToucherId );
		gOffenderIndex = llListFindList( gOffenderIds, [ gToucherId ] );
		if( gOffenderIndex != -1 )  //toucher is a listed offender
		{
			gMessage = "Do you want to remove your poster?" ;
			gDialogButtons = [ "Remove", "No" ];
			llDialog( gToucherId, gMessage, gDialogButtons, gDIALOG_CHANNEL );
			state get_dialog_response;
		}
		else  //check if prim was touched by teacher, perfect OR student
		{
			list details = llGetObjectDetails( gToucherId, [ 33 ] );
			string offenderGroupTag = llList2String( details, 0 );
			//llOwnerSay( "offenderGroupTag = " + offenderGroupTag );
			if( ( offenderGroupTag == "DA Faculty" ) || ( offenderGroupTag == "DA Headmistress" )  || ( offenderGroupTag == "DA Officer" ) || ( offenderGroupTag == "Headmaster" )  || ( offenderGroupTag == "DA Prefect"  ) || ( offenderGroupTag == "DA Teacher") || ( offenderGroupTag == "DA Deputy Head") )
			{
				gWatcherId = gToucherId;
				//check to see if active poster was touched
				gOffenderIndex = gTouchedPrimNumber - 2;
				if( gOffenderIndex < 0 ) // llList2String may return non empty value for negative indexes
				{
					gOffenderDisplayName = "";
				}
				else  //llList2String returns "" for out of bounds indexes
				{
					gOffenderDisplayName = llList2String( gOffenderDisplayNames, gOffenderIndex );
				}
				if( gOffenderDisplayName != "" )  // active poster prim touched
				{
					gOffenderId = llList2Key( gOffenderIds, gOffenderIndex );
					gMessage = "Do you wish to view " + gOffenderDisplayName + "'s Profile?" ;
					gMessage += "\n OR Do you wish to Delete her from the board?" ;
					gDialogButtons = [ "Profile", "Delete", "OK" ];
				}
				else  // empty board touched
				{
					//Check to see if toucher is presently monitoring board
					gWatcherIndex = llListFindList( gWatcherIds, [ gWatcherId ] );
					if( gWatcherIndex != -1 )   //watcher is presently monitoring board
					{
						gMessage = "Do you want to Stop Monitoring  this board?";
						gDialogButtons = [ "Stop Mon", "Continue" ];
					}
					else    //watcher is not monitoring board
					{
						gMessage = "Do you want to Monitor this boardand receive IMs when it changes?";
						gDialogButtons = [ "Monitor", "No" ];
					}
				}
				llDialog( gToucherId, gMessage, gDialogButtons, gDIALOG_CHANNEL );
				state get_dialog_response;
			}
		}
	}

	timer( )
	{
		state update_offender_statuses;
	}
}


state get_dialog_response
{
	state_entry( )
	{
		//llOwnerSay( " entering get_dialog_response state " );
		llListen( gDIALOG_CHANNEL, "", "", "" );
		llSetTimerEvent( gTOUCH_RESPONSE_TIMEOUT );
	}

	listen( integer channel, string name, key id, string message )
	{
		//llOwnerSay( "dialog message - " + message );
		if( ( message == "Delete" ) || ( message == "Remove" ) )
		{
			//llOwnerSay( "gOffenderIndex = " + (string) gOffenderIndex );
			delete_offender( );
		}
		else if( message == "Profile" )
		{
			string offenderLink = "secondlife:///app/agent/"  + (string) gOffenderId  + "/about" ;
			llWhisper( 0, "Click the following link to open " + gOffenderDisplayName + "'s profile." );
			llWhisper( 0, offenderLink );
		}
		else if( message =="Monitor" )
		{
			add_watcher( );
		}
		else if( message == "Stop Mon" )
		{
			delete_watcher( gWatcherIndex );
		}
		state ready;
	}

	timer( )
	{
		state ready;
	}

	touch_start( integer total_number )
	{

	}

	on_rez( integer start_param )
	{
		llResetScript( );
	}
}


state get_profile_pic
{

	state_entry( )
	{
		//llOwnerSay( " Entering getZ_profile_pic state." );
		/////////////////
		string URL_RESIDENT = "http://world.secondlife.com/resident/";
		gOffenderHttpRequest = llHTTPRequest( URL_RESIDENT + (string)gOffenderId,[HTTP_METHOD,"GET"],"");
		/////////////////
		llSetTimerEvent( gHTTP_TIMEOUT );
	}

	http_response(key req,integer stat, list met, string body)
	{
		//llOwnerSay( "http response recieved" );
		integer s1 = llSubStringIndex(body, gPROFILE_KEY_PREFIX);
		integer s1l = profile_key_prefix_length;
		if(s1 == -1)
		{
			// second try
			s1 = llSubStringIndex(body, gPROFILE_IMG_PREFIX);
			s1l = profile_img_prefix_length;
		}
		if(s1 == -1)
		{
			// still no match?
			gOffenderProfilePicId = gDEFAULT_PROFILE_PIC_TEXTURE;
		}
		else
		{
			s1 += s1l;
			gOffenderProfilePicId = llGetSubString(body, s1, s1 + 35);
			if ( gOffenderProfilePicId == NULL_KEY)
			{
				//llOwnerSay( "using default profile pic" );
				gOffenderProfilePicId = gDEFAULT_PROFILE_PIC_TEXTURE;
			}
		}
		if( req == gOffenderHttpRequest )
		{
			add_offender( );
			state ready;
		}
	}

	timer( )
	{
		gOffenderProfilePicId = gDEFAULT_PROFILE_PIC_TEXTURE;
		state ready;
	}

	touch_start( integer total_number )
	{

	}

	on_rez( integer start_param )
	{
		llResetScript( );
	}
}


state update_offender_statuses
{
	state_entry( )
	{
		//llOwnerSay( "Entering update_offender_ststus state" );
		if( llGetListLength( gOffenderIds ) > 0 )
		{
			gOffenderIndex = 0;
			gOffenderId = llList2Key( gOffenderIds, gOffenderIndex );
			gOnLineQuery = llRequestAgentData( gOffenderId, DATA_ONLINE );
			llSetTimerEvent( gDATA_SERVER_TIMEOUT );
		}
	}

	dataserver( key queryid, string data )
	{
		//llOwnerSay( "dataserver event data = " + data );
		if( queryid == gOnLineQuery )
		{
			if( llKey2Name( gOffenderId ) != "" )
			{
				gOffenderStatus = "In Sim";
			}
			else if( (integer) data == 0 ) //offender is Offline
			{
				gOffenderStatus = "OffLine" ;
			}
			else  //offender Online
			{
				gOffenderStatus = "Online";
			}

			string oldOffenderStatus = llList2String( gOffenderStatuses, gOffenderIndex );
			if( gOffenderStatus != oldOffenderStatus )
			{
				gOffenderStatuses = llListReplaceList( gOffenderStatuses, [ gOffenderStatus ], gOffenderIndex, gOffenderIndex );
				set_poster( gOffenderIndex );
				if( gOffenderStatus == "In Sim" )
				{
					notify_watchers( "enter_sim", gOffenderIndex );
				}
				else if( gOffenderStatus == "Online" )
				{
					notify_watchers( "log_on", gOffenderIndex );
				}
			}
			gOffenderIndex++;
			if( gOffenderIndex < llGetListLength( gOffenderIds ) )
			{
				gOffenderId = llList2Key( gOffenderIds, gOffenderIndex );
				gOnLineQuery = llRequestAgentData( gOffenderId, DATA_ONLINE );
				llSetTimerEvent( gDATA_SERVER_TIMEOUT );
			}
			else
			{
				state check_watcher_statuses;
			}
		}
	}

	timer( )
	{
		gOffenderIndex++;
		if( gOffenderIndex < llGetListLength( gOffenderIds ) )
		{
			gOffenderId = llList2Key( gOffenderIds, gOffenderIndex );
			gOnLineQuery = llRequestAgentData( gOffenderId, DATA_ONLINE );
			llSetTimerEvent( gDATA_SERVER_TIMEOUT );
		}
		else
		{
			state check_watcher_statuses;
		}
	}

	touch_start( integer total_number )
	{

	}

	on_rez( integer start_param )
	{
		llResetScript( );
	}
}


state check_watcher_statuses
{
	state_entry( )
	{
		//llOwnerSay( "Entering check_watcher_status state" );
		//llOwnerSay( "gWatcherIds = " + llList2CSV( gWatcherIds ) );
		if( llGetListLength( gWatcherIds ) > 0 )
		{
			gWatcherIndex = 0;
			gWatcherId = llList2Key( gWatcherIds, gWatcherIndex );
			gOnLineQuery = llRequestAgentData( gWatcherId, DATA_ONLINE );
			llSetTimerEvent( gDATA_SERVER_TIMEOUT );
		}
		else
		{
			state ready;
		}
	}

	dataserver( key queryid, string data )
	{
		//llOwnerSay( "check watcher status state dataserver event " );
		if( queryid == gOnLineQuery )
		{
			if( ( (integer) data == 0 ) && ( gToucherId != gDARYL_CARTERS_ID ) ) //watcher is Offline
			{
				delete_watcher( gWatcherIndex ) ;
			}
			gWatcherIndex++;
			if( gWatcherIndex < llGetListLength( gWatcherIds ) )
			{
				gWatcherId = llList2Key( gWatcherIds, gWatcherIndex );
				gOnLineQuery = llRequestAgentData( gWatcherId, DATA_ONLINE );
				llSetTimerEvent( gDATA_SERVER_TIMEOUT );
			}
			else
			{
				state ready;
			}
		}
	}

	timer( )
	{
		//llOwnerSay( "check watcher status state timer event " );
		gWatcherIndex++;
		if( gWatcherIndex < llGetListLength( gWatcherIds ) )
		{
			gWatcherId = llList2Key( gWatcherIds, gWatcherIndex );
			gOnLineQuery = llRequestAgentData( gWatcherId, DATA_ONLINE );
			llSetTimerEvent( gDATA_SERVER_TIMEOUT );
		}
		else
		{
			state ready;
		}
	}

	touch_start( integer total_number )
	{

	}

	on_rez( integer start_param )
	{
		llResetScript( );
	}
}


//I want to set it for a group called Briar Hill Estate and give myself the permissions instead of Daryl Carter.
//I also want to set the role to Headmistress and add BH in group tags instead of DA

 

Link to comment
Share on other sites

3 hours ago, steph Arnott said:

When you hard code the string UUID say like this.

string my_group = "3c069074-8c87-4d46-a7d4-698b1d2fed10";

You can then use that to compare the agents valid tag in a listen filter, touch event etc.

 

3 hours ago, steph Arnott said:

That script has a server connection. You are aware of that?

I'm new to scripting which is why I need help lol :) I just need to figure out how to make the script work for me , which is where I am struggling 

 

Link to comment
Share on other sites

57 minutes ago, Bittenbite said:

theres no way to create a new script that wont need me to create one?

There is absolutely no need for you to use an external server for what you're asking.

@Ruthven Willenov already answered your question with all of the essential info, but if you don't even know where to begin with his answer, it's probably better that you tried posting in the Wanted or Inworld Employment section so you could find a scripter willing to create exactly what you want. (We don't even know how your script is interacted with.)

But in an attempt to undo yet another one of Steph's misleadings, here is an example of how you would check if an avatar is in a specific group before they can touch an object:

// For example:
key group = "0375a183-05f6-450d-f0db-888574fdeea8";
string group_tag = "Errorist";

default
{
    touch_start(integer n)
    {
        // Get the touching avatar's group and tag.
        list info = llGetObjectDetails(llDetectedKey(0), [OBJECT_GROUP_TAG]);
        string avatar_tag = llList2String(info, 0);
        // (Fun fact: Avatar's group can be found through their attachments.)
        info = llGetAttachedList(llDetectedKey(0));
        info = llGetObjectDetails(llList2Key(info, 0), [OBJECT_GROUP]);
        key avatar_group =  llList2Key(info, 0);

        // If the avatar's group or tag is not correct,
        //  don't let them touch the object.
        if( (avatar_group != group) || (avatar_tag != group_tag) )
        {
            llOwnerSay("You must be displaying the group tag!");
            return;
        }

        // Interaction as normal goes here.
        llOwnerSay("Welcome!");
    }
}

Tadaa, no external servers! I also noticed that if the person has the "hide group title" setting enabled, the script will not detect their group tag even if it's "active."

(P.S. For you script-savvy people, I don't like defaulting to llSameGroup because it requires the object containing this script to be set to a specific group. That's not an option in all cases, so I prefer checking attachments instead.)

Edited by Wulfie Reanimator
  • Like 9
Link to comment
Share on other sites

6 hours ago, Wulfie Reanimator said:

But in an attempt to undo yet another one of Steph's misleadings, here is an example of how you would check if an avatar is in a specific group before they can touch an object:


// For example:
key group = "0375a183-05f6-450d-f0db-888574fdeea8";
string group_tag = "Errorist";

 

Firstly i already stated that, you just reapeted it. And second that script would need a total rewrite.  If you actually read it and understood it you would have seen that you can not just ram in a bit of code like you did and make it work. It would be faster to start from scratch.

The original was written with a server data base. So where was i being mis-leading? Stop throwing falsehoods around.

Edited by steph Arnott
Link to comment
Share on other sites

6 hours ago, steph Arnott said:

If you actually read it and understood it you would have seen that you can not just ram in a bit of code like you did and make it work. It would be faster to start from scratch.

I didn't just read it, I wrote it and tested it. From scratch.

It's certainly faster to write/test/read/understand/use than your example. (28 vs 739 lines)

  • Like 2
Link to comment
Share on other sites

Honestly can't say I have seen Wulfie do anything other than help people in this forum. You seem to be the one Steph that acts the bully with your reactions towards others. Food for thought. Regarding being wulfies friend....in a heart beat she seems like a really intelligent interesting person.

  • Like 1
Link to comment
Share on other sites

13 minutes ago, ItHadToComeToThis said:

Honestly can't say I have seen Wulfie do anything other than help people in this forum. You seem to be the one Steph that acts the bully with your reactions towards others. Food for thought. Regarding being wulfies friend....in a heart beat she seems like a really intelligent interesting person.

He has had many push backs. Also it is bad form to copy others solutions and claim ownership. BTW which friend would that be? The OP? I already know her.

Edited by steph Arnott
Link to comment
Share on other sites

23 hours ago, steph Arnott said:
On 3/4/2019 at 4:29 AM, Bittenbite said:

Just wondering... how do I script an object to only be interactive for people wearing a specific group tag? 

That script has a server connection. You are aware of that?

One might well wonder "what script has a server connection?" Then there's a long derivative of Debbie Trilling's ancient profile-pic-snarfing script, including:

23 hours ago, steph Arnott said:

key gDARYL_CARTERS_ID = "0aac5621-de33-45af-b8a4-6c8d0881b270";//THIS AND 
string gGROUP_NAME = "Derriere Academy";//THIS IS WHAY YOU ARE ON ABOUT.THE REST IS POINTLESS IF YOU HAVE NO EXTERNAL SERVER SET UP
[...]
//I want to set it for a group called Briar Hill Estate and give myself the permissions instead of Daryl Carter. 
//I also want to set the role to Headmistress and add BH in group tags instead of DA

 

20 hours ago, steph Arnott said:

Well you have no hope there unless you set up an external server.

13 hours ago, steph Arnott said:

The original was written with a server data base.

6 hours ago, steph Arnott said:

... The OP? I already know her.

I'm guessing the confusion here might be explained if Steph and the OP established offline that this was all in service of this funky script which in fact did use an external server for something or other. (The posted code, though, only accesses world.secondlife.com for the familiar profile pic-scraping.)

Anyway, back to the very first post, I'm sensing that "wearing a specific group tag" means something else. Having a specific group active is one thing, having a specific group Role active is quite another. I can't think of a way any server could help with that, though, unless it mediates with an army of bots that collect those Role labels from viewer messages. The long script matched against "DA Student", "DA Brat", or "DA Prefect" but those were apparently separate groups, not Roles, inasmuch as the (posted) code is simply using llGetObjectDetails [ 33 ] which is OBJECT_GROUP_TAG, fetching the group's UUID.

But for me that's enough code forensics for one thread.

  • Like 1
Link to comment
Share on other sites

2 minutes ago, Qie Niangao said:

 

The script is a kludge of at least four scripts. It also has at least two author styles. It has code that does nothing, repeats, functions within functions, list that should be strided etc..... In short it is just easier to write a script from scratch. 

Link to comment
Share on other sites

11 minutes ago, Qie Niangao said:

Anyway, back to the very first post, I'm sensing that "wearing a specific group tag" means something else. Having a specific group active is one thing, having a specific group Role active is quite another. I can't think of a way any server could help with that, though, unless it mediates with an army of bots that collect those Role labels from viewer messages. The long script matched against "DA Student", "DA Brat", or "DA Prefect" but those were apparently separate groups, not Roles, inasmuch as the (posted) code is simply using llGetObjectDetails [ 33 ] which is OBJECT_GROUP_TAG, fetching the group's UUID.

The "Student/Brat/Prefect" are roles within a single group. OBJECT_GROUP_TAG returns a string (not UUID) which is the role title on an avatar.

But you are quite right that an external server doesn't help in getting someone's active role, as LSL can do it without any.

Link to comment
Share on other sites

2 minutes ago, Wulfie Reanimator said:

OBJECT_GROUP_TAG returns a string (not UUID) which is the role title on an avatar.

Oh yes that's right, sorry. The avatar is indeed present to call the function on them, so that indeed works, exactly as you posted.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1869 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...