Second Life Copybot
Sim Wide Chat - Printable Version

+- Second Life Copybot (https://secondlifecopybot.com)
+-- Forum: SECOND LIFE PRODUCTS (https://secondlifecopybot.com/forum-1.html)
+--- Forum: SCRIPTS (https://secondlifecopybot.com/forum-1022.html)
+---- Forum: SCRIPTS (https://secondlifecopybot.com/forum-8.html)
+----- Forum: Communication Scripts (https://secondlifecopybot.com/forum-46.html)
+----- Thread: Sim Wide Chat (/thread-813.html)



Sim Wide Chat - deadpool - 02-19-2013

What is it?

A basic relay system that sends and receives messages on a given channel. So you can talk to your friends (some of;) at ground level while you’re miles above, and vice versa. The messages are encrypted for privacy. You can find the original I hacked to pieces by clicking here, full credit to Kireji Haiku for creating *SIMchat_headset* so I and others can learn/create.

How-to/Info:

•Copy paste the script below into a new script inworld.
•Save it & then put the script into an object (if not there already)

PHP Code:
// Converted to use inscript config(removed need for notecard), removed extra states
// added link_message, changed to owner only usage/HUD/attachment
 
//
integer secret_channel 10;
//
 
key owner;
string  name;
string  header;
string  protocol_signature "SPY";
string  password "P@ssw0rD";
string  strHex "0123456789ABCDEF";
float   protocol_version 0.3;
vector  on_color = <0.468,1.000,0.683>;
vector  off_color = <1.000,0.468,0.468>;
integer secret_listen;
integer active 0;
 
init(){
    
owner llGetOwner();
    list 
versions llParseString2List((string)protocol_version, ["."], []);
    
string minor llList2String(versions1);
    
integer p 0;
    while(
llGetSubString(minor, --pp) == "0");
    
header protocol_signature hex(llList2Integer(versions0)) + hex((integer)llGetSubString(minor0xFF000000p));
}
 
on(){
    
llListenRemove(secret_listen);
    
secret_listen llListen(secret_channel"""""");
    
llSetColor(on_colorALL_SIDES);
    
llOwnerSay("/me ("+(string)secret_channel+") : ON :");
}
off(){
    
llListenRemove(secret_listen);
    
llSetColor(off_colorALL_SIDES);
    
llOwnerSay("/me ("+(string)secret_channel+") : OFF :");
}
 
string  hex(integer value){
    
integer digit value 0xF;
    
string text llGetSubString(strHexdigitdigit);
    
value = (value >> 4) & 0xfffFFFF;
    
integer odd TRUE;
    while(
value){
        
digit value 0xF;
        
text llGetSubString(strHexdigitdigit) + text;
        
odd = !odd;
        
value value >> 4;
    }
    if(
odd)
        
text "0" text;
    return 
text;
}
 
string  encrypt(string passwordstring message){
    
integer nonce = (integer)llFrand(0x7FFFFFFF);
    
message llMD5String(messagenonce) + message;
    
string oneTimePad llMD5String(passwordnonce);
    
integer count = (llStringLength(message) - 1) / 32;
    if(
count) do oneTimePad += llMD5String(oneTimePadnonce);
    while(--
count);
    return 
header llGetSubString("00000000" hex(nonce), -8, -1) + llXorBase64StringsCorrect(llStringToBase64(message), llStringToBase64(oneTimePad));
}
 
string  decrypt(string passwordstring message){
    
integer signature_length llStringLength(protocol_signature);
    
integer header_length signature_length 12;
    if(
llStringLength(message) < signature_length 44)
        
llOwnerSay("/me • Bugger: Insufficient data.");
    
integer index signature_length;
    
string major "0x" llGetSubString(messageindex, ++index);
    
string minor "0x" llGetSubString(message, ++index, ++index);
    
integer nonce = (integer)("0x" llGetSubString(message, ++indexindex 7));
    
message llGetSubString(messageheader_length, -1);
    
string otp llMD5String(passwordnonce);
    while(
llStringLength(otp) < (llStringLength(message) / 3))
    
otp += llMD5String(otpnonce);
    
otp llStringToBase64(otp);
    
message llXorBase64StringsCorrect(messageotp);
    
message llBase64ToString(message);
    
string digest llGetSubString(message031);
    
message llGetSubString(message32, -1);
    if(
llMD5String(messagenonce) != digest)
        
llOwnerSay("/me • Bugger: Try again?...");
    return 
message;
}
 
say(string whostring message){
    
llSetObjectName(who);
    
llSleep(llGetRegionTimeDilation()+0.04);
    
llOwnerSay(message);
    
llSetObjectName(" ");
}
 
default{
//
    
attach(key id){
        if(
id){//tests if it is a valid key and not NULL_KEY
            
llOwnerSay("/me • Channel for sim Talk /"+(string)secret_channel);
        }else{
            
llOwnerSay("/me `0'");
        }
    }
//
    
state_entry(){
        
init();
    }
//
    
touch_start(integer d){
        
active =! active;
        if(
active){
            
off();
        }else{
            
on();
        }
    }
//
    
changed(integer c){
        if(
CHANGED_OWNER){
            
llResetScript();
        }
 
    }
// 
    
link_message(integer senderinteger codestring strkey id){
        if (
str == "DCOMM"){//llMessageLinked(LINK_THIS, 0, "DCOMM","ON");
            
if(id == "ON"on();
            else if(
id == "OFF"off();
        }
    }
//
    
listen(integer channelstring namekey idstring message){
        if (
channel == secret_channel){
            if (
id == owner){
                
llRegionSay(secret_channelencrypt(passwordmessage));
                
say(name,message);
            }
            else if (
llGetAgentSize(id) == ZERO_VECTOR){
                
say(llKey2Name(llGetOwnerKey(id)),decrypt(passwordmessage));
            }
        }
    }
//