PtokaX forum

Archive => Archived 4.0 boards => Help with Lua 4 scripts => Topic started by: Winss on 04 November, 2003, 21:04:30

Title: HELP Syntax Error: unfinished string;
Post by: Winss on 04 November, 2003, 21:04:30
How can i start scripts with ptokax problem is: (Syntax Error: unfinished string;last token read: `'/**' at line 1 in file )
 
*****************************************************************

'/**
' * ShareBouncer 1.0
' * Author   : DirtyFinger
' * e-Mail   : dirtyFinger@snafu.de
' * Website   : www30.brinkster.com/dirtyfinger
' * Usage   : See the User Settings Sections down below ? Yes ? Just go there and enter stuff
'           that makes sense.
'           Once you configured the script it will check each newly connected users share for specific
'           searchstrings. If the search is unsuccessful within 20-30 seconds, the user is
'           kicked out. If EITHER search is successful, the user may stay.
' * Warning   : Passive Users don't answer to search querys, thus they ALWAYS get kicked.
'           You might want to add that to the private kickmessage in order to not piss the wrong ones off.
'           Passive Users can enter again if they are registered because registered users
'           don't get checked.
Dim sBotName
Dim dUserList
Dim oTokenizer
Dim aSearchStrings
Dim sPrivateRejectMessage,sPublicRejectMessage,sRedirectIP,sRejectMode
Sub Main ()
   '------- User Settings ---------------------------------------
   Redim aSearchStrings(1)    'When adding more searchstrings you have to increase the array first.
    aSearchStrings(0)="avi$anime"   'Put your searchstring in here (just like searching with the client. just seperate terms by $ e.g."term1$term2$term3"
    aSearchStrings(1)="mpeg$anime"   'Put your searchstring in here (just like searching with the client. just seperate terms by $ e.g."term1$term2$term3"
   sPrivateRejectMessage = "You were just kicked. DirtyFinger says you have to share something. Dunno what, because the owner forgot to customize the script."
   sPublicRejectMessage  = " was kicked by DirtyFinger because he didn't share something. Dunno what, because the owner forgot to customize the script."
   sRedirectIP = "bakaUnlimited.no-ip.no-brains.com"  'Thats where rejected ones go.
   sBotName = "ShareBouncer"   '
   sRejectMode = "kick" 'Possible modes are : "kick" "reject"
   '------- User Settings ---------------------------------------
   
   
   frmHub.registerBotName(sBotName)
   Set dUserList = CreateObject("Scripting.Dictionary")
   Set oTokenizer = new Tokenizer
   tmrScriptTimer.interval=10000     ' <- 10 seconds
   tmrScriptTimer.enabled=true    
End Sub

sub NewUserConnected (curUser) 'This event is fired when a new user logs in.
   Dim sSearch
   if not (dUserList.Exists(curUser.sName)) then
      dUserList.Add curUser.sName,2
      for each item in aSearchStrings
         curUser.SendData "$Search Hub:"+sBotName+" T?F?0?1?"+item+"|"
      next
   end if   
end sub


Sub DataArival (curUser, sCurData)
   If Left(sCurData,9) ="$GetINFO " Then Exit Sub
   If Left(sCurData,13)="$ConnectToMe " Then Exit Sub
   If Left(sCurData,16)="$RevConnectToMe " Then Exit Sub
   If Left(sCurData,8) ="$Search " Then Exit Sub
   
   if (inStr(sCurData,"$SR")) then
      oTokenizer.setTokenString(sCurData)
      if (sBotName = oTokenizer.lastToken("")) then
         'Search was requested by the bot -------------------
         sName = oTokenizer.nextToken2(" "," ")
         sSearchResult = oTokenizer.nextToken2(" ","")
         if (dUserList.Exists(sName)) then
            dUserList.Remove(sName)
         end if
         'Search was requested by the bot -------------------
      end if
   end if
End Sub

Sub tmrScriptTimer_Timer()
   for each item in dUserList.Keys
      if (dUserList(item)>0) then
         dUserList(item)= dUserList(item)-1
         'send search again in case the first search packet was lost due to , er, packet-loss
         colUsers.ItemByName(cSTR(item)).SendData "$Search Hub:"+sBotName+" T?F?0?1?"+sSearchString+"|"
      else
         colUsers.ItemByName(cSTR(item)).privateMessage cSTR(sBotName), cSTR(sPrivateRejectMessage)
         colUsers.sendChatToAll cSTR(sBotName), item + cSTR(sPublicRejectMessage)
         frmHub.doEventsForMe
      Select Case sRejectMode
         Case "kick"
            colUsers.ItemByName(cSTR(item)).kick         
         Case "redirect"
            colUsers.ItemByName(cSTR(item)).forceMove cSTR(sRedirectIP)
      End Select
         dUserList.Remove(item)         
      end if
   next   
End Sub


'--------- helper classes ------------------------------

'/**
' * StringTokenizer 1.2
' * Author : DirtyFinger
' * e-Mail : dirtyFinger@snafu.de
' * Website: www30.brinkster.com/dirtyfinger
' * Usage :
' * sub setTokenString (String)               '<-- sets the tokenString
' * function firstToken(sDelimiter)            '<-- returns the first token; sets sRestTokenString
' * function lastToken(sDelimiter)            '<-- returns the last token
' * function nextToken(sDelimiter)            '<-- returns the next token (of the sRestTokenString)
' * function nextToken2(sDelimiter1,sDelimiter2)   '<-- returns the next token between the two given delimiters
' * function hasMoreTokens(sDelimiter)         '<-- returns boolean
' * function getRestTokenString()            '<-- returns what didn't get used by firstToken/nextToken
'**/
Class Tokenizer
   private sTokenString, sRestTokenString, i, j,str
   public sub setTokenString (s)
      sTokenString = s
      sRestTokenString = s
   end sub
   public function firstToken (sDelimiter)
      i = InStr(1,sTokenString,sDelimiter)
      if (i>0) then
         firstToken = Left(sTokenString, i-1)
         sRestTokenString = Right(sTokenString, Len(sTokenString) - i - (Len(sDelimiter) - 1))
      else
         firstToken = ""
         sRestTokenString = sTokenString
      end if
   end function
   public function lastToken (sDelimiter)
      i = inStrRev(sTokenString,sDelimiter)
      lastToken = Right(sTokenString, Len(sTokenString) - i - (Len(sDelimiter) - 1))
   end function
   public function nextToken (sDelimiter)
      i = InStr(1,sRestTokenString,sDelimiter)
      if (i>0) then         
         nextToken  = Left(sRestTokenString, i-1)
         sRestTokenString = Right(sRestTokenString, Len(sRestTokenString) - i - (Len(sDelimiter) - 1))
      else
         nextToken = ""
      end if
   end function
   public function nextToken2 (sDelimiter1, sDelimiter2)
      i = InStr(1,sRestTokenString,sDelimiter1)
      j = InStr(i+1,sRestTokenString,sDelimiter2)
      str = Left (sRestTokenString, j-1)
      nextToken2 = Right(str, Len(str) - i - (Len(sDelimiter2) - 1))
      sRestTokenString = Right(sRestTokenString, Len(sRestTokenString) - j - (Len(sDelimiter2) - 1))
   end function         
   public function hasMoreTokens (sDelimiter)
      if (InStr (1,sRestTokenString,sDelimiter) >0) then
         hasMoreTokens = true
      else
         hasMoreTokens = false
      end if
   end function
   public function getRestTokenString
      getRestTokenString = sRestTokenString
   end function
end class

Function print (sMessage)
   colusers.SendChatToAll "*" , cstr(sMessage)
End Function
Title:
Post by: pHaTTy on 04 November, 2003, 21:07:41
This is not a lua script it is for DCHub >> VB
Title:
Post by: Winss on 04 November, 2003, 21:32:45
OK :rolleyes: