Advertisement
Shinobiace

ScoreBoard

Oct 8th, 2020
371
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. vector COLOR_WHITE = <1.0, 1.0, 1.0>;
  2. float  OPAQUE      = 1.0;
  3.  
  4.  
  5.  
  6. string collectname;
  7. list convertname; //list to keep track of all the players
  8. list leaderboard;
  9. list displayer;
  10. string convertname2;
  11. integer nchan;
  12. integer nhandle;
  13. key touchid;
  14. integer GetCh(key id)   // make a unieq channel from the key inputted
  15. {
  16.     return ((integer)("0x"+llGetSubString((string)id,-8,-1)) & 0x3FFFFFFF) ^ 0xBFFFFFFF;
  17. }
  18.  
  19.  
  20. key Region()  // get the region uuid
  21. {
  22.     vector z = llGetRegionCorner();
  23.  
  24.     return (key)((string)(z.x/256 + 100*z.y));
  25.  
  26. }
  27. default
  28. {
  29.     state_entry()
  30.     {
  31.        
  32.         llSay(0, "Script running");
  33.         llSetText("ScoreBoard", COLOR_WHITE, OPAQUE);
  34.        
  35.         nchan = GetCh(Region()) - 35; //unique channel
  36.         nhandle = llListen(nchan,"","","");
  37.        
  38.     }
  39.     listen(integer channel, string what, key id, string msg)
  40.     {
  41.        
  42.         if(channel == nchan)
  43.         {
  44.             key avi = llGetOwnerKey(id);
  45.             //string avi = llGetUsername(llGetOwnerKey(owner));
  46.             //llSay(0,"the Username ID is: " +(string)avi);
  47.             //key avi = llRequestUsername(llGetOwnerKey(id));
  48.            // string usavi = llGetUsername(avi);
  49.            
  50.             collectname = (string)msg;
  51.             //leaderboard = (list)collectname;
  52.             //llSay(0,(string)leaderboard);
  53.             list leaderboard = llParseString2List(collectname,["_"],[""]); // change seperator to whatever you used as seperator
  54.  
  55.             key owner = llList2String(leaderboard,0);
  56.            
  57.             string username = llList2String(leaderboard,1);
  58.  
  59.             integer totalpoints = (integer)llList2String(leaderboard,2);
  60.             //convertname2 = (string)convertname;
  61.             //string id = llList2String(leaderboard,0);
  62.            // string username = llList2String(leaderboard,0);
  63.            // string totalpoints = llList2String(leaderboard,2);
  64.            
  65.             integer idx = llListFindList(leaderboard, [avi]);
  66.             leaderboard =  ["Username: "+(string)username] +["  "]+["Total Score: "+(string)totalpoints];
  67.             //displayer += leaderboard;
  68.             llSetText("Scoreboard"+"\n"+ (string)leaderboard,COLOR_WHITE, OPAQUE);
  69.             //llSetText("Scoreboard"+"\n"+ "Username: "+(string)b +"  "+"Total Score: "+(string)c,COLOR_WHITE, OPAQUE);  
  70.            
  71.            if(idx != -1)
  72.           {
  73.              llSay(0,"Replace old user");          
  74.              leaderboard = llListReplaceList(leaderboard,["Username: "+(string)username] +["  "]+["Total Score: "+(string)totalpoints] ,idx,idx+3);  
  75.                                                          
  76.           }
  77.          
  78.           else  
  79.           {
  80.               llSay(0,"New user");
  81.           leaderboard += ["\n"]+["Username: "+(string)username] +["  "]+["Total Score: "+(string)totalpoints] ;        
  82.           }
  83.          
  84.            
  85.         }
  86.         //Click on the scoreboard to add name to scoreboard
  87.         //listen for menu correct answer
  88.         // +1 point for every correct
  89.        
  90.        
  91.        
  92.        
  93.      }
  94.      touch_start(integer num_detected)
  95.      {
  96.        
  97.          //touchid = llDetectedKey(0);
  98.          //leaderboard += convertname2;
  99.          //integer idx = llListFindList(leaderboard, [touchid]);
  100.          //leaderboard = llList2List(convertname, 0,2);
  101.          
  102.          //string stringleaderboard = llDumpList2String(leaderboard, "_");
  103.          //integer username = llListFindList(leaderboard, [1]);
  104.          //integer score = llListFindList(leaderboard, [2]);  
  105.          
  106.          
  107.      }
  108.      
  109.  
  110.    
  111. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement