Jump to content

Sorting list from server data


Shihan Feiri
 Share

You are about to reply to a thread that has been inactive for 4633 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

 

I have list on server with names and uuids

 

This data I recive from server via httpRequest in  format:

Data1|data1a| Data2|data2a|Data3|data3a|Data4|data4a|Data5|data5a|

0r

(

amanda|e4b745dc-9ca0-4475-bb5d-ef088e2b8f7f|Sam|e4b745dc-9ca0-4475-bb5d-ef088e2b8f7f|John|e4b745dc-9ca0-4475-bb5d-ef088e2b8f7f| etc....

)

So first NAME then UUID, then again NAME, and UUID  etc

Now i need to sort this

When i get dialog i will get names. With choice of name script will use  data 2 (uuid)

So if eg.  I use data1 what is name (amanda),  script will use second data that is amandas  uuid

My question is how to do that.

I know how to make list of names, and list of uuids, but i dont know how to conect  them. Mybe mine list are complitly uselessy, so I pray for help here.

this is what i have for now.

 

default
{
    state_entry()
    {
        //Request for bots naes and uuids
        http_request_id = llHTTPRequest("http://event-media-shs.com/test.php", [],"");
        // Request for bots groups and uuids of group
        http_request_id2 = llHTTPRequest("http://event-media-shs.com/test2.php", [],"");
      
       
   
    }
 
    http_response(key request_id, integer status, list metadata, string body)
    {
        if (request_id == http_request_id)
        {
           list temp = llParseString2List(body,["|"],[]);
             integer i;
            for (i=0;i<llGetListLength(temp);++i)
                {
                    if (i%2 == 0)
                    {
                        botName += [llList2String(temp,i)];
                    }
                    else
                    {
                        botUUID += [(key)llList2String(temp,i)];
                    }
                } 
        llSay(0,"Bots names and UUID+s");
        llSay(0,body);
       
        }
 
         else if(request_id == http_request_id2)
        {
           
         list temp = llParseString2List(body,["|"],[]);
             integer i;
            for (i=0;i<llGetListLength(temp);++i)
                {
                    if (i%2 == 0)
                    {
                        botGroupName += [llList2String(temp,i)];
                    }
                    else
                    {
                        botGroupUUID += [(key)llList2String(temp,i)];
                    }
                } 
 
            
        llSay(0,"bots group and uuids"); 
        llSay(0,body);
        }
        
    }
          
   
      touch_start(integer total_number)
        {
        
//        SAMPLE   
         llDialog(llDetectedKey(0),"Msg",botGroupName,1);
        
//     IF NAME IS CLICKED WE GET LIST OF NAMES OF BOTS
//        WHEN NAME OF BOT IS CLIKED WE GET HIS UUID

//    IF GROUP IS CLICKED WE GET LIST OF GROUP
 //   when name of group is clicked we get uuid of group
       
        }
        
 listen( integer channel, string name, key id, string message )
{
    if(message=="Name")
        {
//        SAMPLE llDialog(llDetectedKey(0),"here are list of names",["List of names"],3);
}
        else if(message=="Group")
        {
//           SAMPLE  llDialog(llDetectedKey(0),"here are list of groups",["List of groups"],3); 
        
 /// ect.....
}
}
   
}

 


Link to comment
Share on other sites

If I understand you correctly, you want to select the right UUID when a name is chosen. That's prety simple - you take the result of the dialog - let's call it message and look up at which index that result is in your name list:

integer index llListFindList(botName, [message]);

Since the UUIDs are in the same order as the names, the corresponding UUID is:

key UUID = llList2Key(botUUID, index);

One thing you have to take care of, is that the strings you use as names on the dialog (and in the list) aren't longer than 24 characters or you number them and put the numbered names as the message on the dialog.

Link to comment
Share on other sites

llList2ListStrided( server_list, 0, -1, 2 )

will yield a list of all names for use in the dialog, then when one is chosen, use llListFindList to get the index, add 1, and use that number in llList2Key

 

or....

 

use list2listStrided to make separate lists of names and keys, and then the indexes will be the same. this has the benefit of less memory overhead while running (if the original list is big)

 

be careful of names that are more than 24bytes though, they will break the dialog.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4633 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...