Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- vector COLOR_WHITE = <1.0, 1.0, 1.0>;
- float OPAQUE = 1.0;
- string collectname;
- list convertname; //list to keep track of all the players
- list leaderboard;
- string convertname2;
- integer nchan;
- integer nhandle;
- key touchid;
- integer GetCh(key id) // make a unieq channel from the key inputted
- {
- return ((integer)("0x"+llGetSubString((string)id,-8,-1)) & 0x3FFFFFFF) ^ 0xBFFFFFFF;
- }
- key Region() // get the region uuid
- {
- vector z = llGetRegionCorner();
- return (key)((string)(z.x/256 + 100*z.y));
- }
- default
- {
- state_entry()
- {
- llSay(0, "Script running");
- llSetText("ScoreBoard", COLOR_WHITE, OPAQUE);
- nchan = GetCh(Region()) - 35; //unique channel
- nhandle = llListen(nchan,"","","");
- }
- listen(integer channel, string what, key id, string msg)
- {
- if(channel == nchan)
- {
- //key avi = llGetOwnerKey(id);
- //key avi = llRequestUsername(llGetOwnerKey(id));
- // string usavi = llGetUsername(avi);
- collectname = (string)msg;
- //displayer = (list)collectname;
- //llSay(0,(string)displayer);
- list displayer = llParseString2List(collectname,["_"],[""]); // change seperator to whatever you used as seperator
- // a newly declared variable in an event is a local variable. It can be used in only the event it is declared in.
- // in this case the listen event
- // 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.
- // because the parsed list is only temporary you dont need the global varibale so you can delete it
- // you are going to need the data in other events so you need to assign the data to a global variable
- // you can asssign it to the leaderboard variable
- key owner = llList2String(displayer,0);
- string avi = llGetUsername(llGetOwnerKey(owner));
- llSay(0,"the Username ID is: " +(string)avi);
- string username = llList2String(displayer,1);
- integer totalpoints = (integer)llList2String(displayer,2);
- //convertname2 = (string)convertname;
- //string id = llList2String(displayer,0);
- // string username = llList2String(displayer,0);
- // string totalpoints = llList2String(displayer,2);
- //displayer = ["Username: "+(string)username] +[" "]+["Total Score: "+(string)totalpoints];
- integer idx = llListFindList(leaderboard, ["Username: "+(string)username]);
- //displayer = [];
- //displayer += displayer;
- if(idx != -1)
- {
- llSay(0,"Replace old user");
- leaderboard = llListReplaceList(leaderboard,["Username: "+(string)username] +[" "]+["Total Score: "+(string)totalpoints] ,idx,idx+3);
- }
- else
- {
- llSay(0,"New user");
- leaderboard += ["\n"]+["Username: "+(string)username] +[" "]+["Total Score: "+(string)totalpoints] ;
- }
- llSetText("Scoreboard"+"\n"+ (string)leaderboard + "\n",COLOR_WHITE, OPAQUE);
- //llSetText("Scoreboard"+"\n"+ "Username: "+(string)b +" "+"Total Score: "+(string)c,COLOR_WHITE, OPAQUE);
- }
- //Click on the scoreboard to add name to scoreboard
- //listen for menu correct answer
- // +1 point for every correct
- }
- touch_start(integer num_detected)
- {
- //touchid = llDetectedKey(0);
- //displayer += convertname2;
- //integer idx = llListFindList(displayer, [touchid]);
- //displayer = llList2List(convertname, 0,2);
- //string stringdisplayer = llDumpList2String(displayer, "_");
- //integer username = llListFindList(displayer, [1]);
- //integer score = llListFindList(displayer, [2]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement