// Personal Ad Board v1.4 // This version has menus for getting a card and liking a board for normal users // And for board owners has the option to display the last 20 people who have liked the board integer given; integer liked; integer MAX_LIKES = 20; list likesList = []; integer dialogChannel; integer dialogHandle; string menuDialog = "\nWhat would you like to do?\nClick \"Close\" to close the menu."; list menuButtons = ["Get Card", "Like", "Close"]; open_menu(key inputKey, string inputString, list inputList) { dialogChannel = (integer)llFrand(DEBUG_CHANNEL)*-1; dialogHandle = llListen(dialogChannel, "", inputKey, ""); llDialog(inputKey, inputString, inputList, dialogChannel); llSetTimerEvent(30.0); } close_menu() { llSetTimerEvent(0); llListenRemove(dialogHandle); } default { on_rez(integer start_param) { llResetScript(); } state_entry() { given = 0; llOwnerSay("Be sure to only have one notecard in the inventory."); llOwnerSay("Touch at any time to see how many notecards have been given away!"); llSetText("Touch for details\n(liked " + liked + " times)", <0.90196, 0.72549, 0.35294>, 1.0); } touch_start(integer total_number) { key avatarKey = llDetectedKey(0); string avatarName = llDetectedName(0); if ( avatarKey != llGetOwner() ) { close_menu(); open_menu(avatarKey, menuDialog, menuButtons); } else if ( avatarKey == llGetOwner() ) { llOwnerSay((string)given + " notecards have been given away since this object was last started."); llOwnerSay("Your board has been liked " + (string)liked + " times."); for (integer i = 0; i < llGetListLength(likesList); i++) { llOwnerSay(llList2String(likesList, i)); } } } listen(integer channel, string avatarName, key avatarKey, string message) { if(channel != dialogChannel) return; close_menu(); if(message == "Like") { liked = liked + 1; llSetText("Touch for details\n(liked " + liked + " times)", <0.90196, 0.72549, 0.35294>, 1.0); key ownerOfThisObject = llGetOwner(); string date = llGetDate(); string logEntry = avatarName + " liked your board at " + llGetRegionName() + " on " + date + "\n"; llInstantMessage(ownerOfThisObject, logEntry); // Remove the avatar from the list if they already exist and reduce the liked count as well integer idx = llListFindList(likesList, [avatarName + " (" + avatarKey + ") liked your board."]); if (idx != -1) { likesList = llDeleteSubList(likesList, idx, idx); liked = liked - 1; } // Add the avatar name and key to the end of the list likesList += [avatarName + " (" + avatarKey + ") liked your board."]; // Check if the list exceeds the maximum size and remove the oldest entry if (llGetListLength(likesList) > MAX_LIKES) { likesList = llDeleteSubList(likesList, 0, 0); } } else if(message == "Get Card") { given = given + 1; llGiveInventory(avatarKey, llGetInventoryName(INVENTORY_NOTECARD, 0)); } } }