Paul Wardark
Wait, what?
Join date: 10 Jan 2009
Posts: 383
|
09-20-2009 20:52
Okay. I have a script that detects if you're in the group and ejects you if you're not. I got it working after a few hours of work. I'm trying now to get it to give some kind of warning... But can't for the life of me figure out how to make it work.
float RANGE = 5.0; // Scan Range float RATE = 1.0; // Scan Rate
string uuid = "";
boot(key id) { if (llOverMyLand(id) == TRUE) { llUnSit(id); llEjectFromLand(id); } } default { state_entry() { llSensorRepeat("", NULL_KEY, AGENT, RANGE, PI, RATE); } sensor(integer num_detected) { integer i; integer group_members = 0; for (i = 0; i != num_detected; i++) { if (llSameGroup(llDetectedKey(i)) == FALSE) { llSay(0, "You are in an unauthorized area. You will be removed in five seconds."); llSetTimerEvent(5.0); } } } timer() { boot(llDetectedKey(i)); //How do I make this grab the name from above? } }
Everybody's happy to tell me what I'm doing wrong or to tell me to just buy a 96 meter security orb, nobody's telling me what I gotta do to fix this. And I get the feeling that the way I've written it, it's STILL going to kick out the avatar and not detect that they've moved out of range.
|
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
|
09-20-2009 21:34
2 things, it won't get to the timer event, because the sensor repeat happens too often for it, it restarts the count each time it finds someone unauthorized
the second thing is, if it were to get the timer event it wouldn't work because the llDetected* functions don't work outside touch, collision or sensor events
you should have it run the sensor less often, 10 seconds is probably sufficient. probably create a list of detected unauthorized avatars, after it goes through the detected avatars in the sensor event, if it got any unauthorized avatars turn the timer on (maybe remove the sensor temporarily to make sure the timer isn't disturbed) when the timer goes off, it can run through the list of unauthorized avatars again, checking if they're still over your land, and also check to make sure they're still unauthorized (maybe someone forgot to change their tag before entering, and changed it when they got the warning) after it goes through the list of unauthorized, empty the list, turn off the timer, and turn the sensor back on
|
Destiny Niles
Registered User
Join date: 23 Aug 2006
Posts: 949
|
09-20-2009 21:35
You don't need to use the scan every 1 second, do it every 5, the max someone would be there is about 10 seconds. Since they have to be present for 2 scans using the below method.
float RANGE = 5.0; // Scan Range float RATE = 5.0; // Scan Rate You only need to scan once every 5 seconds - if they are still there on second scan kick them.
string uuid = "";
list kickme; //global for who to kick integer list_count; //counter to use for clearing list
boot(key id) { if (llOverMyLand(id) == TRUE) { llUnSit(id);
llEjectFromLand(id);
} }
default { state_entry() { llSensorRepeat("", NULL_KEY, AGENT, RANGE, PI, RATE);
} sensor(integer num_detected) { integer i;
//integer group_members = 0; not used
for (i = 0; i != num_detected; i++) { if (llSameGroup(llDetectedKey(i)) == FALSE) { if ((llListFindList([llDetectedKey(i), kickme) != -1) { boot(llDetectedKey(i); } else kickme = kickme+llDetectedKey(i);
//llSay(0, "You are in an unauthorized area. You will be removed in five seconds."); llInstantMessage(llDetectedKey(i), "You are in an unauthorized area. You will be removed in five seconds."); //don't spam open chat
} //delete old entries
if (list_count >1) { kickme = llDeleteSubList(kickme, 0, list_count); } list_count = llGetListLength(kickme); }
}
|
Paul Wardark
Wait, what?
Join date: 10 Jan 2009
Posts: 383
|
09-21-2009 06:34
That IS more effective, I like that. One issue though, and I'm not seeing an easy fix. Syntax error here-
if ((llListFindList([llDetectedKey(i), kickme) != -1)
UPDATE: I fixed the syntax error, but now that same line is telling me Function call mismatches type or number of arguments
|
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
|
09-21-2009 07:00
That's because you left off a "]". You have to treat llDetectedKey(i) as a list to do a llListFindList comparison. You also have an extra open parenthesis. The correct syntax should be ....
if (llListFindList([llDetectedKey(i)], kickme) != -1)
ETA: And your lists are backwards. You want to see if llDetectedKey(i) is in kickme, not the other way around, so it should be
if (llListFindList(kickme,[llDetectedKey(i)]) != -1)
As it is written currently, the test will always evaluate to -1 because you will never find the entire list kickme in the single element llDetectedKey(i).
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask....  Look for my work in XStreetSL at 
|