12-31-2004 13:21
Don't have time to properly post these (running out the door for the weekend). Could do with some changes but no time...

chat commands
/4 list
/4 add
/4 requests
/4 remove
/4 recent

this can be used as an attachment or a standalone object, IM's owner.

CODE

list users;// = ["4275d408-da94-4f68-8353-090fb2dfc020","abd5216c-1984-4ccc-bd10-f7b32c438816"];

list requests;
list status;
integer t;
integer v;
integer im;
integer w;

list people; //do not play with this
key owner;

init()
{
llListenRemove(w);
owner=llGetOwner();
w = llListen(4,"",owner,"");
}

default
{
state_entry()
{
v = llGetListLength(users);
if(v)
llSetTimerEvent(60.0/v);
init();
llListen(0,"","","");
}
on_rez(integer a)
{
init();
}
listen(integer a, string b, key c, string d)
{
if(c!=llGetKey())
{
if(a)
{
list e=llParseString2List(d,[" "],[]);
b=llToLower(llList2String(e,0));
d=llDumpList2String(llDeleteSubList(e,0,0)," ");
c=(key)d;
if(b=="add")
{
if(llSubStringIndex(d,"-")==8 && llGetListLength(e)==2 && llStringLength(d)==36)
{
users+=c;
requests += [llRequestAgentData(c,DATA_ONLINE), v, llGetTime()];
}
else
{
a=llListFindList(people,[llToLower(d)]);
if(a+1)
{
c=llList2String(people,(a&-2) + 1);
users+=c;
requests += [llRequestAgentData(c,DATA_ONLINE), v, llGetTime()];
}
else
llSensor(d,"",AGENT,96,TWO_PI);
}
v = llGetListLength(users);
if(v)
llSetTimerEvent(60.0/v);
else
llSetTimerEvent(0);
}
else if(b=="remove")
{
llMessageLinked(llGetLinkNumber(), -7,d,"");
}
else if(b=="list")
{
a=llGetListLength(users);
while(a--)
llMessageLinked(llGetLinkNumber(),(im++)%5,
llList2String(status,a), llList2Key(users,a));
}
else if(b=="recent")
{
integer f=llGetListLength(people);
key g;
for(a=0;a<f;a+=2)
{
g=llList2Key(people,a+1);
llMessageLinked(llGetLinkNumber(),(im++)%5,
llList2String(status+["0"],llListFindList(users,[g])), g);
}
}
else if(b=="requests")
{
integer f=llGetListLength(requests);
integer g;
for(a=0;a<f;a+=3)
{
g=llList2Integer(requests,a+1);
llMessageLinked(llGetLinkNumber(),(im++)%5,
llList2Key(status,g), llList2Key(users,g));
}
}
return;
}
else if(c!=owner && llGetAgentSize(c)!=<0,0,0>)
{
if(llListFindList(people,[c])==-1)
people+=[llToLower(b),c];
if(llGetListLength(people)>20)
people=llList2List(people,-20,-1);
}
}
}
link_message(integer a, integer b, string c, key d)
{
if(b == -8)
{
b=llListFindList(users,[(key)d]);
if(b+1 && a==llGetLinkNumber())
{
users = llDeleteSubList(users,b,b);
llMessageLinked(a,im++%5,"3", d);
v = llGetListLength(users);
if(v)
llSetTimerEvent(60.0/v);
else
llSetTimerEvent(0);
}
}
}
sensor(integer a)
{
while(a--)
{
llMessageLinked(llGetLinkNumber(), -1, llDetectedName(a), llDetectedKey(a));
users+=llDetectedKey(a);
requests += [llRequestAgentData(llDetectedKey(a),DATA_ONLINE), v, llGetTime()];
v = llGetListLength(users);
}
}
touch_start(integer a)
{
a=llGetListLength(users);
while(a--)
llMessageLinked(llGetLinkNumber(),im++%5,
(string)(llList2Integer(status,a) | 4), llList2Key(users,a));
}
dataserver(key id, string data)
{
integer r = llListFindList(requests,[id]);
if(r+1)
{
integer u = llList2Integer(requests, r+1);
requests = llDeleteSubList(requests, r, r+2);
string d = (string)((integer)data + 1);
if(llList2String(status,u) != d)
{
status = llListInsertList(llDeleteSubList(status,u,u),[d],u);
llMessageLinked(llGetLinkNumber(),im++%5,d,llList2Key(users,u));
}
}
r=llGetListLength(requests);
float f=llGetTime();
while(r--)
if(f - llList2Float(requests,r * 3 + 2) > 120)
{
requests = llDeleteSubList(requests, 0, r * 3 + 2);
r=0;
}
if(!llGetListLength(requests))
{
llResetTime();
if(v)
t=t%v;
}
}
timer()
{
if(v)
{
requests += [llRequestAgentData(llList2Key(users,t%v),DATA_ONLINE),
t%v, llGetTime()];
t++;
}
}
}


put 5 of these in the object make sure you recompile each one (open each copy of this script and save it)
CODE

//Type something here and click save
list users;
integer chan;

list requests;

integer FindUser(string b)
{
b=llToLower(b);
integer c;
integer d=llGetListLength(users);
for(;c<d;c++)
if(llToLower(llList2String(users,c))==b)
return c;
return -1;
}

message(string u, integer online) {
u += llList2String([" has an unknown status"," is offline", " is online"," was successfuly removed"], online & 3);
if(online & 4)
llSay(0,u);
else
llInstantMessage(llGetOwner(),u);
}

check() {
llMessageLinked(llGetLinkNumber(), -3,(string)chan,llGetScriptName());
}

integer refresh() {
return chan=(integer)llList2String(llParseString2List(llGetScriptName(),[" "],[]),-1);
}

default
{
state_entry()
{
if(!refresh())
llSetTimerEvent(10);
else
check();
}
timer()
{
llSetTimerEvent(0);
refresh();
check();
}
link_message(integer link, integer c, string d, key u)
{
if(c==-1)
{
key e = (key)u; //never trust link_message keys to be keys.
c = llListFindList(users, [e]);
if(c==-1)
users+=[u, d];
}
else if(c==-2)
check();
else if(c==-4)
refresh();
else if(c==-5)
users=[];
else if(c==-6)
llMessageLinked(link, -3,(string)chan,(string)llGetFreeMemory());
else if(c==-7)
{
c = FindUser(d);
if(c+1)
{
c = c & -2;
llMessageLinked(link, -8,llList2String(users, c + 1),llList2Key(users, c));
users = llDeleteSubList(users, c, c + 1);
}
}
else if(c==chan)
{
key e = (key)u; //never trust link_message keys to be keys.
c = llListFindList(users, [e]);
if(c+1)
message(llList2String(users,(c&-2) + 1),(integer)d);
else
requests += [llRequestAgentData(e,DATA_NAME), e,
d, llGetTime()];
}
}
dataserver(key id, string data)
{
integer r = llListFindList(requests,[id]);
if(r+1)
{
key u = llList2Key(requests, r+1);
integer a=llList2Integer(requests, r+2);
if(a!=3)
{
if(llListFindList(users,)==-1)
users += [u, data];
llMessageLinked(llGetLinkNumber(), -1, data, u);
}
message(data,a);
requests = llDeleteSubList(requests, r, r+3);
}

r=llGetListLength(requests);
float f=llGetTime();
while(r)
{
if(f - llList2Float(requests,r + 3) > 120)
{
requests = llDeleteSubList(requests, 0, r + 3);
r=0;
}
else
r-=4;
}
if(!llGetListLength(requests))
llResetTime();
}
}
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.
- Cyril Connolly

Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence.
- James Nachtwey