Jump to content

Sheath on Weapon Switch

Vidia Vargas

Recommended Posts


Hello, maybe someone can help me with this. I have a weapon
script almost finished, i even have it to where when i draw a sword the bow
sheaths and vice versa, the problem is i can only get it to work with chat
commands /1 draw sword etc... I want it so where when i use a hud that it does
the sheath weapon switch as well. I have tested other weapon makers and their
huds all sheath other weapons when drawing their own even if it’s not there
creating that they are sheathing.

Example I have my own sword and then i have a Primus bow when i
draw the primus bow through the Primus Hud my sword that i made sheaths... how do
I do that. I know it’s possible but i can’t figure it out.


Link to comment
Share on other sites

I don't know if this is the answer to the question, but one common "gotcha" when making things that need to respond both to the owner and the owner's hud is saying 


default{	state_entry()	{		llListen(99,"",llGetOwner(),"");	}	listen(integer channel, string name, key id, string message)	{		message = llToLower(message);		if(message = "sheath"){			//do something		}	}}


That doesn't work when the hud says "sheath" because, of course, the hud's uuid isn't the same as yours.   

Instead, you have to say something like


key owner;//declare it as a global, because you don't need to check it all the timedefault{	state_entry()	{		llListen(99,"","","");		owner = llGetOwner();	}	changed(integer change)	{		if (change & CHANGED_OWNER){			owner = llGetOwner();		}	}	listen(integer channel, string name, key id, string message)	{		if(llGetOwnerKey(id)==owner){//is it a message from my owner or something belonging to my owner? Avatars own themselves in according to LSL			message = llToLower(message);			if(message = "sheath"){				//do something			}		}	}}

 That's going to work whether the command comes from the avatar or the avatar's hud.


Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in

Sign In Now
  • Create New...