Listen to owner only - object - object
|
Thili Playfair
Registered User
Join date: 18 Aug 2004
Posts: 2,417
|
06-02-2005 14:58
ok im trying to get my scripts build bit better and im still reading up wiki , trying to figure out how to make a script like this I have one that send commands on chan using menu system, but i only want the owner of that prim to be able to actually activate the script in prim llListen(120, "", llGetOwner(), ""  ; This one in the prim doesnt want to work for me, was hoping it could be that easy, i need some kind of llDetectedKey(0) == llGetOwner() ? llListen(120, "objectname", "" , ""  ; Do work but if someone where to make one with same name and chan, or have another near wouldnt it be able to activate the other? Possible to make a object look at owner of object, before it actually do something? I tried reading llLinkmessage and didnt get much , been experimenting with it, just if anyone have a idea about it would be great 
|
Kali Dougall
Purple and Spikey
Join date: 5 Feb 2005
Posts: 98
|
06-02-2005 15:09
Fact is that using filters in llListen isn't any (or much) more efficient than using an open listen and doing your own checking. So just set up an open listen: llListen(120, "", NULL_KEY, ""); And put this check in your listen event: listen(integer channel, string name, key id, string message) { if (llGetOwnerKey(id) == llGetOwner()) { ...code here... } } That way it'll only listen to objects with the same owner.
_____________________
[ Kali's Purple Pantechnicon ]Eldora (119, 147)[ Final Fantasy Pyreflies ~ Multigame Target Launcher ~ CyberGoggles/BLISS Goggles ~ Other Scripted Gadgets ~ Fashion Accessories ~ Miscellanea ]
|
Pete Fats
Geek
Join date: 18 Apr 2003
Posts: 648
|
06-02-2005 15:12
try using this inside your listen event: listen(integer chan, string name, key id, string message) { if (llGetOwnerKey(id) == llGetOwner()) { do stuff } } This will check to make sure that the key that spoke to you is owned by the same UUID as the script that is processing the listen. Hope this helps.  *edit - heh...kali beat me.
|
Sam Nielsen
Registered User
Join date: 23 Apr 2005
Posts: 7
|
06-02-2005 15:16
This should work for you. Have one of these in an appropriate place, like state_entry(), like you have llListen(0, "", llGetOwner(), ""  ; and then have a listen state which is only interested in the owner speaking, like this: listen (integer channel, string name, key id, string message) { if (id == llGetOwner()) { // Do things if you're the owner } }
|
Zindorf Yossarian
Master of Disaster
Join date: 9 Mar 2004
Posts: 160
|
06-02-2005 15:21
If you're worried about someone finding your channel, just make it ridiculously high. Remember you have over two billion channels to work with.
_____________________
Badass Ninja Penguin: Killing stuff it doesn't like since sometime in May 2004.
|
Sam Nielsen
Registered User
Join date: 23 Apr 2005
Posts: 7
|
06-02-2005 15:49
Zindorf makes a good point. I usually use high numbers. Also you could make a sort of password which you parse out when you receive the message, so you could type in something like
/238472 mypassword executecommand
the chances of someone guessing the channel, your 'password', a command that works and also having the correct user ID for the script to be listening in the first place must be fairly remote.
|
Thili Playfair
Registered User
Join date: 18 Aug 2004
Posts: 2,417
|
06-02-2005 16:03
 thanks, still trying , reason i want it to listen to object owner only, cause im trying to make a menu system for diffrent things , That menu script works with llGetOwner already, so only i can use it, but i tend to make things near that i dont want someone else to use theirs and accidentally trigger a reaction. my listen script wich is spose to listen for object command/owner only still wont do anything default { state_entry() { llListen(120,"controller","", "" ); } listen(integer channel, string name, key id, string text) { if(text=="zzzzz"){ llSetAlpha(0.5,ALL_SIDES); } if(text=="aaaaa"){ llSetAlpha(1.0,ALL_SIDES); } } } Tried to use listen(integer chan, string name, key id, string message) { if (llGetOwnerKey(id) == llGetOwner()) { in there but it keeps saying syntax error (yes im pretty new to scripting in SL ) hehe  it shows Thanks for fast replies O.o
|
Kali Dougall
Purple and Spikey
Join date: 5 Feb 2005
Posts: 98
|
06-02-2005 19:42
Perhaps I'm blind, but I don't see a syntax error with that. Check your closing braces and everything.
_____________________
[ Kali's Purple Pantechnicon ]Eldora (119, 147)[ Final Fantasy Pyreflies ~ Multigame Target Launcher ~ CyberGoggles/BLISS Goggles ~ Other Scripted Gadgets ~ Fashion Accessories ~ Miscellanea ]
|
Thili Playfair
Registered User
Join date: 18 Aug 2004
Posts: 2,417
|
06-03-2005 05:19
Eh yeah this is what im trying to do, keep just saying syntax default { state_entry() { llListen(900, "",NULL_KEY, ""); } listen(integer channel, string name, key id, string message) { if (llGetOwnerKey(id) == llGetOwner()) { if(text=="open"){ llSetAlpha(0.5,ALL_SIDES); } if(text=="lock"){ llSetAlpha(1.0,ALL_SIDES); } } } I cant figure out how to work in the llGetOwner - if(text=="command"  { - then it does things.
|
Sam Nielsen
Registered User
Join date: 23 Apr 2005
Posts: 7
|
06-03-2005 06:10
You're missing a brace (or curly brackets as some people like to call them) at the end I think. In other words add a } at the bottom. You don't get that problem so much if you indent the { and } to the same level so they all line up, and sometimes it's useful to put a comment at the end, like } // end of default Also this line listen(integer channel, string name, key id, string message) won't work with if(text=="open") so change them all to be either "text" or "name". This line if(text=="lock") should really be else if(text=="lock") won't make much difference to the way it works in this case but if the text was "open" then it can't be "lock" so you don't need to check it. You won't notice on a script like this but it's a good habit to get into unless you specifically want to check 2 different things. default { state_entry() { llListen(900,"",NULL_KEY,""); } listen(integer channel, string text, key id, string message) { if (llGetOwnerKey(id) == llGetOwner()) { if (text=="open") { llSetAlpha(0.5,ALL_SIDES); } else if (text=="lock") { llSetAlpha(1.0,ALL_SIDES); } } } // end listen } // end default
|