TonyBowlin Posted February 19, 2018 Share Posted February 19, 2018 (edited) Somewhere along the line, I lost track of what I was doing. My goal is a simple two-way radio. but I'm lost in the Region Say where I want it to send a message containing "user" which is defined by llGetObjectName followed by the message from channel 4. Heres where I left it after I think making it worse. string message; integer channel; integer user; integer channel2 = 4; integer listen_handle; default { state_entry() { channel = (integer)llGetObjectDesc(); user = (integer)llGetObjectName(); listen_handle = llListen(channel2, "", llGetOwner(), ""); } listen(integer channel2, string name, key id, string message) { llRegionSay(channel, "--" + user +","+ message); llPlaySound("",1.0); } } Edited February 19, 2018 by TonyBowlin Link to comment Share on other sites More sharing options...
Scaler Rexen Posted February 19, 2018 Share Posted February 19, 2018 I have wrote up a simple sample for you to go off of comments added so you know what each section does. integer sendChannel = 4; integer receiveChannel = -4324; key owner; default { on_rez(integer p) { llResetScript(); // Reset when attached to make sure it updates for new users. } state_entry() { owner = llGetOwner(); // Store the owners key(uuid) llListen(sendChannel,"",owner,""); // Listen to owner only for sending messages. llListen(receiveChannel,"","",""); // Listen for incoming messages. } listen(integer channel, string name, key id, string message) { if(channel == receiveChannel) { if(llGetOwnerKey(id) != owner) // Ignore messages sent from the owner. { string userName = llGetOwnerKey(id); // Get the name of the person who has sent the message. llOwnerSay(userName+": "+message); // Say the message to the user. } } else if(channel == sendChannel) { llRegionSay(sendChannel,message); // Send the message to other users. } } } 2 1 Link to comment Share on other sites More sharing options...
Nova Convair Posted February 19, 2018 Share Posted February 19, 2018 Small addon: llGetOwnerKey only returns the uuid for the name - llKey2Name or llGetDisplayName required for the name. string userName = llKey2Name(llGetOwnerKey(id)); // Get the name of the person who has sent the message. 2 Link to comment Share on other sites More sharing options...
Scaler Rexen Posted February 19, 2018 Share Posted February 19, 2018 Wow! I can't believe I missed that.. Good catch Nova. Link to comment Share on other sites More sharing options...
TonyBowlin Posted September 3, 2018 Author Share Posted September 3, 2018 Heres out the final idea came out. I split it all into three scripts for ease of learning if anyone else wants to use it. Script 1: Receiving: string message; integer channel; string blank = ""; default { state_entry() { channel = (integer)llGetObjectDesc(); llListen(channel, "","",""); } listen(integer channel, string name, key id, string message) { llPlaySound("3b32ba49-d06a-663b-8835-1d57b9a4ea4a",1.0); llInstantMessage(llGetOwner(),llKey2Name(id) + "-"+ (string)message); } } Script 2: Sending: string message; integer channel; integer user; integer channel2 = 4; integer listen_handle; string message2; default { state_entry() { channel = (integer)llGetObjectDesc(); user = (integer)llGetObjectName(); listen_handle = llListen(channel2, "", llGetOwner(), ""); } listen(integer channel2, string name, key id, string message) { llRegionSay(channel,message); llPlaySound("e1149699-fd54-d9af-efcc-445a2cda289e",1.0); } } Script 3: Channel Set: integer channel = 1; integer listen_handle; string message; default { state_entry() { listen_handle = llListen(channel, "", llGetOwner(), ""); } listen(integer channel, string name, key id, string message) { llSetObjectDesc(message); llPlaySound("3b32ba49-d06a-663b-8835-1d57b9a4ea4a",1.0); llResetOtherScript("Reciveing"); llResetOtherScript("Sending"); llOwnerSay( "Channel Set to " + message); llResetScript(); } } Link to comment Share on other sites More sharing options...
Recommended Posts
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