Please help with this argument error
|
Petelo Core
Registered User
Join date: 22 Oct 2009
Posts: 2
|
11-14-2009 08:41
Hello, I am a newbie in this coding, I am trying to get owner name from this code but it gives me "Function call mismatches type or number of arguments" error can someone please help me correct my code? key owner; key user = NULL_KEY; if (notecount == 1) { owner = llGetOwner(); if (status == OFFLINE) llInstantMessage(user, + owner + "offline."  ; else llInstantMessage(user, "message sent to " + owner + "."  ; } I need to get the item owner name. Thank you
|
Viktoria Dovgal
…
Join date: 29 Jul 2007
Posts: 3,593
|
11-14-2009 09:13
There is llKey2Name if the avatar is online and in the sim.
Since it looks like you are more interested in offline stuff, you will be better off using llRequestAgentData to pick up DATA_NAME. You will have to rearrange things a little so that the instant message goes out from the dataserver event, but it will do the job. You can stash this away in a variable if you are only interested in the owner's name.
[your error message will be in trying to use owner as a string, it's a key so you would have to cast it as (string) owner in that instant message. But never mind that, since you really want to print the name and not the key =)]
|
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
|
11-14-2009 09:17
Error in: llInstantMessage(user, + owner + "offline."  ; try: llInstantMessage(user, owner + "offline."  ; and owner is a key, but you need a string. Try llKey2Name(owner). That will work if the owner is in the region. If not you must request a dataserver for the name, see: http://www.lslwiki.net/lslwiki/wakka.php?wakka=llRequestAgentData
_____________________
From Studio Dora
|
Petelo Core
Registered User
Join date: 22 Oct 2009
Posts: 2
|
11-14-2009 10:04
From: Dora Gustafson Error in: llInstantMessage(user, + owner + "offline."  ; try: llInstantMessage(user, owner + "offline."  ; and owner is a key, but you need a string. Try llKey2Name(owner). That will work if the owner is in the region. If not you must request a dataserver for the name, see: http://www.lslwiki.net/lslwiki/wakka.php?wakka=llRequestAgentDataHI, thanks for the answer, yes I need to detect off sim owner. llInstantMessage(llKey2Name(owner) + "offline."  ; <-- this works but need off sim. I have visited the link but I cannot understand how to convert the owner key to a name. Hmm I think I will make it simple I just want to print out the item name owner regardless he is online or not. How can I convert the owner key to name?
|
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
|
11-14-2009 10:28
key owner; key user = NULL_KEY; //Can't send an instant message to NULL_KEY, so this better be given a real value somewhere.
if (notecount == 1) { owner = llGetOwner(); if (status == OFFLINE){ llInstantMessage(user, llKey2Name(owner) + " offline.");} else ){llInstantMessage(user, "message sent to " + llKey2Name(owner) + ".");}
That ought to do it. BTW, get in the habit of using curly brackets even when they aren't technically necessary. It's small insurance against the day when you edit a script, add a line and forget that the brackets aren't there when you needed them.
_____________________
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 
|
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
|
11-14-2009 10:31
From: Petelo Core llSetText(owner + " is online ", <0,1,0>, 1); not working.
How can I convert the owner key to name?
llSetText(llKey2Name(owner) + " is online ", <0,1,0>, 1); ETA: And if the object is in another sim, you just have to get "owner" from llRequestAgentData instead of llGetOwner(), as Dora said.
_____________________
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 
|
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
|
11-14-2009 10:37
From: Petelo Core owner = llRequestAgentData(owner, DATA_ONLINE); is not doing what you think it is  it returns a key which you must use in a dataserver event. Besides you need one more request for the name. The one you have is for the Online status. try this: integer onlinestatus; string ownername; key querystatus; key queryname;
default { state_entry() { querystatus = llRequestAgentData(llGetOwner(), DATA_ONLINE); queryname = llRequestAgentData(llGetOwner(), DATA_NAME); } dataserver(key queryid, string data) { if (queryid == querystatus) onlinestatus=(integer)data; if (queryid == queryname) ownername=data; if (onlinestatus) llOwnerSay(ownername+" is ON line"); else llOwnerSay(ownername+" is OFF line"); } }
This will work. It is NOT the way I would make an online detector, but an attempt to guess what you want 
_____________________
From Studio Dora
|