Advertisement
Shinobiace

ScoreBoard(UPDATED_1)

Oct 8th, 2020
448
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.            
  46.             //key avi = llRequestUsername(llGetOwnerKey(id));
  47.            // string usavi = llGetUsername(avi);
  48.            
  49.             collectname = (string)msg;
  50.             //displayer = (list)collectname;
  51.             //llSay(0,(string)displayer);
  52.             list displayer = llParseString2List(collectname,["_"],[""]); // change seperator to whatever you used as seperator
  53.  
  54.             key owner = llList2String(displayer,0);
  55.             string avi = llGetUsername(llGetOwnerKey(owner));
  56.             llSay(0,"the Username ID is: " +(string)avi);
  57.             string username = llList2String(displayer,1);
  58.  
  59.             integer totalpoints = (integer)llList2String(displayer,2);
  60.             //convertname2 = (string)convertname;
  61.             //string id = llList2String(displayer,0);
  62.            // string username = llList2String(displayer,0);
  63.            // string totalpoints = llList2String(displayer,2);
  64.            
  65.            
  66.             //displayer =  ["Username: "+(string)username] +["  "]+["Total Score: "+(string)totalpoints];
  67.             integer idx = llListFindList(displayer, ["Username: "+avi]);
  68.             //displayer = [];
  69.             //displayer += displayer;
  70.             llSetText("Scoreboard"+"\n"+ (string)displayer + "\n",COLOR_WHITE, OPAQUE);
  71.             //llSetText("Scoreboard"+"\n"+ "Username: "+(string)b +"  "+"Total Score: "+(string)c,COLOR_WHITE, OPAQUE);  
  72.            
  73.            if(idx != -1)
  74.           {
  75.              llSay(0,"Replace old user");          
  76.              displayer = llListReplaceList(displayer,["Username: "+(string)username] +["  "]+["Total Score: "+(string)totalpoints] ,idx,idx+3);                                
  77.           }
  78.          
  79.           else  
  80.           {
  81.               llSay(0,"New user");
  82.               displayer += ["\n"]+["Username: "+(string)username] +["  "]+["Total Score: "+(string)totalpoints] ;              
  83.           }
  84.          
  85.            
  86.         }
  87.         //Click on the scoreboard to add name to scoreboard
  88.         //listen for menu correct answer
  89.         // +1 point for every correct
  90.        
  91.        
  92.        
  93.        
  94.      }
  95.      touch_start(integer num_detected)
  96.      {
  97.        
  98.          //touchid = llDetectedKey(0);
  99.          //displayer += convertname2;
  100.          //integer idx = llListFindList(displayer, [touchid]);
  101.          //displayer = llList2List(convertname, 0,2);
  102.          
  103.          //string stringdisplayer = llDumpList2String(displayer, "_");
  104.          //integer username = llListFindList(displayer, [1]);
  105.          //integer score = llListFindList(displayer, [2]);  
  106.          
  107.          
  108.      }
  109.      
  110.  
  111.    
  112. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement