touchbound_system:prisoner_id_generator
This is an old revision of the document!
This is the function that my prison cells use to generate semi-unique prisoner ID numbers that are unique for each avatar. I am releasing this code to make it easy for other creators & people running roleplay locations to generate matching prisoner IDs across multiple systems.
Feel free to make the code more efficient and adapt it to your needs, but please do not modify how IDs are generated, to keep everything compatible.
string GeneratePrisonerID(key kUUID) { integer legacy = llSubStringIndex(llGetUsername(kUUID),".") != -1; string sRaw = llSHA1String(kUUID); if(legacy) //SDDDD { integer iChar = (integer)("0x"+llGetSubString(sRaw,1,4)) % 26; string sResult = llGetSubString(CHARS,iChar,iChar); return sResult + llGetSubString((string)((integer)("0x"+llGetSubString(sRaw,9,13)) + 10000),1,4); } else //DDDDD return llGetSubString((string)((integer)("0x"+llGetSubString(sRaw,0,4)) + 100000),1,5); }
touchbound_system/prisoner_id_generator.1643655284.txt.gz · Last modified: 2022/01/31 18:54 by kyrahabattoir