User Tools

Site Tools


touchbound_system:prisoner_id_generator

This is the function that my prison cells use to generate semi-unique prisoner ID numbers that are permanent 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/or adapt it to your needs, all I am asking is that you 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("ABCDEFGHIJKLMNOPQRSTUVWXYZ",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.txt · Last modified: 2022/01/31 19:03 by kyrahabattoir