Jump to content

Reset script to clear the list


Tattooshop
 Share

You are about to reply to a thread that has been inactive for 1244 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Hello! This is a DJ song request tool and I am trying to add a script reset option to update the song request list for this script. I am trying to add a line like this but I get an error every time. it is not clear where to insert it. Thanks in advance! :)

listen( integer channel, string name, key id, string message )

if (message == "reset") llResetScript();

   integer DEDICATION_CHANNEL = 98;
   
   list requests = [];
   
   default
   {
   
       touch_start(integer total_number)
       {
           if(llDetectedKey(0) != llGetOwner())
               jump user;
           if(llGetListLength(requests) == 0) {
               llOwnerSay("No dedications are currently lined up.");
               return;
           }
           llOwnerSay("---------------— BEGIN REQUESTS —----------------");
           integer itra;
           for(itra=0; itra<llGetListLength(requests); itra+=3) {
               llOwnerSay(llList2String(requests, itra) + " requested the song: " + llList2String(requests, itra+1));
               llOwnerSay("With the dedication: " + llList2String(requests, itra+2));
               if(itra+3<llGetListLength(requests)-1)
                   llOwnerSay("-------------------------------------------------------");
           }
           llOwnerSay("----------------— END REQUESTS —-----------------");
           return;
   @user;
           integer comHandle = llListen(DEDICATION_CHANNEL, "", llDetectedKey(0), "");
           llInstantMessage(llDetectedKey(0), "To request the song \"That's Life - Frank Sinatra\" with the dedication \"For my friend Lydia, I love you!\", you would type into the main chat:\n\n/" + (string)DEDICATION_CHANNEL + " That's life - Frank Sinatra%For my friend Lydia, I love you!\n\nThe forward-slash and the number after the slash are important.");
       }
   
       listen( integer channel, string name, key id, string message )
       {
           if(channel != DEDICATION_CHANNEL) return;
   
           requests +=  (list)name + llList2List(llParseString2List(message, ["%"], [""]), 0, 0) + llList2List(llParseString2List(message, ["%"], [""]), 1, 1);
           llInstantMessage(id, "Thank you! Your dedication has been stored and will be played at the DJ's convenience.");
       }
   }

 

Edited by Tattooshop
Link to comment
Share on other sites

51 minutes ago, Fritigern Gothly said:

Why would you reset the script to clear the list?
If you want to clear the requests list, just use 
 requests = [];
That will clear that list without having to reset the whole script.

Thank you so much! but where to add it?

If (message == "reset") requests = [];

Link to comment
Share on other sites

33 minutes ago, Tattooshop said:

Thank you so much! but where to add it?

If (message == "reset") requests = [];

it goes in the listen event. A quick hax is something like:
 

listen( integer channel, string name, key id, string message )
{
   if(channel != DEDICATION_CHANNEL) return;

   if (id == llGetOwner()) // ensure only the owner can reset the request list
   {                       // with open chat message: /98reset
      if (llToLower(message) == "reset")     
      {      
         requests = [];
         return;
      }
   }
   
   requests +=  (list)name + llList2List(llParseString2List(message, ["%"], [""]), 0, 0) + llList2List(llParseString2List(message, ["%"], [""]), 1, 1);
   llInstantMessage(id, "Thank you! Your dedication has been stored and will be played at the DJ's convenience.");
}

 

  • Like 2
  • Thanks 1
Link to comment
Share on other sites

36 minutes ago, Mollymews said:

it goes in the listen event. A quick hax is something like:
 


listen( integer channel, string name, key id, string message )
{
   if(channel != DEDICATION_CHANNEL) return;

   if (id == llGetOwner()) // ensure only the owner can reset the request list
   {                       // with open chat message: /98reset
      if (llToLower(message) == "reset")     
      {      
         requests = [];
         return;
      }
   }
   
   requests +=  (list)name + llList2List(llParseString2List(message, ["%"], [""]), 0, 0) + llList2List(llParseString2List(message, ["%"], [""]), 1, 1);
   llInstantMessage(id, "Thank you! Your dedication has been stored and will be played at the DJ's convenience.");
}

 

Thank you so much! :)👍

 

  • Like 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1244 days.

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
 Share

×
×
  • Create New...