Jump to content

Can someone tell me another workaround for this one?


Rhemah
 Share

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

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

Recommended Posts

Hello everyone,

can someone tell me a better workaround for this?

//Command Script 
//this script is attached to several avatars
default { state_entry() { llListen(2,"",NULL_KEY,"" ); } listen(integer chan, string name, key id, string msg) { if(chan == 2) { if(msg == "getball") { llWhisper(9,"secretcommand"); //secret command } } } }
//Ball Script
//This Script is inside a content of an object
default { state_entry() { llListen(9,"",NULL_KEY,"" ); } listen(integer chan, string name, key id, string msg) { if(chan == 9) { if(msg == "secretcommand") { /* if i use "id", the Command Script does not work but the "/9 secretcommand" works by typing in local chat which makes the Command Script irrelevant*/ //llSensor("", id, AGENT_BY_USERNAME, 5, PI); /* if i use "NULL_KEY", the command script works but it goes to the nearest avatar instead of going to the one who made the command */ //llSensor("", NULL_KEY, AGENT_BY_USERNAME, 5, PI); } } } sensor(integer total_number) { key id = llDetectedKey(0); string name = llKey2Name(id); vector pos = llDetectedPos(0); vector offset = <0,0,0>; pos+=offset; llMoveToTarget(pos,0.3); llSleep(0.5); llStopMoveToTarget(); llSay(0, name + " has the ball!"); } }

 

Link to comment
Share on other sites

I see what your problem is.    You want the UUID of the avatar who sent the message via the attachment, not the UUID of the attachment that spoke to you.   Fortunately there's a simple fix.

Note, also, that your offset doesn't actually do anything as you've written it:  pos +<0.0,0.0,0.0> == pos, of course.

I assume you're going to use a proper offset in practice, so you land the the ball slighly in front of the player and at her feet rather than smack in the middle of her stomach.

When you do, I think you will find you need the player's rotation properly to place the ball, so I've calculated that for you..

	listen(integer channel, string name, key id, string message)	{//no need to test for the channel, since the listener ensures you only hear messages on 9 anyway		if(message == "secretcommand")		{	
//you want to know the UUID of the avatar who owns the object that's spoken to you key speaker = llGetOwnerKey(id);//now you know the avatar's uuid, you don't need to call llSensor string speakerName = llGetDisplayName(speaker);
//or llGetUsername if you prefer list speakerDetails = llGetObjectDetails(speaker,[OBJECT_POS,OBJECT_ROT]); vector speakerPos = llList2Vector(speakerDetails,0); rotation speakerRot = llList2Rot(speakerDetails,1);//I think you will find you need the speaker's rotation in order properly to place the ball } }
  • Like 2
Link to comment
Share on other sites

 

//Command Scriptdefault{    state_entry()    {        llListen(2,"",NULL_KEY,"" );    }    listen(integer chan, string name, key id, string msg)    {        if(chan == 2 && llGetOwnerKey(id) == llGetOwner())        {            if(msg == "getball")            {                llWhisper(9,"secretcommand");            }        }    }}

i made the command script this way and

 

llSensor("", llGetOwnerKey(id), AGENT_BY_USERNAME, 5, PI);

on the ball script this way. Works fine now but the ball goes to the owner first before it will go to the particular avatar who first made the /2 getball, the creator of the object needs to be away though 

Link to comment
Share on other sites

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