diff --git a/functions.lsl b/functions.lsl index e69de29..d934657 100644 --- a/functions.lsl +++ b/functions.lsl @@ -0,0 +1,377 @@ + +string DecipherService(string payload, string ident) +{ + if(llJsonValueType(payload,[ident]) == JSON_INVALID) + { + return ""; + } + + return llJsonGetValue(payload, [ident,"protocol"]) + "://" + llJsonGetValue(payload,[ident,"host"]) + ":" + llJsonGetValue(payload,[ident,"port"]); +} + +initBasicSupport() +{ + g_lSupport = [RED_QUEEN, R_ADMIN|R_DEVELOPER|R_SUPPORT, + ARIA, R_ADMIN|R_DEVELOPER|R_SUPPORT + ]; +} + +integer checkSupportUser(key kID, integer minAccessRights) +{ + integer iIndex=llListFindList(g_lSupport, [(string)kID]); + if(iIndex!=-1) + { + integer iMask = (integer)llList2String(g_lSupport, iIndex+1); + if(iMask & minAccessRights) + { + return TRUE; + }else return FALSE; + } + return FALSE; +} +checkSupport() +{ + UpdateDSRequest(NULL, llHTTPRequest(API_SERVER + "/zni/Get_Support.php", [], ""), SetDSMeta(["get_support"])); +} +string MakeTimeNotation(integer iSec) +{ + integer iDifference = iSec; + + integer Days = iDifference/ONE_DAY; + iDifference -= (ONE_DAY*Days); + integer Hours = iDifference/60/60; + iDifference -= (Hours*60*60); + integer Minutes = iDifference/60; + iDifference -= (Minutes*60); + + list lItem = [Days,"d", Hours, "h", Minutes, "m", iDifference, "s"]; + return llDumpList2String(lItem, ""); +} +string MakeTimeNotationFloated(float iSec) +{ + float iDifference = iSec; + + integer Days = llRound(iDifference/ONE_DAY); + iDifference -= (ONE_DAY*Days); + integer Hours = llRound(iDifference/60/60); + iDifference -= (Hours*60*60); + integer Minutes = llRound(iDifference/60); + iDifference -= (Minutes*60); + + list lItem = [Days,"d", Hours, "h", Minutes, "m", llRound(iDifference), "s", llRound((iDifference - llRound(iDifference))*1000), "ms"]; + return llDumpList2String(lItem, ""); +} + +// Returns in the same format as Make: Days, Hours, Minutes, Seconds, TotalSeconds +list ParseTimeNotation(string sNotation) +{ + integer Days; + integer Hours; + integer Minutes; + integer Seconds; + integer TotalSec; + + list lTmp = llParseString2List(llToLower(sNotation), [], ["d", "h", "m", "s"]); + integer i = 0; + integer end = llGetListLength(lTmp); + for(i=0;i> 1; + } + + return sStr; +} + +integer IsLikelyUUID(string sID) +{ + if(sID == (string)NULL_KEY)return TRUE; + if(llStringLength(sID)==32)return TRUE; + key kID = (key)sID; + if(kID)return TRUE; + if(llStringLength(sID) >25){ + if(llGetSubString(sID,8,8)=="-" && llGetSubString(sID, 13,13) == "-" && llGetSubString(sID,18,18) == "-" && llGetSubString(sID,23,23)=="-") return TRUE; + + } + return FALSE; +} + +integer IsLikelyAvatarID(key kID) +{ + if(!IsLikelyUUID(kID))return FALSE; + // Avatar UUIDs always have the 15th digit set to a 4 + if(llGetSubString(kID,8,8) == "-" && llGetSubString(kID,14,14)=="4")return TRUE; + + return FALSE; +} + +integer IsListOfIDs(list lIDs) +{ + integer i=0; + integer end = llGetListLength(lIDs); + for(i=0;i