Jump to content

Float Text High Score Script


Boopadoopdoop
 Share

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

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

Recommended Posts

Friend helped me do this, but I can't for the life of me figure out how to sort the scores, how I need it to work, is anyone with a higher number score be sorted to the top of the list, I also need to script in a limit of 5 scores to be shown at once [tho keeping that limit changeable would be nice too]

 

Quote

//format is [User UUID, score, User UUID, score, ...]
list scores;

add_Key_and_Score(string user)
{
    //find their index in the list
    //it is important that if we put STRINGS in the list we search for STRINGS
    //if you put a KEY in your list instead of a STRING, the STRING search won't find it
    //this is why the function takes an input of string as the argument
    
    integer find_in_list = llListFindList(scores,[user]);
    
    //if they are in the list, update their score
    if( ~ find_in_list )
    {
        //extract old score
        integer score = llList2Integer(scores, find_in_list + 1);
        
        //update it
        score += 1;
        
        //replace the old score with the new one in the list (using the same index)
        scores = llListReplaceList( scores, [score], find_in_list + 1, find_in_list + 1 );
    }
    
    //if they are not in the list, add them to it
    else
    {
        scores += [user, 1];
    }
}
display_score()
{
    //iterate over the scores list and generate ssome formatted output
    list output;
    integer x;
    integer n = llGetListLength(scores);
    for(x=0;x<n;x+=2)
    {
        string name = llGetDisplayName(llList2String(scores,x));
        if( name == "" )
        name = "NOT IN REGION";
        
        string score = llList2String(scores,x+1);
        
        string entry = name + " : [" + score + "]";
        output += entry;
    }
    llSetLinkPrimitiveParamsFast(LINK_THIS,[PRIM_TEXT,llDumpList2String(output,"\n"),<llFrand(1),llFrand(1),llFrand(1)>,1]);
}

default
{
    touch_start(integer n)
    {
        while(~--n) { add_Key_and_Score(llDetectedKey(n)); }
        display_score();
    }
}

 

I tried using llListSort, but I'm either using it wrong, or am not sure how to implement it correctly.

 

Any pointers would be appreciated!

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1517 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...