
I have a group only giver script that I want to change around a bit. I want to change it to read conditions from a config notecard. I have been successful doing that when it comes to having it pick a greeting from the notecard, or a not in group message etc...
What I can't figure out is how do I make it so the script checks the notecard to see if I want group only on or off and if on then check for LLSameGroup and etc... Not deliver if wrong group and if off just give without checking.
Can anyone help before my brain explodes? lol
Below is the working script with group only give, with reading the notecard config for the greet and sorry message.
Any help would be greatly appreciated!
Holly
CODE
string cardName;
string GREET;
string SORRYGROUP;
integer NotecardLine;
key QueryID;
integer setnote = 00;
// Gives inventory object only to agents with the same active group
default
{
on_rez(integer param)
{
llResetScript();
}
state_entry()
{
llOwnerSay("Initializing...");
cardName = llGetInventoryName(INVENTORY_NOTECARD, setnote);
if (llGetInventoryType(cardName) == INVENTORY_NOTECARD)
{
NotecardLine = 0;
QueryID = llGetNotecardLine(cardName, NotecardLine );
}
else
{
llOwnerSay("Configuration notecard missing, using defaults.");
}
}
dataserver( key queryid, string data )
{
list temp;
string name;
string value;
if ( queryid == QueryID )
{
if ( data != EOF )
{
if ( llGetSubString(data, 0, 0) != "#" && llStringTrim(data, STRING_TRIM) != "" )
{
temp = llParseString2List(data, ["="], []);
name = llStringTrim(llToLower(llList2String(temp, 0)), STRING_TRIM);
value = llStringTrim(llList2String(temp, 1), STRING_TRIM);
if ( name == "greet" )
{
GREET = (string)value;
}
else if ( name == "sorrygroup" )
{
SORRYGROUP = (string)value;
}
}
NotecardLine++;
QueryID = llGetNotecardLine(cardName, NotecardLine );
}
else
{
state Running;
}
}
}state_exit()
{
llOwnerSay("Initialization Complete!");
}
}
state Running
{
touch_start(integer total_number)
{
integer i;
for (i = 0; i < total_number; i++)
{
if (llSameGroup(llDetectedKey(i))) // same as llDetectedGroup(i) (with llDetectedGroup, detected does not need to be in the sim)
{
llSay(0,(string)GREET);
llGiveInventory(llDetectedKey(i), llGetInventoryName(INVENTORY_OBJECT, 0));
}else
llSay(0,(string)SORRYGROUP);
}
}
}
In the config notecard...
greet=Thanks for picking me!
sorrygroup= I am so sorry, you don't seem to be in my group.