|
Kain Cleaver
Registered User
Join date: 24 Jan 2006
Posts: 178
|
08-24-2006 10:06
Hi i need some help
i need a script that will keep a high score list
my object would send a linked message with the score and player to the object that will set the highscore above said object.
so the rundown of it would be
player inserts money Game starts game racks points up (already have this system down) game ends points and players name gets sent via Linkedmessage to highscore display prim
high score display prim determines if this score is highest and if it is.. it is displayed
preferably id like to have top 3 players if this is possible
i would greatly appreciate help. and $1000L to the first person who helps me with a working script. thanks
Kain Cleaver
|
|
Rickard Roentgen
Renaissance Punk
Join date: 4 Apr 2004
Posts: 1,869
|
08-24-2006 10:51
vector text_color = <1.0, 1.0, 1.0>; integer number_of_scores = 3;
list highscores = [];
print_scores() { string text = "HIGH SCORES\n----------------"; integer i; for (i = 0; i < (number_of_scores * 2); i += 2) { if (llList2Integer(highscores, i) == 0) { text += "\n-"; } else { text += "\n" + llList2String(highscores, i + 1) + " (" + llList2String(highscores, i) + ")"; } } llSetText(text, text_color, 1.0); }
state default { state_entry() { if (number_of_scores < 1) number_of_scores = 1; print_scores(); } on_rez(integer sparam) { print_scores(); } link_message(integer sender, integer num, string str, key id) { if (str == "score" && num > 0) { highscores += [num, (string)id]; highscores = llListSort(highscores, 2, FALSE); highscores = llList2List(highscores, 0, (number_of_scores * 2) - 1); print_scores(); } else if (str == "clear scores") { highscores = []; print_scores(); } } } so sending a score via link message would look like: llMessageLinked(LINK_SET, score, "score", name);* Note: If score (the number part of the link message) is 0, then the message will be ignored by the above script.if you want to clear the high scores send this: llMessageLinked(LINK_SET, 0, "clear scores", NULL_KEY);an empty scores list will look something like: HIGH SCORES ---------------- - - -a full scores list will look like: HIGH SCORES ---------------- Avatar One (524) Avatar Two (235) Avatar Three (102)You can change the number of scores displayed by changing the number_of_scores variable at the top of the script. If you set the number too high, the display text might get too long and be cut off. If you set it waaay too high your script might crash. 3 should be pretty safe  . If you set it below 1, then the script will reset it to 1.
|
|
Kain Cleaver
Registered User
Join date: 24 Jan 2006
Posts: 178
|
08-24-2006 18:36
whats your SL name? i cant seem to find you on SL.
|
|
Rickard Roentgen
Renaissance Punk
Join date: 4 Apr 2004
Posts: 1,869
|
08-24-2006 19:40
well, presumably you have the key of whoever got the score somewhere in there. If you have that then you can use llKey2Name(key) and turn that into a string of their name. llKey2Name only works for someone in the same region however so you need to use it as soon as you have the key and then store the name instead of the key. oh and here's a slightly simpler version of your chuck function chuck() { integer index = llCeil(llFrand(13.99) + 0.001); // Even chance of any number from 1-14. llMessageLinked(LINK_SET, 0, "rez"+(string)index, NULL_KEY); } this is my sl name, make sure the online checkbox is unchecked.
|
|
Kain Cleaver
Registered User
Join date: 24 Jan 2006
Posts: 178
|
08-24-2006 21:57
i got it figured out after some time lol. finally! yay ill get online now to send you the 1000  thank you much
|