Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Eject Help

LaZy Hulka
Registered User
Join date: 11 Apr 2006
Posts: 32
12-15-2006 13:29
Hello everyone

I'm a n00b scripter. But I have made this and it does not work. I made a eject from land script. Yes I own the land. But the script detects the person but the eject does not want seem to work? Why can someone help me out xD.

Thanks for reading/posting


CODE

string msg;
string name;
default
{
on_rez(integer n)
{
llResetScript();
}

state_entry()
{
llListen(0,"",llGetOwner(),"");
llListen(1,"",llGetOwner(),"");
}


listen(integer n, string m, key k, string msg)
{

if (llGetSubString(msg,0,4) == "eject")
{

name = llToLower(llGetSubString(msg,6,llStringLength(msg)));
llSensor("",NULL_KEY,AGENT,96,PI);
}

}

sensor(integer total_number)
{


integer i;
for (i = 0; i < total_number; i++)
{
if (llSubStringIndex(llToLower(llDetectedName(i)),name) != -1)
{
llOwnerSay("ejecting " + llDetectedName(i));
llEjectFromLand(llDetectedName(i));
}
}
}

no_sensor() {
llSay(0, "Nobody is around.");
}
}
_____________________
USMC Time to kick ass and take names later. Show No Mercy

ed44 Gupte
Explorer (Retired)
Join date: 7 Oct 2005
Posts: 638
12-15-2006 13:54
Why do you listen on two channels?

Use llOwnerSay to see how far your script worked.

In the sensor i would put a diagnostic line

CODE

llOwnerSay ("detected " + llDetectedName(i));


The idea is to put these kinds of statements where ever things happen so you can follow the flow of the script and actually understand it!

hth
ed
Jacques Groshomme
Registered User
Join date: 16 Mar 2005
Posts: 355
12-15-2006 14:08
llEjectFromLand() expects a key, but llDetectedName returns a string.

Use llDetectedKey instead.
Jacques Groshomme
Registered User
Join date: 16 Mar 2005
Posts: 355
12-15-2006 14:14
Try this. I'm not in world, so I don't know if it'll compile.

It's been modified to only run a sensor for the specified avatar name. Because you are now only searching for one possible agent, no need to have your conditionals in place in the sensor event. I also removed an unnecessary listen.

CODE
string msg;
string name;

default
{
on_rez(integer n)
{
llResetScript();
}

state_entry()
{
llListen(0,"",llGetOwner(),"");
}


listen(integer n, string m, key k, string msg)
{

if (llGetSubString(msg,0,4) == "eject") {
name = llToLower(llGetSubString(msg,6,llStringLength(msg) ));
llSensor(name,NULL_KEY,AGENT,96,PI);
}
}

sensor(integer total_number)
{
llOwnerSay("ejecting " + llDetectedName(0));
llEjectFromLand(llDetectedKey(0));
}


no_sensor() {
llOwnerSay("Avatar not found.");
}
}
LaZy Hulka
Registered User
Join date: 11 Apr 2006
Posts: 32
12-15-2006 14:37
Jacques Groshomme your script does not pick up anyone. When I try typing eject alex Lulu it says Nobody is around.

Also thanks for replaying xD everyone
_____________________
USMC Time to kick ass and take names later. Show No Mercy

Jacques Groshomme
Registered User
Join date: 16 Mar 2005
Posts: 355
12-15-2006 15:29
Odd that my script isn't picking up anybody.

The sensor function and event should be capable of locating an agent by name.

Lemme whip up v2.0 (slightly more inefficient) that is more broadly based on your first code.
Jacques Groshomme
Registered User
Join date: 16 Mar 2005
Posts: 355
12-15-2006 15:33
OK try this one. This one again searches for all agents in an area, loops through them, compares detected name with your original critera and will eject the agent if it matches.

CODE

string msg;
string name;

default
{
on_rez(integer n)
{
llResetScript();
}

state_entry()
{
msg = "";
name = "";
llListen(0,"",llGetOwner(),"");
}


listen(integer n, string m, key k, string msg)
{

if (llGetSubString(msg,0,4) == "eject") {
name = llToLower(llGetSubString(msg,6,llStringLength(msg)));
llSensor("", NULL_KEY, AGENT, 96, PI);
}
}

sensor(integer total_number)
{
integer i;
for(i=0; i < total_number; i++) {
if(llToLower(llDetectedName(i)) == name) {
llOwnerSay("ejecting " + name);
llEjectFromLand(llDetectedKey(i));
}
}
}


no_sensor() {
llOwnerSay("Avatar not found.");
}
}