Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Owner problems

Sollie Villota
Registered User
Join date: 22 Jun 2007
Posts: 46
08-18-2007 18:42
Here's the story-

My combat system/HUD I am making shows text over your head. So I thought maybe it would be easy to make another object that will show the text on your HUD so you can see it in Mouselook. Well, I am having trouble making it so it'll only listen to owner and thats it. When a bunch of people have it on it randomly shows everyone's HP and obviously that doesn't help...

Here's my script for it. I am guessing something is definatly wrong.

CODE

integer healthlisten;
integer dead;
string ownername;

default
{
state_entry()
{
ownername = llGetOwner();
llSetTimerEvent(1);
llListen(4859,"",NULL_KEY,"");
llSetAlpha(0.0, ALL_SIDES);
}
on_rez(integer start_param)
{
llResetScript();
}
listen(integer channel, string name, key id, string message)
{
if (ownername == llGetOwner())
{
healthlisten = (integer)message;
}
}
timer()
{
llSetText("Health | " + (string)healthlisten + " HP", <1,0,0>, 1.0);
}
}


Also I want it so it'll say DEAD instead of the HP later, but I need to figure this problem out first. The other script communicates with this:

CODE

timer()
{
llSetText("Health | " + (string)health + " HP", <1,0,0>, 1);
llSay(4859, (string)health);
if (health <= 0)
{
llSetText("Health | DEAD", <1,0,0>, 1);
state dead;
}
}
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
08-18-2007 18:47
llGetOwner() returns the owner's key, not name.

But that's what you want... so, to get what you're looking for:

if(id == ownername)

the id is passed to the event.

If you want to make the filter (the llListen) do the work:

llListen(4859,"",llGetOwner(),"";);

then the listen() is only triggered when the owner speaks and you can do away with the if().
Sollie Villota
Registered User
Join date: 22 Jun 2007
Posts: 46
08-18-2007 19:00
Okay I understand what you're saying. I tried both ways and each time it just keeps saying 0 HP. So I am guessing there's an owner issue maybe? Its my own HUD and stuff though ...
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
08-18-2007 19:09
From: Sollie Villota
Okay I understand what you're saying. I tried both ways and each time it just keeps saying 0 HP. So I am guessing there's an owner issue maybe? Its my own HUD and stuff though ...
What are you saying to tell it its HP?
Sollie Villota
Registered User
Join date: 22 Jun 2007
Posts: 46
08-18-2007 19:13
OK its supposed to display to me the current HP from the other part that says the current HP on channel 4859. But obviously other HUDs will hear it too. What else can I do to fix this?
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
08-18-2007 19:22
From: Sollie Villota
OK its supposed to display to me the current HP from the other part that says the current HP on channel 4859. But obviously other HUDs will hear it too. What else can I do to fix this?
Ah, well THAT is different. You're not listening for the owner, but for objects owned by the same owner. You can do that. Try this:


Your llListen():

llListen(4859,"",NULL_KEY,"";);

your if():
if(llGetOwnerKey(id) == llGetOwner()) {}
Sollie Villota
Registered User
Join date: 22 Jun 2007
Posts: 46
08-18-2007 19:57
Holy crap thank you VERY much! That makes so much sense to, grr, thanks very much!!