Yunaofsnakes Posted July 24, 2018 Share Posted July 24, 2018 ok so im trying to make a script that sit's inside a prim and outputs a score once you distroy your opposition but i seem to be missing somethning as i can get the outputs both on the prim and in chat but i cant seem to get the output on the board or who made the kill if anyone can point me in the right way or help i would be greatful as ive been trying to fix this for a few hours now integer channel = -933; 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); } default { state_entry() { llListen(-933,"", NULL_KEY, ""); if (number_of_scores < 1) number_of_scores = 1; print_scores(); } listen(integer channel, string name, key id, string message) { if (message == "Score") { llOwnerSay("You Sank My Battleship!"); highscores += [(string)id]; highscores = llListSort(highscores, 1, FALSE); highscores = llList2List(highscores, 0, (number_of_scores * 2) - 1); print_scores(); } //else if (str == "clear scores") { highscores = []; print_scores(); } } Link to comment Share on other sites More sharing options...
Love Zhaoying Posted July 24, 2018 Share Posted July 24, 2018 We would probably need to see the other script which sends messages to the script above - as the issue could be with the other script. I hope you realize that the "id" parameter received in the listen() event, is the key/id of the object which is running the script that should be using "llSay()", "llShout()", etc. to talk to this script. It appears you are trying to use the "id" as the "score", but it will always be the UUID key of the object (or agent) which sent the message. Link to comment Share on other sites More sharing options...
Rolig Loon Posted July 24, 2018 Share Posted July 24, 2018 My guess is that what's missing is the score itself. I can see why you are adding (string)id to the highscores list. You're trying to make a strided list with pairs of score - id values. So, you have the (string)id part, but you forgot the score. I suggest sending it as part of a delimited string message and then parsing the score out of message when you receive it, something like this (where your message is "Score~25" or whatever the score is) ... list temp = llParseString2List(message,["~"],[]); if (llList2String(temp,0) == "Score") { highscores += [ (integer) llList2String(temp,1), (string)id ]; } and so on..... Link to comment Share on other sites More sharing options...
Recommended Posts
Please take a moment to consider if this thread is worth bumping.
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now