This is the source code of an included piece of LSL that I use frequently. It returns a channel number based on the key of the owner.
If you don’t use (or want to use) the Firestorm preprocessor, copy the code between the hash directives and replace the #include that led you to this page with the code you find here (that’s essentially what the preprocessor does for you automatically).
#ifndef __PRIVCHAN_DEF #define __PRIVCHAN_DEF integer privchan () { return ((integer)("0x"+llGetSubString((string)llGetOwner(),-8,-1)) & 0x3FFFFFFF) ^ 0xBFFFFFFF; } #endif // __PRIVCHAN_DEF