Advertisement
Gayngel

ScoreBoard(UPDATED_1)

Oct 8th, 2020 (edited)
1,778
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. string convertname2;
  10. integer nchan;
  11. integer nhandle;
  12. key touchid;
  13. integer GetCh(key id)   // make a unieq channel from the key inputted
  14. {
  15.     return ((integer)("0x"+llGetSubString((string)id,-8,-1)) & 0x3FFFFFFF) ^ 0xBFFFFFFF;
  16. }
  17.  
  18.  
  19. key Region()  // get the region uuid
  20. {
  21.     vector z = llGetRegionCorner();
  22.  
  23.     return (key)((string)(z.x/256 + 100*z.y));
  24.  
  25. }
  26. default
  27. {
  28.     state_entry()
  29.     {
  30.        
  31.         llSay(0, "Script running");
  32.         llSetText("ScoreBoard", COLOR_WHITE, OPAQUE);
  33.        
  34.         nchan = GetCh(Region()) - 35; //unique channel
  35.         nhandle = llListen(nchan,"","","");
  36.        
  37.     }
  38.     listen(integer channel, string what, key id, string msg)
  39.     {
  40.        
  41.         if(channel == nchan)
  42.         {
  43.             //key avi = llGetOwnerKey(id);
  44.            
  45.             //key avi = llRequestUsername(llGetOwnerKey(id));
  46.            // string usavi = llGetUsername(avi);
  47.            
  48.             collectname = (string)msg;
  49.             //displayer = (list)collectname;
  50.             //llSay(0,(string)displayer);
  51.             list displayer = llParseString2List(collectname,["_"],[""]); // change seperator to whatever you used as seperator
  52.  
  53.  
  54.             // a newly declared variable in an event is a local variable. It can be used in only the event it is declared in.
  55.             // in this case the listen event
  56.            
  57.             // if a global variable and a local variable are called the same the compiler gets confused where to assign it to the global variable or the local variable.
  58.  
  59.             // because the parsed list is only temporary you dont need the global varibale so you can delete it
  60.            
  61.             // you are going to need the data in other events so you need to assign the data to a global variable
  62.            
  63.             // you can asssign it to the leaderboard variable
  64.  
  65.             key owner = llList2String(displayer,0);
  66.             string avi = llGetUsername(llGetOwnerKey(owner));
  67.             llSay(0,"the Username ID is: " +(string)avi);
  68.             string username = llList2String(displayer,1);
  69.  
  70.             integer totalpoints = (integer)llList2String(displayer,2);
  71.             //convertname2 = (string)convertname;
  72.             //string id = llList2String(displayer,0);
  73.            // string username = llList2String(displayer,0);
  74.            // string totalpoints = llList2String(displayer,2);
  75.            
  76.            
  77.             //displayer =  ["Username: "+(string)username] +["  "]+["Total Score: "+(string)totalpoints];
  78.             integer idx = llListFindList(leaderboard, ["Username: "+(string)username]);
  79.             //displayer = [];
  80.             //displayer += displayer;
  81.          
  82.            
  83.            if(idx != -1)
  84.           {
  85.              llSay(0,"Replace old user");          
  86.              leaderboard = llListReplaceList(leaderboard,["Username: "+(string)username] +["  "]+["Total Score: "+(string)totalpoints] ,idx,idx+3);                                
  87.           }
  88.          
  89.           else  
  90.           {
  91.               llSay(0,"New user");
  92.               leaderboard += ["\n"]+["Username: "+(string)username] +["  "]+["Total Score: "+(string)totalpoints] ;              
  93.           }
  94.          
  95.              llSetText("Scoreboard"+"\n"+ (string)leaderboard + "\n",COLOR_WHITE, OPAQUE);
  96.             //llSetText("Scoreboard"+"\n"+ "Username: "+(string)b +"  "+"Total Score: "+(string)c,COLOR_WHITE, OPAQUE);  
  97.         }
  98.         //Click on the scoreboard to add name to scoreboard
  99.         //listen for menu correct answer
  100.         // +1 point for every correct
  101.        
  102.        
  103.        
  104.        
  105.      }
  106.      touch_start(integer num_detected)
  107.      {
  108.        
  109.          //touchid = llDetectedKey(0);
  110.          //displayer += convertname2;
  111.          //integer idx = llListFindList(displayer, [touchid]);
  112.          //displayer = llList2List(convertname, 0,2);
  113.          
  114.          //string stringdisplayer = llDumpList2String(displayer, "_");
  115.          //integer username = llListFindList(displayer, [1]);
  116.          //integer score = llListFindList(displayer, [2]);  
  117.          
  118.          
  119.      }
  120.      
  121.  
  122.    
  123. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement